Forum Moderators: coopster
$connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>");
mysql_select_db($dbname);
$sql = "select * from 'tablename' where id=". $_POST['Name'] . $_POST['Address'] . $_POST['SS#'] . $_POST['Birthday'] . $_POST['Birth_place'] . $_POST['comments'];
echo $sql;
$query = mysql_query($sql);
while($row = mysql_fetch_array($query, MYSQL_ASSOC))
{
echo "<p>",$row['Name'],":",
$row['Address'],
$row['SS#'],
$row['Birthday'],
$row['Birth_Place'],
$row['Comments'] ;
}
?>
Here is my form:
<form action="page5.php" method="post">
<P><STRONG>PLEASE ENTER THE FOLLOWING INFO BELOW::</STRONG></P>
<P><STRONG>Name:</STRONG>
<input type="text" name="Name" size="10"><br>
</P>
<P><STRONG>Address:</STRONG>
<input type="text" name="Address" size="10"><br>
</P>
<P><STRONG>SS#:</STRONG>
<input type="text" name="SS#" size="20"><br>
</P>
<P><STRONG>Birthday:</STRONG>
<input type="text" name="Birthday" size="10"><br>
</P>
<P><STRONG>Place Of Birth:</STRONG>
<input type="text" name="Birth_place" size="10"><br>
</P>
<P><STRONG>Comments:</STRONG>
<TEXTAREA NAME = "comments" ROWS = "4" cols = "20"></TEXTAREA>
</P>
<input type="submit" value="Submit" name="Submit">
<input type="submit" value="Show All Records" name="Show All Records">
</form>
I'm very new to this and can use any advise, thanks a lot
I`m guessing that this is your problem.
$sql = "select * from 'tablename' where id=". $_POST['Name'] . $_POST['Address'] . $_POST['SS#'] . $_POST['Birthday'] . $_POST['Birth_place'] . $_POST['comments'];
Try changing it to (note the use of single and double quotes):
$sql = "select * from tablename where id='". $_POST['Name'] . $_POST['Address'] . $_POST['SS#'] . $_POST['Birthday'] . $_POST['Birth_place'] . $_POST['comments']. "';
also, you should use mysql_error() to give you the specific error message.
Change:
$query = mysql_query($sql);
to:
$query = mysql_query($sql) or die(mysql_error());
Hope that helps.
$query = "SELECT * FROM `tablename`...
Your query should always use single quotes when comparing data.
$query = "SELECT * FROM `tablename` WHERE foo = '$boo'....
Unfortunately I have never used Dreamweaver, so maybe someone else can give you insight into the colours. I`m colour blind anyway. :)