Posted By

gdonald on 09/26/06


Tagged

mysql query mysqli


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

vali29


php mysql/mysqli query


 / Published in: PHP
 

  1. function sqlQuery( $sql )
  2. {
  3. if( in_array( 'mysql', $GLOBALS[ 'loaded_extensions' ] ) )
  4. {
  5. $query = mysql_query( $sql ) or die(
  6. "<pre><font color=\"red\"><b>Invalid SQL:</b>\n\n("
  7. . ' ) '
  8. . "\n\n"
  9. . "<b>Query:</b>\n"
  10. . eregi_replace( "\t", ' ', $sql )
  11. . '</font></pre>' );
  12. }
  13. elseif( in_array( 'mysqli', $GLOBALS[ 'loaded_extensions' ] ) )
  14. {
  15. $query = mysqli_query( $GLOBALS[ 'dbHandle' ], $sql ) or die(
  16. "<pre><font color=\"red\"><b>Invalid SQL:</b>\n\n("
  17. . mysqli_errno( $GLOBALS[ 'dbHandle' ] )
  18. . ' ) '
  19. . mysqli_error( $GLOBALS[ 'dbHandle' ] )
  20. . "\n\n"
  21. . "<b>Query:</b>\n"
  22. . eregi_replace( "\t", ' ', $sql )
  23. . '</font></pre>' );
  24. }
  25.  
  26. return $query
  27. }

Report this snippet  

You need to login to post a comment.