Forum Moderators: coopster & phranque

Message Too Old, No Replies

Parse error: parse error, unexpected T_STRING

         

Waterline

8:02 pm on May 18, 2003 (gmt 0)



I have seen suggestions that a semicolon that is missing will cause this error... I have looked and looked and looked this code over and CANNOT find a missing semi colon.

Can someone else see what I am obviously missing?

Parse error: parse error, unexpected T_STRING in /home/ppocd/www/ppocd/modules/Recipes/index.php on line 13

#12 /************************************************************************/
#13
#14 if (!eregi("modules.php", $_SERVER['PHP_SELF'])) {

So.. no missing semicolons on Line #12/13.

When I remove the calls to these two functions, the error goes away:

function listRecipes() {

$result = mysql_query("SELECT * FROM nuke_recipes ORDER BY name);

if(!$result) {
echo "No recipes in our database.";
$return;
} else {
$i=0;
while($row = mysql_fetch_array($result)) {
$i++;
echo "<a href=\"modules.php?name=Recipes&rid=".$row[id]."\">".$row[name]."</a>\n";
}
}
mysql_free_result($result);

}

function showRecipe($rid) {

$result = mysql_query("SELECT * FROM ".$prefix."_recipes WHERE rid = ".$rid);

$row = mysql_fetch_array($result);

echo "<b>Recipe Name:</b> ".$row[name]."<br>\n"
."<b>Instructions:</b><br>".$row[recipe]."<br>\n";

mysql_free_result($result);

}

Any ideas?

jatar_k

8:18 pm on May 18, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld Waterline,

What often happens is those types of errors drop through from somewhere above the line where it says the error occurred. Have you looked at the couple of lines above line 13?

WeirdCode

8:37 pm on May 18, 2003 (gmt 0)

10+ Year Member



waterline, if this is really your code -

$result = mysql_query("SELECT * FROM nuke_recipes ORDER BY name);

- then it's not a missing ; but rather a missing " at the end of the query string which should read

$result = mysql_query("SELECT * FROM nuke_recipes ORDER BY name");

jatar_k

8:39 pm on May 18, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld WeirdCode, good catch, that's probably it.

phpmaven

8:49 pm on May 18, 2003 (gmt 0)

10+ Year Member



One problem I see right off the bat is that you are missing a closing quote on the following line:

$result = mysql_query("SELECT * FROM nuke_recipes ORDER BY name);

should be:

$result = mysql_query("SELECT * FROM nuke_recipes ORDER BY name");

also the following line will not work:

$result = mysql_query("SELECT * FROM ".$prefix."_recipes WHERE rid = ".$rid);

You need to build the text of your query first and then feed mysql_query() a formatted query string. For example:

$table = $prefix."_recipes";
$sql = "SELECT * FROM $table WHERE rid = '$rid'";
mysql_query($sql);

If "rid" is a numeric field in the database, then remove the single quotes around $rid.

Hope that helps.

bergm57

12:21 am on Jun 12, 2003 (gmt 0)

10+ Year Member



I am experiencing a similar problem but being the wretched newbie that I am, I cannot figure out what is up. Please help!

Parse error: parse error, unexpected T_STRING in /home/sites/home/web/p/processForm.php on line 14

Here is the code.

1 <html>
2 <head>
3 <title>Process Form Data</title>
4 </head>
5 <body>
6 <h3>Your information has been processed.</h3>
7
8 <?php
9
10 $linkID = mysql_connect("localhost", "root", "xxxx");
11
12 mysql_select_db("surplus", $linkID);
13
14 mysql query("INSERT INTO equipment (qty, model, descript, vendor, locale, date, price)
VALUES ($qty, $model, $descript, $vendor, $date, $price)", $linkID);
15
16 print "$qty, $model , $descript , $vendor , $locale , $date , $price<br>";
17
18 mysql_close($linkID);
19
20?>
21
22 </body>
23 </html>

Thanks!

grahamstewart

12:30 am on Jun 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Line 14: mysql query should be mysql_query

bergm57

2:44 pm on Jun 12, 2003 (gmt 0)

10+ Year Member



Oh Brother! Thanks, Graham...