RE: [PHP] debugging problems
| From: | Don Read | Date: | Fri, 18 May 2001 13:54:42 +0000 |
| Subject: | RE: [PHP] debugging problems | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-53413@lists.php.net to get a copy of this message | ||
On 18-May-01 Taline Makssabo wrote:
> This is a program i wrote to get some information at keep track with some
> stats. I am very new at this so bare with me....I keep on getting this
> Warning:
>
> Warning: Supplied argument is not a valid MySQL result resource in
> /home/virtual/ppcu/home/httpd/html/php2/stat.php on line 13
>
> Warning: Supplied argument is not a valid MySQL-Link resource in
> /home/virtual/ppcu/home/httpd/html/php2/stat.php on line 17
>
> Whats wrong???? Is it my code? Please help.
>
> <?
>
> global $dblink,$PHP_SELF;
> $ip = getenv("REMOTE_ADDR");
> $host = getenv("HTTP_HOST");
> $browser = getenv("HTTP_USER_AGENT");
> $referer = getenv("HTTP_REFERER");
> $sql = "SELECT ipaddress FROM stat WHERE ipaddress = '$ip'";
> $connection = @mysql_connect("localhost", "username",
> "password") or
> die("Couldn't connect.");
Not too informative:
die ('<p>problems ' .mysql_errno()
.'<BR>'.mysql_error()."<BR>\n");
but anyhow, ok, you're connected.
> $db_name = "contact";
> $table_name = "stat";
What are these ?
are you missing mysql_select_db($db_name); ?
> $result = @mysql_query($sql, $dblink);
Test your queries !
if ($result) {
> $num = mysql_num_rows($result);
> if( $num == 0 )
> {
> $sql ="INSERT INTO stat(ipaddress,host,browser,referer,filename)
> VALUES('$ip', '$host', '$browser',
> '$referer','$PHP_SELF')";
> $result=mysql_query($sql,$dblink);
> $sql1="INSERT INTO hits(ipaddress,count) VALUES('$ip',1)";
> $result1=@mysql_query($sql1,$dblink);
> $text="you had a new visitor from IP: $ip, Host: $host Browser:
> $browser Referer: $referer";
> if ($result)
> {
> mail("taline@prepresshelp.com", "You had a new
> visitor",$text,
"FROM:
> stat@prepresshelp.com.com");
> }
> }else{
> $sql = "UPDATE hits SET count = count + 1 where ipaddress='$ip'";
> $result =@mysql_query($sql, $dblink) ;
> $sql2 = "UPDATE stat SET filename ='$PHP_SELF' where
> ipaddress='$ip'";
> $result2 =@mysql_query($sql2, $dblink) ;
> }
> ?>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
--
Don Read dread@texas.net
-- It's always darkest before the dawn. So if you are going to
steal the neighbor's newspaper, that's the time to do it.