PHP4 to PHP3 problem
| From: | Rob Griffiths | Date: | Tue, 10 Apr 2001 20:49:01 +0000 |
| Subject: | PHP4 to PHP3 problem | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-8461@lists.php.net to get a copy of this message | ||
I have a simple little corporate phonebook app that I developed in PHP4/mySQL, but our work department is only running PHP3 (and they want to leave it that way, for fear of breaking other PHP apps ... sigh).
Anyway, the following code snippet produces this error message when I run it in PHP3:
Parse error: parse error, expecting
STRING' or NUM_STRING' or `'$'' in subs3.php3 on line 50
Here's what line 50 looks like, with a bit of surrounding syntax, and the dbquery routine, in case that's the problem. line 51 causes the same problems (both are shown on multiple-lines, but they're one line in the source file)
... various bits deleted ...
function dbquery($sql) {
$db = mysql_connect('localhost','foo','bar');
@mysql_select_db('phonelist') or die();
$result = @mysql_query($sql,$db);
if (mysql_errno() == 0 && !empty($result)) {
return $result;
} else {
return "There was an error";
exit;
}
}
function searchit($sql) {
global $words,$howsort,$first,$last,$dep,$ext,$mgr;
$result = dbquery($sql);
$nrows = mysql_num_rows($result);
if ($nrows > 0) {
... various bits deleted ...
for ($x=1;$x<=$nrows;$x++) {
$A = mysql_fetch_array($result);
if ($A["ismgr"] == "Yes") {
**50** print "<tr bgcolor=#66FFFF><td>{$A["fname"]}</td>" .
"<td>{$A["lname"]}</td>" . "
<td>{$A["dept"]}</td>" . " <td>{$A["manager"]}</td>" .
"<td>{$A["extension"]}</td></tr>\n";
} else {
print "<tr bgcolor=#CCFFCC><td>{$A["fname"]}</td>" .
"<td>{$A["lname"]}</td>" . "<td>{$A["dept"]}</td>" .= "
<td>{$A["manager"]}</td>" . "<td>{$A["extension"]}</td></tr>\n";
}
print "</div>";
}
... various bits deleted ...
}
If anyone can help me "back convert" this routine into something PHP3 likes, I'd be greatly appreciative! It runs fine in PHP4, so I know the code works (even if it's not the most elegant of examples). I'm not a developer by trade, and I've never used PHP3, so I'm not sure what could be different that's making it go crash. I've checked the FAQ's and searched the annotated documentation, but I must be missing something basic.
thanks;
-rob.
robg@easystreet.com
--
--
Rob Griffiths | 00 Audi A4 2.8 | 00 Ford Explorer | 99 Mazda Miata |
robg@easystreet.com | The Griffiths: A front-wheel-drive-free household! |