Jump to content

syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE),


Kez323

Recommended Posts

Hi!

 

I'm getting this PHP syntax error on line 87 of my file.

 

ERROR: PHP Parse error:  syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)

 

The function works fine, if I take the function out of that file and put it into a separate file, it works fine.

	function get_UserId($username){
		
		include('config.php');
		
		// Check connection
		if ($conn->connect_error) {
			die("Connection failed: " . $conn->connect_error);
		} 
		$sql = "SELECT id FROM users WHERE username='$username'";
		$result = $conn->query($sql);
		$row = $result->fetch_assoc();
		$id = $row['id'];
		$conn->close();
		return $id;
	}

Thanks

Edited by Kez323
Link to comment
Share on other sites

I would have expected you to actually show us the LINE IN QUESTION instead of talking about some function working "fine".

 

Your line numbers (a PIA when you cut and paste your code!) - are they really the line numbers that the error message refers to or just some editor lines numbers that you pasted here? The line:

 

$id = $row['id'];

certainly doesn't have any problem so the " in the error message must be located somewhere else. Does the error message refer to another file perhaps?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.