Jump to content

T string


topflight

Recommended Posts

I am new to php and I was just playing around making a code and now I am receiving

 

Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\addnewsv.php on line 44

 

this error message and this is line 44


$update = mysql_query("INSERT INTO `news` (authorname,date,newstitle,newsart,ip) VALUES ('$_POST[authorname]','$now','$_POST[newstitle]','$_POST[newsart]','$ip')")or die mysql_error());

 

many somebody please tell me what the matter is.

 

Thanks in advanced.

Link to comment
https://forums.phpfreaks.com/topic/127341-t-string/
Share on other sites

try this

<?php
$update = mysql_query("INSERT INTO `news` (authorname,date,newstitle,newsart,ip) VALUES ('".mysql_real_escape_string($_POST['authorname'])."','$now','".mysql_real_escape_string($_POST['newstitle'])."','".mysql_real_escape_string($_POST['newsart'])."','$ip')")or die (mysql_error());
?>

 

always use mysql_real_escape_string at the very minimum for user input

Link to comment
https://forums.phpfreaks.com/topic/127341-t-string/#findComment-658742
Share on other sites

T String i'm pretty sure refers to String, like $string or $foo_bar. Unexpected T String usually comes up when you don't use a semi colen when you should (so look at the previous line of code. For instance: error on line 44, look at line 43) or when you don't close up a statement (for instance in a if statement: if(isset($string){ $stuff= "foo"; } //you'd be missing the second ")" in the statement and it would likely tell you unexpected T string or {, I don't remember)

That is just in my experience and imho.

Best of luck in you learnings.

Link to comment
https://forums.phpfreaks.com/topic/127341-t-string/#findComment-658745
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.