Results 1 to 4 of 4

Thread: PHP/MYQSL brings back wrong value (resource ID #3)

  1. #1
    Join Date
    Apr 2007
    Posts
    32
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default PHP/MYQSL brings back wrong value (resource ID #3)

    HI,

    I'm trying to get the highest number from a table, but it brings back "resource ID #3". I have no idea where that comes from, because there is no resource id #3 or even 3 colums. Here is my code
    PHP Code:
    mysql_select_db("mvy_fomcreds") or die(mysql_error());
    $data mysql_query("SELECT annon FROM `annon` ORDER BY `annon` DESC LIMIT 1")
    or die(
    mysql_error());
    $new $annon $data;
    mysql_select_db("mvy_fomcreds") or die(mysql_error());
    mysql_query("INSERT INTO `annon` (`annon`) VALUES ('$new');
    "
    );
    Print 
    "Thank you for your submission.";
    echo 
    "$data";
    ?> 
    Thanks,
    Josh

  2. #2
    Join Date
    Jul 2008
    Posts
    199
    Thanks
    6
    Thanked 58 Times in 57 Posts

    Default

    You cannot echo your raw query. You must first grab the information it is returning with a function such as mysql_fetch_array()

  3. The Following User Says Thank You to techietim For This Useful Post:

    izzysanime (09-26-2008)

  4. #3
    Join Date
    Apr 2007
    Posts
    32
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    OK, i still get the same response. Is this what you meant?

    PHP Code:
    mysql_select_db("mvy_fomcreds") or die(mysql_error());
    $data mysql_query("SELECT annon FROM `annon` ORDER BY `annon` DESC LIMIT 1")
    or die(
    mysql_error());
    $new $annon $info['annon'];
    mysql_select_db("mvy_fomcreds") or die(mysql_error());
    mysql_query("INSERT INTO `annon` (`annon`) VALUES ('$new');
    "
    );
    Print 
    "Thank you for your submission.";

    while(
    $info mysql_fetch_array$data ))
    {
    echo 
    "</head>
    <body>"
    ;

    Print 
    $info['annon'] ;


    ?> 

  5. #4
    Join Date
    Apr 2007
    Posts
    32
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Hmm, got it working. not really sure where it got #3, I just renamed a few things and it works.

    PHP Code:
    mysql_select_db("mvy_fomcreds") or die(mysql_error());
    $data mysql_query("SELECT * FROM `annon` ORDER BY `annonCount` DESC LIMIT 1")
    or die(
    mysql_error());


    Print 
    "Thank you for your submission.";

    while(
    $info mysql_fetch_array$data ))
    {

    echo 
    "</head>
    <body> <br />"
    ;
    $new $info['annonCount'];

    Print 
    $new ;

    mysql_select_db("mvy_fomcreds") or die(mysql_error());
    mysql_query("INSERT INTO `annon` (`annonCount`) VALUES ('$new')")
    or die(
    mysql_error());
    ?> 

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
  •