Saturday, December 29, 2018

php - Parse error: syntax error, unexpected 'text' (T_STRING), expecting ',' or ';'




I am having trouble getting this to work. I have been able to call data from a dropdown menu and place it into a table and have it actively update without reloading the page. I am now trying to get the database information that is called to appear within a text input field or another drop down menu.



So basically I have a drop down menu that will call up user information, I am trying to get that information that is called to appear within another form so I can update it. Here is the code I am working with;




table7.php














Person info will be listed here.







getuser2.php



$q = intval($_GET['q']);
$con=mysqli_connect("localhost","user","password","database");

// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}


$sql="SELECT * FROM users WHERE id = '".$q."'";
$result1 = mysqli_query($con,$sql);



echo "




";

echo "";

while($row1 = mysqli_fetch_array($result1)) {

echo "";
echo "";
echo "";
echo "";
echo "";
}

echo "";

echo "
UsernameE-MailInfo 1
" . $row1['email'] . "" . $row1['info1'] . "
";


mysqli_close($con);
?>


Within the getuser2.php code if you strip out the form input section and replace it with a call for uname using the format directly below for email and info it will display the data called from the database in standard text format.



However, I am encountering this error:





Parse error: syntax error, unexpected 'text' (T_STRING), expecting ',' or ';' in C:\wamp\www\getuser2.php on line 25



Answer



The problem is the following:



echo "";


You have double quotes inside a double-quoted string. PHP doesn't know where the string ends.




An easy fix (since you're not using variables inside the string anyway) is to change the double quotes to single quotes:



echo '';

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...