Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: Query problem

  1. #1
    New Coder
    Join Date
    Jun 2005
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Query problem

    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".

  • #2
    Regular Coder
    Join Date
    May 2005
    Posts
    563
    Thanks
    0
    Thanked 3 Times in 3 Posts
    have you actually connected to the mysql server and database?

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

  • #3
    New Coder
    Join Date
    Jun 2005
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Query Problem

    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>

  • #4
    Regular Coder
    Join Date
    May 2005
    Posts
    563
    Thanks
    0
    Thanked 3 Times in 3 Posts
    use

    PHP Code:
    $_POST['name'/* instead of */ $name
    $_POST
    ['email'/* instead of */ $email
    $_POST
    ['customerid'/* instead of */ $customerid 

  • #5
    New Coder
    Join Date
    Jun 2005
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #6
    New Coder
    Join Date
    Jun 2005
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Query Problem - never mind

    Duh! Okay, I figured it out. Thanks a lot for your help. Sincerely appreciate it.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •