Blank fields detection

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
olidenia
Forum Newbie
Posts: 19
Joined: Mon Apr 28, 2008 12:38 pm

Blank fields detection

Post by olidenia »

having some problems with this code:

Code: Select all

<?php
 
$con = mysql_connect("$hostName","$dbName","$dbUserPw");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
 
mysql_select_db("$dbName", $con);
 
{
//This makes sure they did not leave any fields blank
if (!$_POST['firstname']) 
die ('No one here by that name!!');
}
 
$result = mysql_query ("SELECT * FROM Sandbox
WHERE FirstName='$_POST[firstname]'");
 
 
 
while($row = mysql_fetch_array($result))
  {
  echo $row['FirstName'] . " " . $row['LastName'];
  echo "<br />";
  }
?>
I can't get this part to work, I have it on another file and it works fine.

Code: Select all

{
//This makes sure they did not leave any fields blank
if (!$_POST['firstname']) 
die ('No one here by that name!!');
}
Any help?
Thank you
olidenia
Forum Newbie
Posts: 19
Joined: Mon Apr 28, 2008 12:38 pm

Re: Blank fields detection

Post by olidenia »

Sorry, excuse me, this piece of code works perfectly, my fault, I whas expecting it to do something else, hehe.

The beginings of PHP can make you a bit :crazy:
Post Reply