techiefreak05 Posted January 5, 2007 Share Posted January 5, 2007 I have a function that checks if you are friends with a user ... and i am friends with someone but this function is returning false even tho i AM. this function has worked on my server. but when i got a host.. they have MySQL 3.23.. and I have 4.0 .. how would i change the syntax to please version 3.23??[code]<?phpfunction isFriend($a,$b){ global $conn; $q = "select * from `friends` where `friend` = '$a' and `username` ='$b' AND `accepted` = 'yes'"; $result = mysql_query($q,$conn); return (mysql_num_rows($result) > 0);}?>[/code]**this code has worked on MySQL 4.0 .. but no 3.23 Link to comment https://forums.phpfreaks.com/topic/32919-function-issues/ Share on other sites More sharing options...
trq Posted January 5, 2007 Share Posted January 5, 2007 Try some debugging to try and find ou whats going on.[code=php:0]$result = mysql_query($q) or die(mysql_error());[/code]PS; You do not need to declare $conn as global, in fact you don't need to declare it at all. Link to comment https://forums.phpfreaks.com/topic/32919-function-issues/#findComment-153354 Share on other sites More sharing options...
.josh Posted January 5, 2007 Share Posted January 5, 2007 to clarify thorpe's PS:if you are going to specify the connection in his query, you need to declare $conn, but you don't need to pass that argument in your query, unless you are wanting the query to be run on a specific connection you made. And I have a sneaking suspicion that you have not established multiple connections to the database, so you don't need to specify that argument. msyql_query will automatically look for a connection if none is specified, and that's already on the global level. $mysql_query($q);all by itself will work. Link to comment https://forums.phpfreaks.com/topic/32919-function-issues/#findComment-153359 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.