FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


could use some help..simple one line issue





dz9c
trying to make this visitor counter or whatever. get this error:
Code:
Counter :
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/dz9c/domains/dz9c.frih.net/public_html/real_visitor_counter.php on line 26


here is the .php file its referring to:

Code:
<?
session_start();

// Connect database
mysql_connect("localhost","dz9c_counter","gamers");
mysql_select_db("tutorial");

if(!session_is_registered("visitor")){
$visitor=session_id();
session_register("visitor");

// Update value in column "all_visitor" by +1.
mysql_query("update easy_counter set all_visitor=all_visitor+'1'");
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
Counter :
<?
// Select data from easy_counter and put them into $result.
$result=mysql_query("select * from easy_counter");
$row=mysql_fetch_assoc($result);

// Output all_visitor record.
echo $row['all_visitor'];

// Close database connection.
mysql_close();
?>
</body>
</html>
hexkid
You need to test the return value of mysql_query() and, in fact, of almost all mysql_* functions.

Code:
// ...
$result = mysql_query("whatever");
if (!$result) {
  // the query failed. For simplicity sake we exit with the error
  exit('Query failed: ' . mysql_error());
}
$row = mysql_fetch_assoc($result);
// ...
Related topics
[TUTOR] A Short Intro to GD
Interview: Derek Liu, Gaia Online Anime Community
PHPBB fantastico problem
What graphic format to use, answers
Is New Orleans worth rebuilding?
Some cPanel and cvsquestions and stuff
airbrush tutorial
[php] can't display rss feeds using rss2html.php
anyone know of a good php form processer script
Frihost time. -Marketplace-
Help Simple PHP Problem
my sub domain is not working
Forum Philosophy
The Work Update
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.