Hello:

I am just starting to learn php and have been reading tutorials that I 
have found on the Internet.

The one I am reading now is:

http://www.freewebmasterhelp.com/tutorials/phpmysql/1

The problem I am having is with these two scripts.

Script 1:

(This script displays some forms to type in Contact information.)

<form action="insert.php" method="post">
First Name: <input type="text" name="first"><br>
Last Name: <input type="text" name="last"><br>
Phone: <input type="text" name="phone"><br>
Mobile: <input type="text" name="mobile"><br>
Fax: <input type="text" name="fax"><br>
E-mail: <input type="text" name="email"><br>
Web: <input type="text" name="web"><br>
<input type="Submit">
</form>

Script 2:

(This script (saved as insert.php) is called by Script 1 after 
information has been typed into the above form.)

<?
$username="localuser";
$password="unknown";
$database="Contacts";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM Contacts";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();

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;
}

?>

I have created the database Contacts.  It is a MySQL database.  I open 
the first script and enter my contact data, press Submit, and I believe 
the second script is then called.

I go and check my Contacts database and a new record has been added, but 
it is empty.  I am guessing that the values assigned in the first script 
are not being seen by the second script and that the empty variables are 
being written to the database.

Is there something that has to be done to php so that it sees these 
variables?  Is this an operating system issue?  Anything else I should be 
looking at?

Other data:

Server Machine: Sun Sparc 20 with Solaris 2.6, Apache 2.0.49, MySQL 
4.0.17, PHP 4.3.7.
Remote Machine: Homebuilt running MS Windows 2000, Mozilla Firebird 0.7 
browser

If there is a better list for beginner questions, please let me know.

Thanks.

-- 
Frank Hahn

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to