Gossamer Forum
Home : General : Internet Technologies :

New problems arise

Quote Reply
New problems arise
In my previous problem i got rid of arrays to store the data in my database and used the global $_post functoin. This solved the problem of inserting data into my database but revealed a whole new problem. Now i can seem to retieve the data.



Here is the code that handles the data and sends it into the database.

$Firstname = $_POST['Firstname'];
$Lastname = $_POST['Lastname'];
$Emailaddress = $_POST['Emailaddress'];
$Comments = $_POST['Comments'];

$Query = "INSERT into $stuff SET ('0', '$Firstname', '$Lastname', '$Emailaddress', '$Comments)";

print ("$Comments");
print ("The query is:<BR>$Query<p>\n");

if (mysql_db_query ($dbname, $Query, $Link)) {
print ("Your information has been updated =;0)<BR>\n");
} else {
print ("Your information has not been updated<BR>\n");
}
mysql_close ($Link);
?>

And here is the retireve one

$Query = "Select * from $stuff";
$Result = mysql_db_query ($dbname, $Query, $Link);

//Fetch results from datbase

if ($result){
echo "<table border=1>";
echo "<tr><td><b>First Name</b></td><td><b>LastName</b></td><td> <b>Email Address</b></td><td><b>comments</b></td></tr>";

$numOfRows = mysql_num_rows ($result);
for ($i = 0; $i < $numOfRows; $i++){
$Firstname = mysql_result ($result, $i, "Firstname");
$Lastname = mysql_result ($result, $i, "Lastname");
$Emailaddress = mysql_result ($result, $i, "Emailaddress");
$Comments = mysql_result ($result, $i, "Comments");
echo "<tr><td>$Firstname</td><td>$Lastname</td><td>$Emailaddress</td><td>$Comments</td></tr>";
}

echo "</table>";
}
else{
echo mysql_errno().": ".mysql_error()."<BR>";
}


i'm a bit of a noob and have been trying out different scripts to get it working, any ideas?
Subject Author Views Date
Post New problems arise Redz^ 2369 May 27, 2003, 9:16 AM