Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Yaz
    Yaz is offline
    Junior Member
    Join Date
    Jul 2003
    Location
    Toronto
    Posts
    21
    Member #
    2327
    I have a problem with a query. I narrowed it down to this, I know everyhting else is fine because I've done it before. This SQL statement its comming back NULL when I do a var_dump.

    Here is the situation, I have a form that its going to be submited. i have a variable that i passed through URL by:

    PHP Code:
    $id $_GET['var_id']; 
    Then I make a query to insert the info from the form into the DB.

    PHP Code:
    $query "INSERT INTO tbl_whatever SET
    name='
    $_POST[name],
    text='
    $_POST[text]
    WHERE column_id = '
    $id'";

    $result mysql_query($query); 
    ..:: Yaz ::..

  2.  

  3. #2
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Always use quotes around array key names in PHP, although that shouldn't be the problem here.

    As an INSERT statement, it's natural for it to return null, I'd imagine. Use the other MySQL functions such as (IIRC) mysql_affected_rows() to find out what happened.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  4. #3
    Yaz
    Yaz is offline
    Junior Member
    Join Date
    Jul 2003
    Location
    Toronto
    Posts
    21
    Member #
    2327
    thanks... got it working..
    ..:: Yaz ::..

  5. #4
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Just for anyone who does a search on this.... the correct syntax of an insert statement is like so:
    PHP Code:
    $query "INSERT INTO tbl_whatever (id, name, text)
              VALUES (
    $id, '$name', '$text');"


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 03:07 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com