Reply to Problem adding records

Your name:

Reply:


Posted by KB on 02/01/08 23:36

Hi, I'm trying to use a PHP script to add a record. It's a very simple table
with three fields: Last Name, First Name and Email Address.

I ran this script and for some reason, the record doesn't get added, but all
the fields do come accross fine. That's why I have the thing at the end
where I displayed the fields. When I look at the table, the fields aren't
there. I don't get an error either.

The connect information has been changed for obvious security reasons. The
connect information does work fine with other programs, where it reads the
database. I think the problem likes in my SQL string.

The variable $result returns a blank.

Here is the code:

<?php

$phpform_lastname = $_POST['form_lastname'];
$phpform_firstname = $_POST['form_firstname'];
$phpform_email = $_POST['form_email'];

//Connect To Database
$hostname="hw329d32s7.securecomputer.com";
$username="joeuser";
$password="Deleb56";
$dbname="joeuser";
$usertable="addresses";

mysql_connect($hostname,$username, $password) OR DIE ("Unable to load the
Test Database! Please try again later.");
mysql_select_db($dbname);

//Make and execute SQL String

$query = "INSERT INTO `addresses` (`last_name`, `first_name`,
`emailaddress`) VALUES ($phpform_lastname, $phpform_firstname,
$phpform_email)";
$result = mysql_query($query);

?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<?php

echo "The Result is: ".$result;

echo "<BR>I just added the record with the following parameters.<BR>";
echo "<BR>";
echo "The Last name is: ".$phpform_lastname."<BR>";
echo "The First name is: ".$phpform_firstname."<BR>";
echo "The Email is: ".$phpform_email."<BR>";

?>

</body>
</html>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация