clown[NOR] Posted April 10, 2007 Share Posted April 10, 2007 why wont this print out the form? i don't get any errors, just a blank page print("<form action=updated.php method=post>"); print("<input type=hidden name=ud_id value=" . $id . ">"); print("First Name: <input type=text name=ud_first value=" . $first . "><br>"); print("Last Name: <input type=text name=ud_last value=" . $last . "><br>"); print("Phone Number: <input type=text name=ud_phone value=" . $phone . "><br>"); print("Mobile Number: <input type=text name=ud_mobile value=" . $mobile . "><br>"); print("Fax Number: <input type=text name=ud_fax value=" . $fax . "><br>"); print("E-mail Address: <input type=text name=ud_email value=" . $email . "><br>"); print("Web Address: <input type=text name=ud_web value=" . $web . "><br>"); print("<input type=Submit value=Update>"); print("</form>"); i've also tried echo... but nothing... I must be missing something really simple here.. Quote Link to comment Share on other sites More sharing options...
obsidian Posted April 10, 2007 Share Posted April 10, 2007 When you view your source, what do you get? Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 10, 2007 Author Share Posted April 10, 2007 <html> <head><title>Edit Contact</title></head> <body> </body> </html> Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 10, 2007 Author Share Posted April 10, 2007 can it be because I'm running it from my computer? I've installed wamp5.. but maybe there's some settings I need to change? anyone familiar with wamp5? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 10, 2007 Share Posted April 10, 2007 Make sure the error reporting settings are set to display all errors. At the top of your script put <?php error_reporting(E_ALL); ?> Ken Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 10, 2007 Author Share Posted April 10, 2007 thanks... not it showed this message: Notice: Use of undefined constant localhost - assumed 'localhost' in F:\root\edit.php on line 12 $id = $_GET['id']; $user = "root"; $password = "*******"; $database = "adressebok"; mysql_connect(localhost,$user,$password); // This is line 12 @mysql_select_db($database) or die ("Unable to select database"); $query = "SELECT * FROM contacts WHERE id='$id'"; Quote Link to comment Share on other sites More sharing options...
Asheeown Posted April 10, 2007 Share Posted April 10, 2007 print("<form action=updated.php method=post>"); print("<input type=hidden name="ud_id" value=" . $id . ">"); print("First Name: <input type="text" name="ud_first" value=" . $first . "><br>"); print("Last Name: <input type="text" name="ud_last" value=" . $last . "><br>"); print("Phone Number: <input type="text" name="ud_phone" value=" . $phone . "><br>"); print("Mobile Number: <input type="text" name="ud_mobile" value=" . $mobile . "><br>"); print("Fax Number: <input type="text" name="ud_fax" value=" . $fax . "><br>"); print("E-mail Address: <input type="text" name="ud_email" value=" . $email . "><br>"); print("Web Address: <input type="text" name="ud_web" value=" . $web . "><br>"); print("<input type="Submit" value="Update">"); print("</form>"); Try that Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 10, 2007 Author Share Posted April 10, 2007 Fearsoldier? Wouldnt all thos quotes inside the print() mess up the whole thing? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 10, 2007 Share Posted April 10, 2007 localhost needs to be in quotes. That was only a notice, so it wouldn't have caused your problem. Can you post more of your code? Ken Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 10, 2007 Author Share Posted April 10, 2007 this i the whole code <html> <head><title>Edit Contact</title></head> <body> <?php error_reporting(E_ALL); $id = $_GET['id']; $user = "root"; $password = "*****"; $database = "adressebok"; mysql_connect("localhost", $user, $password); @mysql_select_db($database) or die ("Unable to select database"); $query = "SELECT * FROM contacts WHERE id='$id'"; $result = mysql_query($query); $num = mysql_numrows($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"); print("<form action=updated.php method=post>"); print("<input type=hidden name=ud_id value=" . $id . ">"); print("First Name: <input type=text name=ud_first value=" . $first . "><br>"); print("Last Name: <input type=text name=ud_last value=" . $last . "><br>"); print("Phone Number: <input type=text name=ud_phone value=" . $phone . "><br>"); print("Mobile Number: <input type=text name=ud_mobile value=" . $mobile . "><br>"); print("Fax Number: <input type=text name=ud_fax value=" . $fax . "><br>"); print("E-mail Address: <input type=text name=ud_email value=" . $email . "><br>"); print("Web Address: <input type=text name=ud_web value=" . $web . "><br>"); print("<input type=Submit value=Update>"); print("</form>"); $i++; } ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 10, 2007 Share Posted April 10, 2007 You should always check mysql operations for success or failure and don't use the "@" operator when developing code. It will suppress error messages. <?php $query = "SELECT * FROM contacts WHERE id='$id'"; $result = mysql_query($query) or die("Problem with the query <pre>$query</pre><br>" . mysql_error()); ?> You can make your coding task easier by using one of the mysql_fetch functions instead of mysql_result. I prefer the mysql_fetch_assoc() function. Also, you don't have to call mysql_close(). <?php while ($rw = mysql_fetch_assoc($result)) { echo '<form action=updated.php method=post>'; echo '<input type="hidden" name="ud_id" value="' . $_rw['id'] . '">'; echo 'First Name: <input type="text" name="ud_first" value="' . $rw['first'] . '"><br>'; echo 'Last Name: <input type="text" name="ud_last" value="' . $rw['last'] . '"><br>'; echo 'Phone Number: <input type="text" name="ud_phone" value="' . $rw['phone'] . '"><br>'; echo 'Mobile Number: <input type="text" name="ud_mobile" value="' . $rw['mobile'] . '"><br>'; echo 'Fax Number: <input type="text" name="ud_fax" value="' . $rw['fax'] . '"><br>'; echo 'E-mail Address: <input type="text" name="ud_email" value="' . $rw['email'] . '"><br>'; echo 'Web Address: <input type="text" name="ud_web" value="' . $rw['web'] . '"><br>'; echo '<input type="submit" value="Update">'; echo '</form>'; } ?> You will notice that I made a few other changes to your code... Ken Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 10, 2007 Author Share Posted April 10, 2007 ok..thanks... yeah this is my 2nd day working with mysql.. so I'm following a tutorial =) http://www.freewebmasterhelp.com/tutorials/phpmysql/ one more noob question... where is $rw and $_rw set? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 10, 2007 Share Posted April 10, 2007 Sorry the "$rw_" in this line: <?php echo '<input type="hidden" name="ud_id" value="' . $_rw['id'] . '">'; ?> should be "$rw" <?php echo '<input type="hidden" name="ud_id" value="' . $rw['id'] . '">'; ?> The "$rw" array is set in the "while" statement <?php while ($rw = mysql_fetch_assoc($result)) { ?> the mysql_fetch_assoc() function returns an associative array containing all the fields in the row just retrieved. Ken Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 10, 2007 Author Share Posted April 10, 2007 oh ok... thanks =) i'll try it out now Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 10, 2007 Author Share Posted April 10, 2007 i'm sorry to report this, but still the same result... <?php error_reporting(E_ALL); $id = $_GET['id']; $user = "root"; $password = "*****"; $database = "adressebok"; mysql_connect("localhost", $user, $password); mysql_select_db($database) or die ("Unable to select database" . mysql_error()); $query = "SELECT * FROM contacts WHERE id='$id'"; $result = mysql_query($query) or die("Problem with the query <pre>$query</pre><br>" . mysql_error()); $num = mysql_numrows($result); mysql_close(); while ($rw = mysql_fetch_assoc($result)) { echo '<form action=updated.php method=post>'; echo '<input type="hidden" name="ud_id" value="' . $rw['id'] . '">'; echo 'First Name: <input type="text" name="ud_first" value="' . $rw['first'] . '"><br>'; echo 'Last Name: <input type="text" name="ud_last" value="' . $rw['last'] . '"><br>'; echo 'Phone Number: <input type="text" name="ud_phone" value="' . $rw['phone'] . '"><br>'; echo 'Mobile Number: <input type="text" name="ud_mobile" value="' . $rw['mobile'] . '"><br>'; echo 'Fax Number: <input type="text" name="ud_fax" value="' . $rw['fax'] . '"><br>'; echo 'E-mail Address: <input type="text" name="ud_email" value="' . $rw['email'] . '"><br>'; echo 'Web Address: <input type="text" name="ud_web" value="' . $rw['web'] . '"><br>'; echo '<input type="submit" value="Update">'; echo '</form>'; } ?> and there's no error message(s) Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 10, 2007 Share Posted April 10, 2007 Are you sure you have something in the database that will be retrieved? Change your code to: <?php $num = mysql_num_rows($result); if ($num > 0) { echo '<form action=updated.php method=post>'; while ($rw = mysql_fetch_assoc($result)) { echo '<input type="hidden" name="ud_id" value="' . $rw['id'] . '">'; echo 'First Name: <input type="text" name="ud_first" value="' . $rw['first'] . '"><br>'; echo 'Last Name: <input type="text" name="ud_last" value="' . $rw['last'] . '"><br>'; echo 'Phone Number: <input type="text" name="ud_phone" value="' . $rw['phone'] . '"><br>'; echo 'Mobile Number: <input type="text" name="ud_mobile" value="' . $rw['mobile'] . '"><br>'; echo 'Fax Number: <input type="text" name="ud_fax" value="' . $rw['fax'] . '"><br>'; echo 'E-mail Address: <input type="text" name="ud_email" value="' . $rw['email'] . '"><br>'; echo 'Web Address: <input type="text" name="ud_web" value="' . $rw['web'] . '"><br>'; } echo '<input type="submit" value="Update">'; echo '</form>'; } else echo 'No records selected for id = ' . $id . '<br>'; ?> Ken Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 10, 2007 Author Share Posted April 10, 2007 I'm positive =) Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 10, 2007 Author Share Posted April 10, 2007 oh my god!! I feel so super stupid now! how could i know that even when i fysicaly went into the database and deleted the contacts then made 3 new trough the add contact form the ID continued counting.. haha.. the id was 3-4-5 not 0-1-2 as i thought it was thanks for all the help.. it's working fine now =) 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.