jmilane Posted September 25, 2006 Share Posted September 25, 2006 I have been at this for 3 hours... am I missing something obvious???[code]<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>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/21981-fixed-this-is-making-me-nuts-error-near-on-line-1/ Share on other sites More sharing options...
gerkintrigg Posted September 25, 2006 Share Posted September 25, 2006 change <?PHP to <?php(lowercase) sometimes that causes problems Quote Link to comment https://forums.phpfreaks.com/topic/21981-fixed-this-is-making-me-nuts-error-near-on-line-1/#findComment-98171 Share on other sites More sharing options...
jmilane Posted September 25, 2006 Author Share Posted September 25, 2006 [quote author=gerkintrigg link=topic=109413.msg440910#msg440910 date=1159193526]change <?PHP to <?php(lowercase) sometimes that causes problems[/quote]Thanks, but that wasnt it. Quote Link to comment https://forums.phpfreaks.com/topic/21981-fixed-this-is-making-me-nuts-error-near-on-line-1/#findComment-98195 Share on other sites More sharing options...
wildteen88 Posted September 25, 2006 Share Posted September 25, 2006 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 "[i]error near .... on line 1[/i]" is common with errors in SQL queries as the error is comming from the database rather than PHP itself. Quote Link to comment https://forums.phpfreaks.com/topic/21981-fixed-this-is-making-me-nuts-error-near-on-line-1/#findComment-98204 Share on other sites More sharing options...
kenrbnsn Posted September 25, 2006 Share Posted September 25, 2006 [code]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()); ?>[/code]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:[code]<?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;?>[/code]Ken Quote Link to comment https://forums.phpfreaks.com/topic/21981-fixed-this-is-making-me-nuts-error-near-on-line-1/#findComment-98211 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.