mysql_db_query() is deprecated
Results 1 to 9 of 9

Thread: mysql_db_query() is deprecated

  1. #1
    Junior Member
    Join Date
    May 2011
    Posts
    3

    mysql_db_query() is deprecated

    deprecated codes:

    PHP Code:
    $query "select * from categories where sub_cat_id = $selected ORDER BY `weight`, `name` ASC";
    $result = [COLOR="Red"]mysql_db_query[/COLOR]($dbs["db_name"],$query,$conn) or die ("Error in query: $query.2" mysql_error()); 
    *If I added mysql_select_db() and changed to mysql_query as suggested, Parse error comes out.
    *Warning: mysql_select_db() expects at most 2 parameters, 3 given in ...
    *Error in query: select * from categories where sub_cat_id = 11 ORDER BY `weight`, `name` ASC.2
    ------------------------------------------------
    Note:
    This code is working, only deprecated errors appeared.
    This code used 3 parameters.
    I have no right to access/modify PHP.ini file.

    Hopes some can help me to solve this problem. Thanks in advance.
    Last edited by bradgrafelman; 06-04-2011 at 01:42 PM. Reason: PHP bbcode tags added

  2. #2
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,349
    Welcome to PHPBuilder! When posting PHP code, please use the board's [php]..[/php] bbcode tags as they make your code much easier to read and analyze.

    As for your issue... show us the code you tried when you switched to first selecting the db and then using mysql_query().

  3. #3
    Junior Member
    Join Date
    May 2011
    Posts
    3
    code after modification:

    PHP Code:
    mysql_select_db($dbs["db_name"]);
                        
    $query "select * from categories where sub_cat_id = $selected2 ORDER BY `weight`, `name` ASC";
                        
    $result mysql_query($dbs["db_name"],$query,$conn) or die ("Error in query: $query.2" mysql_error()); 
    The above code produce this error:

    Warning: mysql_query() expects at most 2 parameters, 3 given in ....
    Error in query: select * from categories where sub_cat_id = 13 ORDER BY `weight`, `name` ASC.2

    Please let me know if you need more info.

  4. #4
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,349
    As the error message clearly explains, mysql_query() only "expects at most 2 parameters" yet instead "3 [were] given."

    See the manual to learn how the function is to be used.

  5. #5
    High Energy Magic Dept. NogDog's Avatar
    Join Date
    Aug 2006
    Location
    Ankh-Morpork
    Posts
    13,816
    Hint: you've already selected the database via the mysql_select_db() function.
    Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." ~ from Nation, by Terry Pratchett

    "But the main reason that any programmer learning any new language thinks the new language is SO much better than the old one is because he’s a better programmer now!" ~ http://www.oreillynet.com/ruby/blog/...ck_to_p_1.html


    eBookworm.us

  6. #6
    Junior Member
    Join Date
    May 2011
    Posts
    3
    Thanks for the hint.

    The warning error for mysql_select_db is already resolved.
    The error for $query = "select * from categories ... is haven't resolved yet.

  7. #7
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,349
    Quote Originally Posted by ruswady View Post
    The error for $query = "select * from categories ... is haven't resolved yet.
    There is no error on that line. The error is on the next line where you attempt to call mysql_query().

    Read the error message, and then read my post above, and then read the manual for mysql_query().

  8. #8
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Systems Vehicle "Thrilled To Be Here"
    Posts
    21,771
    As bradgrafelman said. Also,
    Quote Originally Posted by ruswady
    Please let me know if you need more info.
    The rest of the error message that starts
    Code:
    Error in query: select * from categories where sub_cat_id = 13 ORDER BY `weight`, `name` ASC.2
    probably explains the error.
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

  9. #9
    High Energy Magic Dept. NogDog's Avatar
    Join Date
    Aug 2006
    Location
    Ankh-Morpork
    Posts
    13,816
    Before things get too confusing here, this command...
    PHP Code:
    $result mysql_query($dbs["db_name"],$query,$conn
    ...should instead be...
    PHP Code:
    $result mysql_query($query$conn
    (There is no "database" parameter for the mysql_query() function, just the query and the (optional) DB connection resource.
    Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." ~ from Nation, by Terry Pratchett

    "But the main reason that any programmer learning any new language thinks the new language is SO much better than the old one is because he’s a better programmer now!" ~ http://www.oreillynet.com/ruby/blog/...ck_to_p_1.html


    eBookworm.us

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
  •