Results 1 to 4 of 4

Thread: whats wrong? mysql query

  1. #1

    Thread Starter
    Fanatic Member stickman373's Avatar
    Join Date
    Mar 2001
    Location
    MA
    Posts
    909

    whats wrong? mysql query

    PHP Code:
    mysql_query("INSERT INTO warehouse (pname,desc,costmedia,rrp,sname,snumber,saddress,quantity,notes) VALUES ('".$_POST['pname']."','".$_POST['desc']."','".$_POST['costmedia']."','".$_POST['rrp']."','".$_POST['sname']."','".$_POST['snumber']."','".$_POST['saddress']."','".$_POST['quantity']."','".$_POST['notes']."')"); 
    whats wrong with the above query? nothing gets entered into the mysql database, but when I do this query:

    PHP Code:
    mysql_query("INSERT INTO warehouse (pname) VALUES ('".$_POST['pname']."')"); 
    it will enter that small portion of data?

    Help please.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,174

    Re: whats wrong? mysql query

    PHP Code:
    mysql_query("INSERT INTO warehouse (pname,desc,costmedia,rrp,sname,snumber,saddress,quantity,notes) VALUES ('".$_POST['pname']."','".$_POST['desc']."','".$_POST['costmedia']."','".$_POST['rrp']."','".$_POST['sname']."','".$_POST['snumber']."','".$_POST['saddress']."','".$_POST['quantity']."','".$_POST['notes']."')"); 
    Instead of performing the query straight out, try echoing it out and see if it's a proper SQL statement.

    Then try running the result directly or in commandline.

  3. #3
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    It's always a good idea to do this (especially when developing):

    Code:
    mysql_query($sql) or die(mysql_error())
    That will display a MySQL error (different from a PHP error), if there is one.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Was it you who posted at GT too? A very similar question there had the same problem: that "desc" is a reserved word.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

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



Click Here to Expand Forum to Full Width