The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 3 of 3

Thread: Is my update syntax correct in my php code?

  1. #1

    Is my update syntax correct in my php code?

    I can't believe I'm having such a hard time with this but, I'm trying to update code in my database using php here is the code. I don't see any issues, I mean I have a php mysql book in front of me and it looks correct:

    PHP Code:
    $sql "UPDATE info SET firstname='$fn' WHERE user_id='$user'";
    $Result2 mysql_query($sql$dbConnect) or die('Error updating database. Error L1.'); 
    What could be the fricking problem! I've wasted so much time on this simple piece of code.

    I'm connecting fine because before this line I'm doing a select statement which works. I'm using the same mysql_select_db().

    I've also printed out the values for $fn and $user and they both have data.


    Thanks
    ---------------------------------------
    FlashNewby
    "Not really a newby just thought the name was cool ...."

  2. #2
    PHP Code:
    <?php
    $host
    ="yuor host name";
    $dbuser="your db user";
    $pass="your pass";
    $datbase="your db";
    $fn=$_GET['fn'];//form submitted var
    $user=$_GET['user'];//form submitted var
    $conn=mysql_connect($host$dbuser$pass) or die("no connect to database server"); 

    mysql_select_db($database);

    $query="UPDATE info SET firstname='$fn' WHERE user_id='$user'";

    mysql_query($query) or die('Error updating database. Error L1.');

    mysql_close($conn);
    ?>

  3. #3
    I've got all the connection info and I'm connecting but when I check mysql_affected_rows() function it returns 0 which means no rows were updated.
    I also check the database and notice that the row is not getting updated.

    Any other ideas??
    ---------------------------------------
    FlashNewby
    "Not really a newby just thought the name was cool ...."

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
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012