Hi Im getting the following error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/sharpene/public_html/intouch/chat.php on line 19 Code (markup): My line 19 is: echo "<b>".$row["name"]."</b>";
That means your select statement is probably wrong (it's not selecting the necessary data from the database). Could you post some more code so we can see exactly what's wrong?
I doubt that's the line php think is 19, but anyway. The result sent to mysql_fetch_array() is not valid, that means that the query in your code that looks something like this $result = mysql_query("some sql query"); The problem is either that this mysql query doesnt return any rows or that there is an error in the query, it's probably the first.
The full document <html> <head> <style type="text/css"> <!-- body,td,th { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; color: #000000; } --> </style> </head> <body bgcolor="#ffcc66"> <meta http-equiv="refresh" content="5"> <?php include "sql.php"; $showit = mysql_query("SELECT * FROM `staffchat` ORDER BY `id` DESC"); while($row = mysql_fetch_array($showit)){ echo "<b>".$row["name"]."</b>"; echo ": ".$row["body"]."<br>"; } mysql_close(); ?> </body> </html>
many things could have gone wrong... but my suspicion is that your mysql_query command returned an error. 1. does your staffchat table contain a name field? 2. run the exact sql command manually in phpmyadmin directly against the database to determine if the sql command is valid.
Try replacing your line number 19 and line number 20 with this: echo "<b>".$row['name']."</b>"; echo ": ".$row['body']."<br>"; Bye
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/lmigueza/public_html/dd172/unit 4 (DD172)/topic_15/config.php on line 34 I keep getting this same warning and I dont know what else to do I have check it as far as the punctuation but maybe I am over looking something since I stare at this so much. I have put the script in here so you know what I am talking about...thanks! <?php define('DB_HOST', 'localhost'); define('DB_USER', 'dd172web_dd172us'); define('DB_PASSWORD', '1235'); define('DB_NAME', 'dd172web_test'); mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die(mysql_error() . 'Not able to contact the host'); mysql_select_db(DB_NAME) or die(mysql_error() . 'Not able to connect with database'); function returnNavigation(){ $sql = "SELECT * FROM tblcategories"; $result = mysql_query($sql); return resultToArray($result); } function resultToArray($result){ $array = array(); while($rs = mysql_fetch_array($result)){ $array[] = $rs; } return $array; } function returnArtwork($category_id){ $sql = 'SELECT * FROM tblartwork WHERE category_id = ' . $category_id; $result = mysql_query($sql); return resultToArray($result); } ?> The one in bold is line 34.
instead of ".$row['name']." put {$row['name']} i think both will work, but curly brackets are easier Also, for the query problem. does your sql.php automatically connect your query to the database? Or do you need your query to call to a connection variable. eg. $showit = mysql_query("SELECT * FROM `staffchat` ORDER BY `id` DESC",$CONNECTION); if so, perhaps you forgot to have the query connect.
Hi I know this is a very old thread. I have replied that for the all future visitors with a view to helping them: see below: $result = mysql_query("select count(*) from cart where cookieId = '" . GetCartId() . "' and itemId = $itemId"); Cart is table name here. I know that when table name is too short and without underscore thn mql shows the error. because mysql can not detect short name. when table name is too short and without underscore thn you must have to add ` both side of the table name in query. Or if u dont want to add ` thn select a name with a underscore or select a long name. See example and try below one and both will work : $result = mysql_query("select count(*) from `cart` where cookieId = '" . GetCartId() . "' and itemId = $itemId"); or, $result = mysql_query("select count(*) from cart_1 where cookieId = '" . GetCartId() . "' and itemId = $itemId");