muskelmann098 Posted December 17, 2009 Share Posted December 17, 2009 When I try to run the following piece of code, I get this error: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/muskelmann098/public_html/build.php on line 37 Here is the area of the code where I think the problem is: /*--36--*/ $b = "SELECT * FROM users WHERE town = '$town' AND username = '$name'"; /*--37--*/ $b_res = mysql_query($b,$conn)or die(mysql_error()); /*--38--*/ $barray = mysql_fetch_array($b_res)or die(mysql_error()); /*--39--*/ $blev = $barray["$building"]; I'm not really sure what is wrong with the SQL query as I'm using almost exactly the same syntax a few lines above. I hope someone here might see where I messed up. Thanks in advance Link to comment https://forums.phpfreaks.com/topic/185465-mysql-query-problem/ Share on other sites More sharing options...
rajivgonsalves Posted December 17, 2009 Share Posted December 17, 2009 if your using the same syntax in the above lines and its working then the only thing I think what could be going wrong will be the $conn variable is getting overwritten if you post more code it would be helpful. Link to comment https://forums.phpfreaks.com/topic/185465-mysql-query-problem/#findComment-979162 Share on other sites More sharing options...
muskelmann098 Posted December 17, 2009 Author Share Posted December 17, 2009 Thanks for that. You were right, I neglected to declare the $conn variable within the function. I fixed it and it works now. Thanks a lot for your help. Link to comment https://forums.phpfreaks.com/topic/185465-mysql-query-problem/#findComment-979171 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.