ahundiak wrote:The error message is being generated because your sql statement has a problem in it.
Try:
$sql = 'Whatever';
$result = mysql_query($sql) or die(mysql_error());
It tells me I have an error in line 1... but line 1 has worked before.
Here is my code.
<?PHP
$username="dfsf";
$password="dfsdfsdfsdfsdf";
$database="sdfsdfsdf";
$databox="www.sdfdsffsdsdfsdf.net";
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."; }
mysql_close();
echo "<b><center>Database Output</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++;
}
//include_once (./regdbsearch.php);
?>