Hi all
I can't get this script to work whatever I do?
I don't get any errors, but nothing seem to be input into the DB.
<html>
<head>
</head>
<title>Address Book</title>
<body>
<?php
$user="root";
$host="localhost";
$password="twister";
$databasename="mss";
$connection=mysql_connect($host,$user,$password)
or die (mysql_error());
$database=mysql_select_db($databasename,$connection)
or die (mysql_error());
echo "You're connected to the Address Book.<br><br><hr><br>";
$query = "SELECT * FROM addressbook";
$result = mysql_query($query)
or die ("not working");
$num=mysql_numrows($result);
$i=0;
while($i<$num){
$id=mysql_result($result,$i,"id");
$fname=mysql_result($result,$i,"fname");
$sname=mysql_result($result,$i,"sname");
$tel_home=mysql_result($result,$i,"tel_home");
$tel_mobile=mysql_result($result,$i,"tel_mobile");
$date=mysql_result($result,$i,"date");
echo "$id";
echo "$fname";
echo "$fname";
echo "$tel_home";
echo "$tel_mobile";
echo "$date<br>";
++$i;
}
?>
<p>
<p>
<form action="ad.php" method="post">
<input type="text" id="fname" name="fname"> first name<br>
<input type="text" id="sname" name="fname"> surname<br>
<input type="text" id="tel_home"> home tel<br>
<input type="text" id="tel_mobile"> mobile tel<br>
<input type="submit">
</form>
</body>
</html>
<html>
<head>
</head>
<title>Address Book</title>
<body>
<?php
$user="root";
$host="localhost";
$password="twister";
$databasename="mss";
$connection=mysql_connect($host,$user,$password)
or die (mysql_error());
$database=mysql_select_db('mss')
or die (mysql_error());
echo "You're entry has been added to the Address Book.<br><br><hr><br>";
$query = "INSERT INTO addressbook (fname,sname,tel_home,tel_mobile) VALUES ('$fname','$sname','$tel_home','$tel_mobile')";
$result = mysql_query($query)
or die ("not working");
?>
<a href="index.php">Go Back</a>
</body>
</html>
I'm running on:
• OSX 10.2.6
• PHP 4.0.15
• Sql 4.3.3
• YourSQL for my DB admin stuff
Cheers if anyone can help me out.
Kia.