Results 1 to 4 of 4

Thread: Table update problem

  1. #1
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default Table update problem

    I am having a problem with this table updating
    The code should take the max id from the user and turn it into a variable though its not letting me do it...
    PHP Code:
    $con mysql_connect("localhost","admin","");
            
                if (!
    $con)
                  {
                  die(
    'Could not connect: ' mysql_error());
                  }
                    
    mysql_select_db("markmon_pureadd_upload"$con);
    $resultmysql_query("SELECT MAX(ID) FROM pictures WHERE user='$user'");//Selects max ID from the specific user specified
    while($row mysql_fetch_array($result)){
        
    mysql_query("UPDATE pictures SET status='102' WHERE ID='$result' AND user='$user'"); 
    Now when I put in a value for id like id=1 it will update the status... but when i have it trying and do it with the variable... it won't...
    Thanks!
    Last edited by Rockonmetal; 04-17-2008 at 09:28 PM. Reason: stupid typos and saw it wasn't in a php box...

  2. #2
    Join Date
    Feb 2008
    Location
    Coventry
    Posts
    103
    Thanks
    5
    Thanked 8 Times in 8 Posts

    Default

    i know its the tedious testing stuff but have you tried echoing out the $result variable. just to see what exactly is in it. iv had problems in the past where iv just had to declare the variable to make sure it is set properly.

    passing the obvious test, try seeing if you can convert it. there is no reason why it shouldn't be going in fine but you never know, it can happen.

    http://www.phpf1.com/tutorial/php-string-to-int.html

    try that, tedious and obvious and you prob deserve more credit, but hey its worth a go if you havent already checked
    The important thing is not to stop questioning. Curiosity has its own reason for existing.

  3. #3
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default

    I get Resource id #3 when I echo it and thats not the max value or the next max value. This is starting to make less and less sense...

  4. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Everything that is not an MySQL command should be ticked, try this:
    Code:
    $con = mysql_connect("localhost","admin","");
            
                if (!$con)
                  {
                  die('Could not connect: ' . mysql_error());
                  }
                    mysql_select_db("markmon_pureadd_upload", $con);
    $result= mysql_query("SELECT MAX(ID) FROM `pictures` WHERE `user`='{$user}'");//Selects max ID from the specific user specified
    while($row = mysql_fetch_array($result)){
        mysql_query("UPDATE `pictures` SET `status`='102' WHERE ID='$result' AND `user`='{$user}'");
    Jeremy | jfein.net

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
  •