Jump to content
xisto Community
Sign in to follow this  
iGuest

Php Error

Recommended Posts

Okey, so I got this error: Parse error: syntax error, unexpected T_STRING in C:wampwwwragnhildprosjekt1visinnlegg.php on line 48

 

I've read about T_STRING but I cant solve this problem. Here is the code:

 

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {  $insertSQL = sprintf("INSERT INTO kommentar (tittel, navn, tekst, tidsstempel, innleggid) VALUES ( %s, %s, %s, NOW(), %s)'					   GetSQLValueString($_POST['tittel'], "text"),					   GetSQLValueString($_POST['navn'], "text"),					   GetSQLValueString($_POST['tekst'], "text"),  GetSQLValueString($_GET['innleggid'], "int")  );

and line 48 is: GetSQLValueString($_POST['tittel'], "text"),

Can somebody please help me out with this?

Edited by moderator (see edit history)

Share this post


Link to post
Share on other sites

The problem is actually on line 47: you open the "INSERT INTO..." with a double quote, but close it with a single quote. And the PHP interpreter thinks the single quote is a part of the string started at the beginning, and that that string is continuing onto line 48... now when you finally have a double string, "text", it thinks that's where the string ends, and it doesn't know what to do with the line that says "text", since you would need a closing parentheses of the sprintf, or a comma for the next parameter, before you can make any new assertions like that: and that's why you get that error. Oh, and just for the future, to make sure you don't make the same mistake again, you should've been able to figure all this out simply by looking at the fact that the GetSQLValueString is green instead of black in the code parser previewer on this forum.

Share this post


Link to post
Share on other sites

You have got a problem with the quotes in the code snippet that you have posted. If you are using Notepad or a text editor that does not automatically create the closing quote for you when you type the opening quote, I would suggest that you try a different PHP editor. NuSphere's PhpEd is good stuff. Komodo makes a good IDE and editor too, but they do have stability issues that they are trying to work out - when they do, they'll have a good product to offer. Notepad++ and many other free editors, will show you the closing quote when you click on the opening quote or vice-versa. Try different source code editors and see what works for your coding style.

Share this post


Link to post
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
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.