Jump to content

[SOLVED] Function won't return variables!


burntheblobs

Recommended Posts

For some reason, this function will not return $cxn. Here a simple function that I am using to connect to my database. If I just stick the code right in my program it works, however if I try to call it as a function, it does not. Even when I put the information directly into the $cxn variable, it does not work.

 

function dbconnect()
{
$user="MYUSERNAME";
$host="localhost";
$password="MYPASSWORD";
$database="MYDATABASE";
$cxn = mysqli_connect($host,$user,$password,$database)
	or die ("Couldn't Connect to server.");
return $cxn;
}

Link to comment
https://forums.phpfreaks.com/topic/130387-solved-function-wont-return-variables/
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.