Wildhalf Posted December 30, 2006 Share Posted December 30, 2006 Hi,I need help.. I designed my site on my local pc testing my php with xampp... Everything was working fine but now that i have uploaded my site it get the following error message...Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource the code is as follows...*************************// Get database connectioninclude 'db.php';// Create variables from URL.$refer_id = $_REQUEST['id'];//If domain is visited without a refer the site uses the following if ($refer_id == ""){ $refer_id = 75645361;}//retrieves information from database...$sql = mysql_query("SELECT * FROM tblFriends WHERE myspace_id='$refer_id'");$data = mysql_fetch_array($sql); -->Line that is causing the problem//adds array information to a variable$friend_1 = $data[friend_1];$friend_2 = $data[friend_2];$friend_3 = $data[friend_3];$friend_4 = $data[friend_4];$friend_5 = $data[friend_5];$friend_6 = $data[friend_6];/* Let's strip some slashes in case the user enteredany escaped characters. */$friend_id = stripslashes($friend_id);$friend_1 = stripslashes($friend_1);$friend_2 = stripslashes($friend_2);$friend_3 = stripslashes($friend_3);$friend_4 = stripslashes($friend_4);$friend_5 = stripslashes($friend_5);$friend_6 = stripslashes($friend_6);hope someone ccan help me...Kieron Quote Link to comment https://forums.phpfreaks.com/topic/32280-solved-mysql_fetch_array-problem/ Share on other sites More sharing options...
wildteen88 Posted December 30, 2006 Share Posted December 30, 2006 If you are getting that error then there is a problem with your query:[code]//retrieves information from database...$sql = mysql_query("SELECT * FROM tblFriends WHERE myspace_id='$refer_id'");$data = mysql_fetch_array($sql); -->Line that is causing the problem[/code] add an or die clause after the query in order to see whats wrong with your query:[code]//retrieves information from database...$qry = "SELECT * FROM tblFriends WHERE myspace_id='$refer_id'";$sql = mysql_query($qry) or die("An internal error has occured!<br />Unable to run the following query:<br /><pre>" . $qry. "</pre><br /><br />" . mysql_error());$data = mysql_fetch_array($sql);[/code]Post the error you get now. Quote Link to comment https://forums.phpfreaks.com/topic/32280-solved-mysql_fetch_array-problem/#findComment-149833 Share on other sites More sharing options...
Wildhalf Posted December 30, 2006 Author Share Posted December 30, 2006 Thank you very much...Ill have to remember that one in future....All that was wrong was trying to get the info from tblFriends but table name was tblfriends... renamed the table on my servers side and all is well...thanks againkieron Quote Link to comment https://forums.phpfreaks.com/topic/32280-solved-mysql_fetch_array-problem/#findComment-149836 Share on other sites More sharing options...
wildteen88 Posted December 30, 2006 Share Posted December 30, 2006 yeah you have to watch out for typos. When ever you are dealing with databases always add the or die caluse to the end of mysql_query so you can easily catch the errors with your queries. Otherwise you'll be sat there for a while wondering what the hells going on. After you finished developing your scripts you should take the or die clauses out. Just for security. Quote Link to comment https://forums.phpfreaks.com/topic/32280-solved-mysql_fetch_array-problem/#findComment-149869 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.