Jump to content


Photo

**fixed** This is making me nuts... error near " on line 1???


  • Please log in to reply
4 replies to this topic

#1 jmilane

jmilane
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 25 September 2006 - 02:08 PM

I have been at this for 3 hours... am I missing something obvious???

<html>
<head>
<title>
ULEM Registration Database Search Form
</title>
<body>

<?PHP

$username="ghf";
$password="gfghgfh";
$database="ghgfh";
$databox="www.ghfhgfh.org";

mysql_connect($databox,$username,$password);

@mysql_select_db($database) or die("Unable to select database");

if (isset($_POST['regid'])) {
$regid = $_POST['regid'];
$query = "select employmentprog, businessprog, certprog, youthprog, parentprog, policyprog, firstname, middlename, lastname, birthdate, street, city, state, postalcode, homephone, otherphone, referral, contact, race, otherrace, gender, regdate from registration where id = $regid";
}

if (isset($_POST['lastname'])) {
$ln = $_POST['lastname'];
$query = "select employmentprog, businessprog, certprog, youthprog, parentprog, policyprog, firstname, middlename, lastname, birthdate, street, city, state, postalcode, homephone, otherphone, referral, contact, race, otherrace, gender, regdate from registration where lastname = $ln";
}

$result=mysql_query($query) or die(mysql_error());  

$num=mysql_num_rows($result);

if ($num == 0) {echo "No matching records."; return;}

mysql_close();

echo "<b><center>The results of your search:</center></b><br><br>";

$i=0;
while ($i < $num) {

$firstname=mysql_result($result,$i,"firstname");
$middlename=mysql_result($result,$i,"middlename");
$lastname=mysql_result($result,$i,"lastname");
$homephone=mysql_result($result,$i,"homephone");
$otherphone=mysql_result($result,$i,"otherphone");
$street=mysql_result($result,$i,"street");
$city=mysql_result($result,$i,"city");
$state=mysql_result($result,$i,"state");
$postalcode=mysql_result($result,$i,"postalcode");
$referral=mysql_result($result,$i,"referral");
$race=mysql_result($result,$i,"race");
$otherrace=mysql_result($result,$i,"otherrace");
$contact=mysql_result($result,$i,"contact");
$gender=mysql_result($result,$i,"gender");
$regdate=mysql_result($result,$i,"regdate");

echo "<b>$firstname $lastname</b><br>Phone: $homephone<br>Other Phone: $otherphone<br>Street: $street<br>City: $city<br>Zip: $postalcode<br>Best time to contact $contact<br>Race: $race<br>Other race (if applicable): $otherrace<br>Gender: $gender<br>Registration date: $regdate<br><hr>";

$i++;
}

?>
</html>


#2 gerkintrigg

gerkintrigg
  • Members
  • PipPipPip
  • Magician
  • 828 posts
  • LocationBristol, UK
  • Age:37

Posted 25 September 2006 - 02:12 PM

change <?PHP to <?php

(lowercase) sometimes that causes problems
Neil Trigger - http://www.ghostlypublishing.co.uk - Ghostly Publishing - Children's Fantasy Books

#3 jmilane

jmilane
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 25 September 2006 - 02:24 PM

change <?PHP to <?php

(lowercase) sometimes that causes problems


Thanks, but that wasnt it.

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 25 September 2006 - 02:27 PM

Could you post the full error message(s) here please as it'll help us understand whats going on. I think the error you are getting isnt to do with PHP but to do with MySQL queries. As the "error near .... on line 1" is common with errors in SQL queries as the error is comming from the database rather than PHP itself.

#5 kenrbnsn

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

Posted 25 September 2006 - 02:32 PM

Change this line:
<?php $result=mysql_query($query) or die(mysql_error());  ?>
to
<?php $result=mysql_query($query) or die("Problem with the query: $query<br>" . mysql_error());  ?>
This will tell you if the query has a problem (which is usually the case when you get an error like that)

BTW, it looks like you're getting all the fields from your data base. If this is the case I would write your query as:
<?php
$whr = '';
if (isset($_POST['regid'])) $whr = " where id = '" . mysql_real_escape_string($_POST['regid']) . "'";
if (isset($_POST['lastname'])) $whr = " where ln = '" . mysql_real_escape_string($_POST['lastname']) . "'";
$query = "select * from registration" . $whr;
?>

Ken





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users