www.webdeveloper.com
Results 1 to 2 of 2

Thread: Can't get php update to work for mysql

Threaded View

  1. #1
    Join Date
    Jan 2010
    Posts
    23

    Can't get php update to work for mysql

    First, I am a beginner with php and mysql. I'm testing out a script to update the value in a column. This script keeps throwing the error "Query was empty". I'm trying to put the $activationNumber value into a column called activation1 for the row where the value in the serial column matches the $serialNumber value.

    I double checked and there is a row in the table with the $serialNumber value in the serial column. There is also a column called activation1.

    Code:
    <?php
    $serialNumber = 'TEST-1234-TEST-6789';
    $activationNumber = 'TEST123';
    $con = mysql_connect("localhost","unsername","password");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    
    mysql_select_db("my_db", $con);
    
    $query = "UPDATE my_table SET activation1 = '$activationNumber', WHERE serial = '$serialNumber'";
    
    if (!mysql_query($sql,$con))
      {
      die('Error: ' . mysql_error());
      }
    echo "Activation Added to Database";
    
    mysql_close($con);
    ?>
    Last edited by ddbell; 12-18-2012 at 05:43 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles