Jump to content

Parse Error: Syntax Error, Unexpected '{'


strago

Recommended Posts

<?php
session_start();
ob_start();
mysql_connect("localhost", "root", "XXXXX") or die(mysql_error());
mysql_select_db("XXXXX") or die(mysql_error());

$page_name = $_GET["id"];

$q = mysql_query("SELECT * FROM `memes` WHERE `id` LIKE '$page_name'");
while($result = mysql_fetch_assoc($q){
 $db_title = $result["title"];
 $db_image = $result["image"];
 $db_body = $result["body"];
}
echo "
 <h1>$db_title</h1>
 <p>$db_image</p>
 Text: $db_body
";

?>

 

generates

 

Parse error: syntax error, unexpected '{' in /home/site1/public_html/Memes.php on line 10

 

Line 10 being

 

while($result = mysql_fetch_assoc($q){

 

I'm trying to use the URL to get the content from the database.

 

filename.php?id=1

Link to comment
https://forums.phpfreaks.com/topic/270266-parse-error-syntax-error-unexpected/
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.