...

View Full Version : Query problem



Betty
06-11-2005, 01:33 PM
Is there any error in this line from an Ashok Appu book? I keep getting "Query could not be executed"

$query = "INSERT INTO newsmail VALUES('". $name ."','". $email . "','". $customerid . "')";

It is from pg. 222 of "Making Use of PHP" and there is no way to contact the author. I have tried everything I could think of.

The database and table are set in MySQL, all other scripts in this section check out. Register globals are "off".

SeeIT Solutions
06-11-2005, 01:53 PM
have you actually connected to the mysql server and database?

Post some more code because what you have there looks correct.

Betty
06-11-2005, 02:19 PM
Yes, connection confirmed. Here's a little more code. (I did enter the required information into the form)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Newsmail Registration Form</title>
<meta http-equip="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#ffffff" text="000000">
<p>&nbsp;</p>
<form name="newsmailform" method="post" action="addnew.php">
<table width="250" border="0" align="center" cellpadding="3">
<tr>
<td colspan="2" bgcolor="#dddddd">
<div align="center"><b>Enter Newsmail Information</b></div>
</td>
</tr>

<tr bgcolor="#eeeeee">
<td width="100" bgcolor="#eeeeee">
<div align="right">Name</div>
</td>
<td width="150">
<input type="text" name="name">
</td>
</tr>

<tr bgcolor="#eeeeee">
<td width="100" bgcolor="#eeeeee">
<div align="right">E-mail</div>
</td>
<td width="150">
<input type="text" name="email">
</td>
</tr>

<tr bgcolor="#eeeeee">
<td width="100" bgcolor="#eeeeee">
<div align="right">CustomerID</div>
</td>
<td width="150">
<input type="text" name="customerid">
</td>
</tr>

<tr>
<td colspan="2" bgcolor="#dddddd">
<div align="center">
<input type="submit" name="Submit" value="Submit">
</div>
</td>
</tr>

</table>
</form>

</body>

</html>

SeeIT Solutions
06-11-2005, 02:26 PM
use


$_POST['name'] /* instead of */ $name
$_POST['email'] /* instead of */ $email
$_POST['customerid'] /* instead of */ $customerid

Betty
06-11-2005, 02:52 PM
Changed to this:
$query = "INSERT INTO newsmail VALUES('".$_POST['name'] ."','". $_POST['email'] . "','". $_POST['customerid'] . "')";

The values are entered into the the database but the report table that is outputted is blank ?? the values are not there.

Betty
06-11-2005, 03:04 PM
Duh! Okay, I figured it out. Thanks a lot for your help. Sincerely appreciate it.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum