473,508 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP newb needing help.

1 New Member
I need help here, I am trying to learn PHP and MySQL and have run into some trouble. I have written this page to update records in my database, and cannot get the page to load. It just comes up a blank page. All the other paged I have written come up fine. I have fixed all the errors in my error.log, so what am I doing wrong here? The code is:

[PHP]
<html>
<head>
</head>
<body>
<?php

$id='$_GET[id]';
$username="******";
$password="******";
$database="******";

mysql_connect('localhost',$username,$password);

$query="select * from contacts where id='$id'";

$result="mysql_query($query)";
$num="mysql_numrows($result)";
$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");

mysql_close();

?>


<form action="update.php" method="post">
<input type="hidden" name="ud_id" value="<?php echo $id; ?>">
First Name: <input type="text" name="ud_first" value="<?php echo $first; ?>"><br>
Last Name: <input type="text" name="ud_last" value="<?php echo $last; ?>"><br>
Phone Number: <input type="text" name="ud_phone" value="<?php echo $phone; ?>"><br>
Mobile Number: <input type="text" name="ud_mobile" value="<?php echo $mobile; ?>"><br>
Fax Number: <input type="text" name="ud_fax" value="<?php echo $fax; ?>"><br>
E-mail Address: <input type="text" name="ud_email" value="<?php echo $email; ?>"><br>
Web Address: <input type="text" name="ud_web" value="<?php echo $web; ?>"><br>
<input type="Submit" value="Update">

<?php
++$i;
}
?>
</body>
</html>
[/PHP]

Don't laugh too hard, its just thrown together because I am trying to learn. :)
Thanks for any help in advance!
May 6 '07 #1
1 1096
pbmods
5,821 Recognized Expert Expert
This line:

[PHP]
mysql_close();
[/PHP]
gets executed before the loop finishes. Try removing that line or moving it to the end of the file.
May 7 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
2019
by: Alexandre | last post by:
Hi, Im a newb to dev and python... my first sefl assigned mission was to read a pickled file containing a list with DB like data and convert this to MySQL... So i wrote my first module which...
4
1429
by: Donald Newcomb | last post by:
I'm a real Python NEWB and am intrigued by some of Python's features, so I'm starting to write code to do some things to see how it works. So far I really like the lists and dictionaries since I...
6
1669
by: Sean Berry | last post by:
Hello all I have build a list that contains data in the form below -- simplified for question -- myList = ,, ...] I have a function which takes value3 from the lists above and returns...
11
1970
by: The_Kingpin | last post by:
Hi all, I'm new to C programming and looking for some help. I have a homework project to do and could use every tips, advises, code sample and references I can get. Here's what I need to do....
0
7225
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7124
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7326
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7046
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7498
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5053
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3195
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.