SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    sweden
    Posts
    646
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    An Update problem

    I have a page where a code is passed in the url and then this should update my table with the info from the url.

    I've been using this before, but then I had an INSERT instead of the UPDATE, which is what I need now.
    But there is something wrong in my code (like always) and I just can't see it...

    It's supposed to put the $number in the table and set STATUS to 1 and the registration date. It will find the id in the CODE from the url as well.

    So what I will get from the URL is:
    blablabla.com/page.php?number=123&code=xyz

    PHP Code:
    <?php
    error_reporting
    (0); 

    require_once(
    'Connections/connection_stuff.php');

     
    $number $_REQUEST["number"];
     
    $code = @urldecode($_REQUEST["code"]);
     
     
    sqlconnect(); 

     
    mysql_query("UPDATE table_user SET number='$number', status=1, reg_date=now(), WHERE code='$code'");
     
     
    mysql_close(); 

    echo 
    "It's working.";
    ?>

  2. #2
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Debug ...
    Change:
    mysql_query("UPDATE table_user SET number='$number', status=1, reg_date=now(), WHERE code='$code'");
    to:
    mysql_query("UPDATE table_user SET number='$number', status=1, reg_date=now(), WHERE code='$code'") or die(mysql_error());

    It probably doesn't like the , between now() and WHERE

  3. #3
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    sweden
    Posts
    646
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I removed the , as well, but it still isn't working.

  4. #4
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    sweden
    Posts
    646
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Found the problem. It was a typo in the connection string :-(


Bookmarks

Posting Permissions

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