Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6925299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:46:18+00:00 2026-05-27T10:46:18+00:00

Possible Duplicate: php warning mysql_fetch_assoc I have tried my code and it seems to

  • 0

Possible Duplicate:
php warning mysql_fetch_assoc

I have tried my code and it seems to be working but it is throwing errors.

I’m in a LAMP environment, this is my code.

    <?php
    mysql_select_db($database_conn1, $conn1);

    //DROPING VIEW
    $query_rsDropView = "DROP VIEW attorneyOrder;";
    echo $query_rsDropView . "/////";  //this code outputs nothing, not even the "/////" part.
    $rsDropView = mysql_query($query_rsDropView, $conn1) or die(mysql_error());
    echo $rsDropView . "/////";     //output the value "1" (witout quotes)
    $row_rsDropView = mysql_fetch_assoc($rsDropView);      //line 222
    $totalRows_rsDropView = mysql_num_rows($rsDropView);   //line 223

    //CREATING VIEW
    $query_rsView = "CREATE VIEW attorneyOrder AS SELECT * FROM LewisJohsAttorneys ORDER BY lname ASC;";
    $rsView = mysql_query($query_rsView, $conn1) or die(mysql_error());
    echo $rsView . "/////";     //outputs the value "1" (without quotes)
    $row_rsView = mysql_fetch_assoc($rsView);      //line 228
    $totalRows_rsView = mysql_num_rows($rsView);   //line 229

    //GETTING VALUES FOR SELECT ON VIEW
    $urlStart_rsName = "NULL";
    if (isset($_GET['start'])) {
         $urlStart_rsName = $_GET['start'];
    }
    $urlEnd_rsName = "NULL";
    if (isset($_GET['end'])) {
         $urlEnd_rsName = $_GET['end'];
    }

    //SELECTING DATA FROM VIEW
    $query_rsName = sprintf("SELECT * FROM attorneyOrder WHERE attorneyOrder.lname BETWEEN %s AND %s;", GetSQLValueString($urlStart_rsName, "text"),GetSQLValueString($urlEnd_rsName, "text"));
    $rsSearch = mysql_query($query_rsName, $conn1) or die(mysql_error());
    echo $rsSearch . "/////";  //outputs a resouce id
    $totalRows_rsName = mysql_num_rows($rsName);    //line 249

    //OUTPUTING DATA
    while($rsSearch = mysql_fetch_assoc($rsSearch)){   //line 262
    //do some stuff here
    }

    ?>

The errors I’m getting are:

    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /var/www/lewisjohs.com/attorneys-search.php on line 222

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/lewisjohs.com/attorneys-search.php on line 223

    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /var/www/lewisjohs.com/attorneys-search.php on line 228

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/lewisjohs.com/attorneys-search.php on line 229

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/lewisjohs.com/attorneys-search.php on line 249

    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /var/www/lewisjohs.com/attorneys-search.php on line 262

I’m assuming its all stemming from the same problem and that is why each successive query is returning an invalid value since they all build off of the prior ones output.

But, I’m still getting the correct output. I could just suppress the errors but I want to know why these errors are coming up. After searching online a common cause was not specifying the database, but that’s the first thing I’m doing with this line [code]mysql_select_db($database_conn1, $conn1);[/code]

I tried outputing the return result of the queries and commented their output in the code. It seems they are appropriately returning either as “1” or true, or a resource id.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:46:18+00:00Added an answer on May 27, 2026 at 10:46 am

    Your errors are there for a reason. You don’t need to suppress them but to fix them.

    mysql_fetch_assoc() function is used when selecting something from the database. In this case array of selected rows is returned which are fetched with this function.
    Your error on line 222 and 228 is there because CREATE VIEW OR DROP VIEW is not a select query, and it is totally unnecessary there.
    The same goes for mysql_num_rows() on lines 223, 229. This function is also used only for SELECT queries.
    Error on line 249 is there because variable $rsName does not exist in your script. This should be mysql_num_rows($rsSearch); In case you are doing SELECT, SHOW, DESCRIBE, EXPLAIN queries with mysql_query function will return ResultSet if it passed ok or FALSE if it failed. You can fetch Resultset with mysql_fetch_assoc() and loop through it. But if no rows exists for that query then mysql_query will return false which cannot be passed to mysql_fetch_assoc()

    This is how it should be written:

    <?php
    mysql_select_db($database_conn1, $conn1);
    
    //DROPING VIEW
    $q_drop = "DROP VIEW attorneyOrder;";
    echo $q_drop. "/////"; // prints out string stored in $q
    $rsDropView = mysql_query($q_drop, $conn1) or die(mysql_error());
    echo $rsDropView . "/////";     // prints TRUE (1) if mysql_query() went well or FALSE(0) if it failed
    
    //CREATING VIEW
    $q_view = "CREATE VIEW attorneyOrder AS SELECT * FROM LewisJohsAttorneys ORDER BY lname ASC;";
    $rsView = mysql_query($q_view, $conn1) or die(mysql_error());
    echo $rsView . "/////";     // prints TRUE (1) if mysql_query() went well or FALSE(0) if it failed
    
    
    //GETTING VALUES FOR SELECT ON VIEW
    $urlStart_rsName = "NULL";
    if (isset($_GET['start'])) {
         $urlStart_rsName = $_GET['start'];
    }
    $urlEnd_rsName = "NULL";
    if (isset($_GET['end'])) {
         $urlEnd_rsName = $_GET['end'];
    }
    
    //SELECTING DATA FROM VIEW
    $query_rsName = sprintf("SELECT * FROM attorneyOrder WHERE attorneyOrder.lname BETWEEN %s AND %s;", GetSQLValueString($urlStart_rsName, "text"),GetSQLValueString($urlEnd_rsName, "text"));
    $rsSearch = mysql_query($query_rsName, $conn1) or die(mysql_error());
    echo $rsSearch . "/////";  //outputs a resouce id
    $totalRows_rsName = mysql_num_rows($rsSearch);    //line 249
    
    //OUTPUTING DATA
    if($totalRows_rsName>0){
        while($rsSearch = mysql_fetch_assoc($rsSearch)){   //line 262
            //do some stuff here
        }
    }
    
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: php warning mysql_fetch_assoc I have a weird problem about my script. It
Possible Duplicate: php headers already sent error I have attached my code which am
Possible Duplicate: php warning mysql_fetch_assoc i am just implementing a simple part of my
Possible Duplicate: php multi-dimensional array remove duplicate I have an array like this: $a
Possible Duplicate: PHP Regular express to remove <h1> tags (and their content) I have
Possible Duplicate: PHP: Date larger than current date I have my dates in this
Possible Duplicate: PHP UML Generator I am trying to understand some php code that
Possible Duplicate: php date compare I have a date that I take from the
Possible Duplicate: PHP Sort a multidimensional array by element containing date I have some
Possible Duplicate: php scandir --> search for files/directories I have a folder, inside this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.