7 Replies - 1859 Views - Last Post: 30 August 2010 - 12:59 PM Rate Topic: -----

#1 gymangel812  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 116
  • Joined: 15-February 10

Parse error: syntax error, unexpected T_STRING, expecting ','

Posted 30 August 2010 - 10:47 AM

Can't seem to figure out what is causing this error:
"Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'"

require_once ('mysqli_connect.php');

		$title="Ultimate Video Game Connection is now open!";
		$link="http://www.DEVELOPMENT-DESIGNS-BY-SARA.com/uvgc/index.php";
		$description="Ultimate Video Game Connection is now open! We sell used video games from NES to Xbox 360, PS3, and Wii.
		We specialize in hard to find and out of print items.";

		// Create a query to insert data into the comments table
		$query = "INSERT INTO feed (title, link, description, recorddate)
          	  	  VALUES ('$title', '$link', '$description', NOW() )";

		// Execute the query
		$result = mysqli_query ($dbc, $query);
		if ($result) { // If it ran OK.

			echo '<p>Added to Database</p>';

		} else { // If it did not run OK.

			echo '<p>Didn't Work.</p>';

	        }

		mysqli_close($dbc); // Close the database connection.


Is This A Good Question/Topic? 0
  • +

Replies To: Parse error: syntax error, unexpected T_STRING, expecting ','

#2 PhunkRabbit  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 81
  • View blog
  • Posts: 406
  • Joined: 23-August 10

Re: Parse error: syntax error, unexpected T_STRING, expecting ','

Posted 30 August 2010 - 10:56 AM

too many )'s Edit: nope, my bad.

$query = "INSERT INTO feed (title, link, description, recorddate)
	                  VALUES ('$title', '$link', '$description', NOW() )";
	 



Found it ^^

Need to escape the ' here:

echo '<p>Didn't Work.</p>';



use:
echo '<p>Didn\'t Work.</p>';


or
echo "<p>Didn't Work.</p>";


This post has been edited by PhunkRabbit: 30 August 2010 - 10:54 AM

Was This Post Helpful? 1
  • +
  • -

#3 gymangel812  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 116
  • Joined: 15-February 10

Re: Parse error: syntax error, unexpected T_STRING, expecting ','

Posted 30 August 2010 - 11:20 AM

That fixed it, thanks. But for some reason the info is not being added to the database. any idea why?
require_once ('mysqli_connect.php');

		$title="Ultimate Video Game Connection is now open!";
		$link="http://www.DEVELOPMENT-DESIGNS-BY-SARA.com/uvgc/index.php";
		$description="Ultimate Video Game Connection is now open! We sell used video games from NES to Xbox 360, PS3, and Wii.
		We specialize in hard to find and out of print items.";

		// Create a query to insert data into the comments table
		$query = "INSERT INTO feed (title, link, description, recorddate)
          	  	  VALUES ('$title', '$link', '$description', NOW() )";

		// Execute the query
		$result = mysqli_query ($dbc, $query);
		if ($result) { // If it ran OK.

			echo '<p>Added to Database</p>';

		} else { // If it did not run OK.

			echo '<p>Did not Work.</p>';

	        }

		mysqli_close($dbc); // Close the database connection.


Was This Post Helpful? 0
  • +
  • -

#4 suniahk  Icon User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 27
  • Joined: 22-May 10

Re: Parse error: syntax error, unexpected T_STRING, expecting ','

Posted 30 August 2010 - 11:34 AM

What do you mean it's not adding it? Are you getting your '<p>Did not Work.</p>' line, or is the query working successfully, but not adding anything? I'm not familiar with using MySQLi, but a bit of poking around on PHP's site shows that there is indeed an error message. Try changing
'<p>Did not Work.</p>'
to
mysqli_error($dbc)
and see if that helps debug at all.
Was This Post Helpful? 0
  • +
  • -

#5 PhunkRabbit  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 81
  • View blog
  • Posts: 406
  • Joined: 23-August 10

Re: Parse error: syntax error, unexpected T_STRING, expecting ','

Posted 30 August 2010 - 11:35 AM

Your using mysqli, does that not mean you have to use it in the OOP fasion, im using it atm myself however have not tryed using it in a procedual way.

$mysqli = new mysqli;
if($mysqli->query("INSERT INTO `feed` (title, link, description, recorddate) VALUES ('$title','$link','$description', NOW())"))
{
    echo '<p>Added to Database</p>';
}
else
{
    echo '<p>Did not Work.</p>';    
}
$mysqli->close();


Was This Post Helpful? 0
  • +
  • -

#6 gymangel812  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 116
  • Joined: 15-February 10

Re: Parse error: syntax error, unexpected T_STRING, expecting ','

Posted 30 August 2010 - 11:54 AM

magically it started working after taking out the didn't work put.
Was This Post Helpful? 0
  • +
  • -

#7 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3490
  • View blog
  • Posts: 10,058
  • Joined: 08-June 10

Re: Parse error: syntax error, unexpected T_STRING, expecting ','

Posted 30 August 2010 - 12:55 PM

View PostPhunkRabbit, on 30 August 2010 - 06:35 PM, said:

Your using mysqli, does that not mean you have to use it in the OOP fasion, im using it atm myself however have not tryed using it in a procedual way.

both is possible, though the OOP style allows for more flexibility.
Was This Post Helpful? 1
  • +
  • -

#8 PhunkRabbit  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 81
  • View blog
  • Posts: 406
  • Joined: 23-August 10

Re: Parse error: syntax error, unexpected T_STRING, expecting ','

Posted 30 August 2010 - 12:59 PM

View PostDormilich, on 30 August 2010 - 06:55 PM, said:

View PostPhunkRabbit, on 30 August 2010 - 06:35 PM, said:

Your using mysqli, does that not mean you have to use it in the OOP fasion, im using it atm myself however have not tryed using it in a procedual way.

both is possible, though the OOP style allows for more flexibility.


Thanks, thats interesting to know.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1