The changes were:
1) I had many more columns in the table...one for each page I was monitoring. Therefore,
the insert portion reflected that.
2) On the main page code, I set a variable to go into one column rather than set a variable
telling it what page that I was recording and setting a second variable to indicate a hit.
That's all I did. And I'm not sure why those two changes would make it insert a row as
expected and then a second row with the IP address and date (cutting out the variables
from the main page).
Jeremy
--- In [email protected], "Gerry Danen" <[EMAIL PROTECTED]> wrote:
>
> You're not giving us all your code, before and after your changes, so all we
> can do is speculate...
>
> I can tell you what I do. I use require_once to include a file with
> functions. Once of those functions is a logging function like you show. I
> call that function whenever I need it. No dups.
>
> Probably not very helpful to your question why this behaviour, but perhaps a
> good guideline to fix the problem.
>
> Gerry
>
> On 6/4/06, Jer <[EMAIL PROTECTED]> wrote:
> >
> > I've got a file of code that is included in a page. I recently made a
> > change to the code and
> > now the script executes multiple times.
> >
> > In the main file, I've got this:
> >
> > if ( $_SERVER[SERVER_NAME] == "www.domain.com" )
> > {
> > $pagename = 'index';
> > $hitcount = 'X';
> >
> > include("include/userlog.php");
> > }
> >
> > In userlog.php, I've got this:
> >
> > $dt_logged = date("Y-n-j H:i:s");
> > $ip_addr = GetHostByName($REMOTE_ADDR);
> >
> > @ $db = mysql_pconnect("localhost", "x", "x");
> >
> > if (!$db)
> > {
> > print 'Error: Could not connect to database. Please try again
> > later.';
> > exit;
> > }
> >
> > mysql_select_db("dbname");
> > $insert_query = "insert into tablename values ('".$dt_logged."',
> > '".$ip_addr."', '".
> > $pagename."', '".$hitcount."', '".$pagevar."', '".$searchterm."')";
> > $insert_result = mysql_query($insert_query) or die(mysql_error());
> >
> >
> > It worked before I changed the database structure. I reduced the number of
> > columns and
> > now it seems that the included file executes twice and, for the second
> > execution, does not
> > take the variables set in the main file into account. So, I get two rows
> > added to my
> > table...one with all variables, even the ones set in the main file; and a
> > second row with just
> > the IP address and date.
> >
> > What would cause this?
> >
> > Many thanks,
> >
> > Jer
> >
> >
> >
> >
> >
> >
> > The php_mysql group is dedicated to learn more about the PHP/MySQL web
> > database possibilities through group learning.
> >
> >
> >
> > SPONSORED LINKS
> > American general life and accident insurance company<http://groups.yahoo.com/
gads?t=ms&k=American+general+life+and+accident+insurance+company&w1=American
+general+life+and+accident+insurance+company&w2=American+general+life
+insurance+company&w3=American+general+life&w4=American+general
+mortgage&w5=American+general+life+insurance&w6=Computer+internet
+security&c=6&s=230&.sig=Kzn1J6ZDdsfc3f-9JZ-bKQ> American
> > general life insurance company<http://groups.yahoo.com/gads?t=ms&k=American
+general+life+insurance+company&w1=American+general+life+and+accident
+insurance+company&w2=American+general+life+insurance+company&w3=American
+general+life&w4=American+general+mortgage&w5=American+general+life
+insurance&w6=Computer+internet
+security&c=6&s=230&.sig=q5Z_Gheyyf5dB3KHCkTGOw> American
> > general life<http://groups.yahoo.com/gads?t=ms&k=American+general
+life&w1=American+general+life+and+accident+insurance+company&w2=American
+general+life+insurance+company&w3=American+general+life&w4=American+general
+mortgage&w5=American+general+life+insurance&w6=Computer+internet
+security&c=6&s=230&.sig=1O42IK5r5LJ1BBWLyTAAKA> American
> > general mortgage<http://groups.yahoo.com/gads?t=ms&k=American+general
+mortgage&w1=American+general+life+and+accident+insurance
+company&w2=American+general+life+insurance+company&w3=American+general
+life&w4=American+general+mortgage&w5=American+general+life
+insurance&w6=Computer+internet+security&c=6&s=230&.sig=AC-
EcyrN2MPgqHTxt6lmKg> American
> > general life insurance<http://groups.yahoo.com/gads?t=ms&k=American+general
+life+insurance&w1=American+general+life+and+accident+insurance
+company&w2=American+general+life+insurance+company&w3=American+general
+life&w4=American+general+mortgage&w5=American+general+life
+insurance&w6=Computer+internet
+security&c=6&s=230&.sig=P8vNlXr7QopQQ3tGIepE4Q> Computer
> > internet security<http://groups.yahoo.com/gads?t=ms&k=Computer+internet
+security&w1=American+general+life+and+accident+insurance
+company&w2=American+general+life+insurance+company&w3=American+general
+life&w4=American+general+mortgage&w5=American+general+life
+insurance&w6=Computer+internet+security&c=6&s=230&.sig=OCFX-
MPv3cQROoYDEaexxA>
> > ------------------------------
> > YAHOO! GROUPS LINKS
> >
> >
> > - Visit your group "php_mysql<http://groups.yahoo.com/group/php_mysql>"
> > on the web.
> >
> > - To unsubscribe from this group, send an email to:
> > [EMAIL PROTECTED]<php_mysql-
[EMAIL PROTECTED]>
> >
> > - Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> > Service <http://docs.yahoo.com/info/terms/>.
> >
> >
> > ------------------------------
> >
>
>
>
> --
> Gerry
> http://dev.danen.org/
>
>
> [Non-text portions of this message have been removed]
>
The php_mysql group is dedicated to learn more about the PHP/MySQL web database possibilities through group learning.
SPONSORED LINKS
| American general life and accident insurance company | American general life insurance company | American general life |
| American general mortgage | American general life insurance | Computer internet security |
YAHOO! GROUPS LINKS
- Visit your group "php_mysql" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
