Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unexpected T_STRING? Eh..

Status
Not open for further replies.

BittenApple

Programmer
Jan 4, 2005
7
GB
It says unexpected T_STRING in line 9, but I dont get it, whats a string? I read a tutorial on reading errors, but it say T_'then problem of name' but I dont know what a string is..
this is my line 8-10

Code:
8  //Start table
9  echo "<table width="100%">
10 "

Heh, I know the "100%" is wrong, because it must include some slashes, but i've tried with/without 'em.. anyone can to help?

O, and btw, is there a program that checks any errors in the program - I tried PSPAD and PHP CODER PRO! but none of them seem to do it.. :(

Thanks guys, you'r all big helps!!
 
When you use quotes within qoutes you should escape them:
Code:
echo "This is a \"string\"";
Backslash is used as an escape character here. Alternatively, php supports both single and double quotes around strings. As such, you can use single quotes for html strings to make them more readable.
Code:
echo '<table width="100%">';
This will work beautifully.
 
You're trying to use doublequotes inside of doublequotes. PHP is interpreting this is as:

echo the string "<table width=", then
the bare string 100%, then
the string ">"

and it doesn't know what to do with the bare string 100%.

You must either escape the interior doublequotes:

echo "<table width=\"100%\">
";

or use doublequotes within singlequotes:

echo '<table width="100%">
';

I prefer the latter, as it makes the script more readable. There are differences in the behavior of the two quotes and how interior variable references are handled. See for more information.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Wow thanks, it seems to be working..

But, now its turned into a T_LNUMBER -- :S

Code:
echo '<table width="100%">';
thats what it is - whats a LNUMBER?
 
What are the lines before this one. Sometime the parser won't put out a messages until it can't figure what anything means.

Ken
 
<?php
function shoutView(){
$color1 = "#466A2B";
$color2 = "#568434";
$e_shout = mysql_query("SELECT FROM 'shoutbox');
echo '<table width="100%">';

I edited loads of lines, so now the problem is on line 6.. heh. Btw, ''db.php'' in included in index.php, and this file is included in index.php so theres no problem connecting to database..

Error:

Parse error: parse error, unexpected T_LNUMBER in ''not to be shown'' on line 6
 
One problem I see is with this line:

$e_shout = mysql_query("SELECT FROM 'shoutbox');

You're not closing your outermost quotes. The line should read:

$e_shout = mysql_query("SELECT FROM 'shoutbox'[red]"[/red]);


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Haha, thank you so much sleipnir. I feel like such an idiot!! :p
 
Parse error" is PHP's way of saying, "Hold on, I'm confused."

With that in mind, it's important to remember that the line number PHP gives in a parse error is not the line where the actual error will reside, but rather the line at which PHP realizes is is confused. The two can be, but are not necessarily, one and the same. In my experience, the line with the actual error most often falls before the line which PHP reports.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
A nicer way to handle errors is actually to check after the line if it errored. That way you can control how the error is handled better then just stopping the script and telling the user possibly the information they need to circumvent some of your programming.

Code:
$sql = mysql_query("SELECT * FROM `none`");
if (!$sql) {
   //Handle Error Here
} else {
   //Use this for your normal execution or put die(); under the previous condition
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top