Jump to content

function issues


techiefreak05

Recommended Posts

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]
<?php
function 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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.