Jump to content

undefined variable


etsted
 Share

Recommended Posts

this is a little reference from my live chat script, but it wont work. The error message is variable $con is not defined, but it is clearly defined.

 

$con = mysqli_connect("localhost","root","123","chat") or die(mysqli_error($con));function get_msg(){ $query = mysqli_query($con, "SELECT Sender, Message FROM chat"); $run = mysqli_query($con, $query); $messages = array(); while($message = mysqli_fetch_assoc($run)){ $messages = array('sender' => $message['Sender'], 'message' => $message['Message']); } return $messages; }

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...