Jump to content


Photo

Parse Error on ?>


  • Please log in to reply
9 replies to this topic

#1 joecooper

joecooper
  • Members
  • PipPipPip
  • Advanced Member
  • 358 posts

Posted 27 February 2006 - 01:46 PM

<?php
Require("db.php");
$username = $_POST['s_name'];
$h_from = $_POST['h_from'];
$h_to = $_POST['h_to'];
$hop = $_POST['s_radio'];
$map1 = $_POST['s_map1'];
$map2 = $_POST['s_map2'];
$map3 = $_POST['s_map3'];
$nomap = "No Map";
$honor = "> $h_from < $h_to";
//if a username wasnt entered, then search all the other crap
if ($username == ''){
$sql = "SELECT * FROM AAForm WHERE Favourite_map_1 IN ('$map1', '$map2', '$map3') AND Favourite_map_2 IN ('$map1', '$map2', '$map3') AND Favourite_map_3 IN ('$map1', '$map2', '$map3') ORDER BY Honor_Level ASC";
$query=mysql_query($sql);
// show the collected data
// a table showing results
echo "Here are the results matching your request:<br>";
echo "<table border='.1'><tr><td><b>Username</b></td><td><b>Honour Level</b></td><td><b>Map 1</b></td><td><b>Map 2</b></td><td><b>Map 3</b></td></tr>";

}
while ($row=mysql_fetch_array($query)){
echo "<tr><td>{$row['AA_Username']}</td><td>{$row['Honor_Level']}</td><td>{$row['Favourite_Map_1']}</td><td>{$row['Favourite_Map_1']}</td><td>{$row['Favourite_Map_1]}</td></tr>";
}
echo "</table>";
?>

i cannot under stand why im getting "Parse error: parse error, unexpected $ in /home/essexrac/public_html/joe/other/search.php on line 26"
line 26 is the ?>
ive changed it around many many times, and checked to see if all the { and } were in right places and all the ; are on ends of lines...
Signature:
[/a]
[a href="http://www.planet-so...=1999&lngWId=8" target="_blank"]EzLogin 1.0[/a]
[a href="http://www.essexracers.com" target="_blank"]Essexracers.com[/a]
Msn Messenger: joe@joeyjoe.co.uk

#2 glenelkins

glenelkins
  • Members
  • PipPipPip
  • Advanced Member
  • 760 posts
  • LocationBridlington - East Riding of Yorkshire - United Kingdom

Posted 27 February 2006 - 01:50 PM

can you show the db.php code please
http://thewebsolutionprovider.com - A Solution For Everything Web!

#3 joecooper

joecooper
  • Members
  • PipPipPip
  • Advanced Member
  • 358 posts

Posted 27 February 2006 - 01:52 PM

<?php
mysql_real_escape_string($input);
error_reporting(E_ERROR | E_PARSE);

$db_host="--";
$db_name="--";
$db_user="--";
$db_pass="--";

$dbc=mysql_connect($db_host,$db_user,$db_pass) OR DIE (mysql_error());
$dbs=mysql_select_db($db_name) OR DIE (mysql_error());
?>

never had a problem with this code.
Signature:
[/a]
[a href="http://www.planet-so...=1999&lngWId=8" target="_blank"]EzLogin 1.0[/a]
[a href="http://www.essexracers.com" target="_blank"]Essexracers.com[/a]
Msn Messenger: joe@joeyjoe.co.uk

#4 glenelkins

glenelkins
  • Members
  • PipPipPip
  • Advanced Member
  • 760 posts
  • LocationBridlington - East Riding of Yorkshire - United Kingdom

Posted 27 February 2006 - 02:05 PM

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]if ($username == '')[/quote]

Try changing this line ^ to: if ($username == "")

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]$honor = "> $h_from < $h_to";[/quote]

and this line ^ to: $honor = "> " . $h_from . " < " . $h_to;


let me know if it works
http://thewebsolutionprovider.com - A Solution For Everything Web!

#5 joecooper

joecooper
  • Members
  • PipPipPip
  • Advanced Member
  • 358 posts

Posted 27 February 2006 - 02:10 PM

made no diffrence :(.


Parse error: parse error, unexpected $ in /home/essexrac/public_html/joe/other/search.php on line 26

with db.php, i have it linked to another server, but that server is a bit messed up, it dont work proply. when i load the server from my IE, it crashes it... could that be the problem?
www.think-gaming.com
Signature:
[/a]
[a href="http://www.planet-so...=1999&lngWId=8" target="_blank"]EzLogin 1.0[/a]
[a href="http://www.essexracers.com" target="_blank"]Essexracers.com[/a]
Msn Messenger: joe@joeyjoe.co.uk

#6 glenelkins

glenelkins
  • Members
  • PipPipPip
  • Advanced Member
  • 760 posts
  • LocationBridlington - East Riding of Yorkshire - United Kingdom

Posted 27 February 2006 - 02:14 PM

i doubt it. a parse error usually happens if you misspell something, or miss something out for example: you could miss out $, ;, "" anything

To be honest i think your coding is all messed up. there is no structure to it. you should just re-write it or i could do it for a small fee for you and get the whole thing working
http://thewebsolutionprovider.com - A Solution For Everything Web!

#7 joecooper

joecooper
  • Members
  • PipPipPip
  • Advanced Member
  • 358 posts

Posted 27 February 2006 - 02:16 PM

ive kinda narrowed it down..

while ($row=mysql_fetch_array($query)){
echo "<tr><td>{$row['AA_Username']}</td><td>{$row['Honor_Level']}</td><td>{$row['Favourite_Map_1']}</td><td>{$row['Favourite_Map_1']}</td><td>{$row['Favourite_Map_1]}</td></tr>";
}
echo "</table>";

doesnt like that
Signature:
[/a]
[a href="http://www.planet-so...=1999&lngWId=8" target="_blank"]EzLogin 1.0[/a]
[a href="http://www.essexracers.com" target="_blank"]Essexracers.com[/a]
Msn Messenger: joe@joeyjoe.co.uk

#8 joecooper

joecooper
  • Members
  • PipPipPip
  • Advanced Member
  • 358 posts

Posted 27 February 2006 - 02:29 PM

thanks for your help
Signature:
[/a]
[a href="http://www.planet-so...=1999&lngWId=8" target="_blank"]EzLogin 1.0[/a]
[a href="http://www.essexracers.com" target="_blank"]Essexracers.com[/a]
Msn Messenger: joe@joeyjoe.co.uk

#9 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 27 February 2006 - 02:33 PM

The problem is in this line:
<?php
echo "<tr><td>{$row['AA_Username']}</td><td>{$row['Honor_Level']}</td><td>{$row['Favourite_Map_1']}</td><td>{$row['Favourite_Map_1']}</td><td>{$row['Favourite_Map_1]}</td></tr>";
?>

You are missing a single quote at the end of the second "Favorite_map_1".

I think it's much better to break up long lines like this into many shorter lines in PHP. It's much easier to debug and paste into this forum.

<?php
$tmp = "<tr><td>{$row['AA_Username']}</td>";
$tmp .= "<td>{$row['Honor_Level']}</td>";
$tmp .= "<td>{$row['Favourite_Map_1']}</td>";
$tmp .= "<td>{$row['Favourite_Map_1']}</td>";
$tmp . = "<td>{$row['Favourite_Map_1']}</td></tr>"; // added missing single quote
echo $tmp;
?>

Ken

#10 joecooper

joecooper
  • Members
  • PipPipPip
  • Advanced Member
  • 358 posts

Posted 27 February 2006 - 02:46 PM

Ohhhh thanks!!
Signature:
[/a]
[a href="http://www.planet-so...=1999&lngWId=8" target="_blank"]EzLogin 1.0[/a]
[a href="http://www.essexracers.com" target="_blank"]Essexracers.com[/a]
Msn Messenger: joe@joeyjoe.co.uk




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users