Krunk Posted June 27, 2007 Share Posted June 27, 2007 Hi all, I cannot understand why the form does not show up in the browser. The connection works fine in the select and output scripts but this one is stubborn. when I comment out the php tags, the form shows. I've commented out and rearranged in every way that I can think of. When it works, the values from the table are supposed to appear in the textboxes so that when you change them the form calls updated.php to do the work. I can post updated.php if you need me to. Thanks in advance. <? include("dbinfo.inc.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM contacts WHERE id='$id'"; $result=mysql_query($query); $num=mysql_num_rows($result); mysql_close(); $i=0; while ($i < $num) { $first=mysql_result($result,$i,"first"); $last=mysql_result($result,$i,"last"); $phone=mysql_result($result,$i,"phone"); $mobile=mysql_result($result,$i,"mobile"); $fax=mysql_result($result,$i,"fax"); $email=mysql_result($result,$i,"email"); $web=mysql_result($result,$i,"web"); ?> <form action="updated.php"> <input type="hidden" name="ud_id" value="<? echo "$id"; ?>"> First Name: <input type="text" name="ud_first" value="<? echo "$first"?>"><br> Last Name: <input type="text" name="ud_last" value="<? echo "$last"?>"><br> Phone Number: <input type="text" name="ud_phone" value="<? echo "$phone"?>"><br> Mobile Number: <input type="text" name="ud_mobile" value="<? echo "$mobile"?>"><br> Fax Number: <input type="text" name="ud_fax" value="<? echo "$fax"?>"><br> E-mail Address: <input type="text" name="ud_email" value="<? echo "$email"?>"><br> Web Address: <input type="text" name="ud_web" value="<? echo "$web"?>"><br> <input type="Submit" value="Update"> </form> <? ++$i; } ?> Quote Link to comment Share on other sites More sharing options...
king arthur Posted June 27, 2007 Share Posted June 27, 2007 $id does not appear to be defined, therefore your mysql query will return zero rows, therefore your while loop will never execute. Quote Link to comment Share on other sites More sharing options...
Krunk Posted June 27, 2007 Author Share Posted June 27, 2007 King, Oh sorry about that. It's in the table as an auto_increment primary key. Should I still define it? Possibly with $_POST['id'] somewhere in the script? or $id =$_POST['id']; in the html. Thanks for the reply. Let me go try that. Here is the output script (which works fine)where I've used all the post variables, but I've also used them in the update.php file and it still comes back blank. <? $user="root"; $password="farscape1"; $database="test"; //values taken from form.html $first=$_POST['first']; $last=$_POST['last']; $phone=$_POST['phone']; $mobile=$_POST['mobile']; $fax=$_POST['fax']; $email=$_POST['email']; $web=$_POST['web']; mysql_connect("192.168.2.6",$user,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM contacts"; $result=mysql_query($query); $num=mysql_numrows($result); echo "<b><center>Database Output</center></b><br><br>"; $i=0; while ($i < $num) { $first=mysql_result($result,$i,"first"); $last=mysql_result($result,$i,"last"); $phone=mysql_result($result,$i,"phone"); $mobile=mysql_result($result,$i,"mobile"); $fax=mysql_result($result,$i,"fax"); $email=mysql_result($result,$i,"email"); $web=mysql_result($result,$i,"web"); echo "<b>$first $last</b><br>Phone: $phone<br>Mobile: $mobile<br>Fax: $fax<br>E-mail: $email<br>Web: $web<br><hr><br>"; $i++; } ?> Quote Link to comment Share on other sites More sharing options...
Krunk Posted June 27, 2007 Author Share Posted June 27, 2007 The form is still not showing. When I comment out all the php it shows. Quote Link to comment 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.