daily pastebin goal
27%
SHARE
TWEET

Weird MySQL errors

OldManRiver Apr 10th, 2015 (edited) 242 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. My Enterprise Module code has this method:
  2.  
  3.       function dbArray ( $sql, $connect=NULL ) {
  4.          /***********************************************************************/
  5.          /*  Function: dbQuery()                                                */
  6.          /*   Purpose: Runs the database query string & returns the results or  */
  7.          /*            reports errors.                                          */
  8.          /***********************************************************************/
  9.          $row_ray    =  array();
  10.          $newquery   =  sprintf( "insert into qry_errors (error_desc) values ".
  11.                                  "('%s')", addslashes($sql));
  12.          switch ($this->db_eng) {
  13.             case 'mysql':                       // Process MySQL Engine
  14.                echo "C=> $connect \n";
  15.                $res = mysql_query ( $sql, $connect );
  16.                if ($res == false) {
  17.                   echo "C=> $connect \n";
  18.                   $res = mysql_query ( $newquery, $connect ) or die ( mysql_error () );
  19.                }  // end if $result
  20.                         while ( $row   =  mysql_fetch_assoc ( $res ) ) {
  21.                       $row_ray[]  =  $row;
  22.                    }  // end while $row    
  23.                break;
  24.             case 'pgsql':                       // Process PostGres Engine
  25.                $res     =  pg_query( $sql, $connect );
  26.                if ($res == false) {
  27.                   $res  =  pg_query( $newquery, $connect ) or
  28.                   die("Error: Query failed with query string:<BR>$sql");
  29.                }  // end if $result
  30.                         while ( $row   =  pg_fetch_row ( $res ) ) {
  31.                       $row_ray[]  =  $row;
  32.                    }  // end while $row    
  33.                break;
  34.             //case 'oracle':            // Process Oracle Engine
  35.                //       break;
  36.             //case 'mssql':             // Process MS-SQL Engine
  37.                //       break;
  38.             //case 'sybase':            // Process SyBase Engine
  39.                //       break;
  40.          }     // end switch
  41.          if (dbNRows($res)==0) {
  42.             return 0;
  43.          } else {
  44.             return $row_ray;
  45.          }
  46.          //echo "S=> $this->db_sql <br>";
  47.       }      // end function dbQuery
  48.  
  49. It was working fine but suddenly started giving errors:
  50.  
  51. C=> Resource id #12
  52. PHP Warning:  mysql_query() expects parameter 2 to be resource, string given in /home/path/EM/em_dio/em_dio.php on line 138
  53. C=> Resource id #12
  54. PHP Warning:  mysql_query() expects parameter 2 to be resource, string given in /home/path/EM/em_dio/em_dio.php on line 141
  55.  
  56. That is when I put in the comment lines that show parm 2 is actually a 'resource'.  Does anyone know why this would change and cause these errors?
  57.  
  58. Cheers!
  59.  
  60. OMR
RAW Paste Data
Top