sk1tL1L Posted October 3, 2006 Share Posted October 3, 2006 Hello, i've got abit of a problem[code] <?phpinclude ("config.php");// Retrieve data from database$sql= "SELECT * FROM messages WHERE to='$member'"; $result=mysql_query($sql);while($rows=mysql_fetch_array($result)){?><table width="400" border="1" cellspacing="0" cellpadding="3"><tr><td width="10%"><? echo $rows['from']; ?></td><td width="40%"><? echo $rows['message']; ?></td></tr></table><?php}mysql_close();?>[/code]Whic displays an error:[code]Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\xampp\xampp\htdocs\TFP\messages.php on line 51[/code]I'm Trying to make my own PM system, it will be great if you can help me with this. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted October 3, 2006 Share Posted October 3, 2006 echo out the query and run it in phpmyadmin I suspect you are retunring 0 rows. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted October 3, 2006 Share Posted October 3, 2006 If the query were returning zero rows, the OP wouldn't get an error, but the while loop wouldn't execute. That error usually occurs when the query has a syntax error. Change the mysql_query() to:[code]<?php $result=mysql_query($sql) or die("There is a problem with the query: $sql<br>" . mysql_error()); ?>[/code]Check the error that prints, and fix the problem...Ken Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted October 3, 2006 Share Posted October 3, 2006 make the $member variable '".$member."'. i dont like code that isnt like that. or you can add { and } i think. Quote Link to comment Share on other sites More sharing options...
sk1tL1L Posted October 7, 2006 Author Share Posted October 7, 2006 ok thanks everyone,[code]<?php $result=mysql_query($sql) or die("There is a problem with the query: $sql<br>" . mysql_error()); ?>[/code]that helped me out! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.