Vote count:
0
I have this PHP Code:
$conn=mysql_connect($dbhost,$dbusername,$dbpassword);
mysql_select_db($dbname,$conn);
if(!function_exists("ContactLookup")) {
function ContactLookup($sequence) {
global $conn;
$sql="SELECT * from contacts where sequence = '".$sequence."' ";
$rs=mysql_query($sql,$conn) or die(mysql_error());
$result=mysql_fetch_array($rs);
return $result;
}
}
and i call the function here:
echo ContactLookup($_SESSION["integra-uk.net"]["customer_sequence"]);
but its showing up this error:
Warning: mysql_query() expects parameter 2 to be resource, null given in /home/integra/public_html/wp_pages/index.php on line 132
i cannot work out what the issue is with $conn
I have tested the database connection and it works fine. I have also run queries outside of functions and they work okay so its an issue with the $conn variable being passed into the functions.
The code i have on my own PHP files and then those PHP files are included inside a wordpress site
asked 18 secs ago
Aucun commentaire:
Enregistrer un commentaire