Jump to content

Parse Error on ?>


joecooper

Recommended Posts

<?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...
Link to comment
Share on other sites

<?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.
Link to comment
Share on other sites

[!--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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

The problem is in this line:
[code]<?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>";
?>[/code]

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.

[code]<?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;
?>[/code]

Ken
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.