Advertisement
Guest User

Untitled

a guest
Jun 5th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.90 KB | None | 0 0
  1. define("LOCAL", 1);
  2.  
  3. function sql($query, $debug = 0){
  4.     global $LASTINSERTID;
  5.     if (LOCAL) {
  6.         $dbserver = 'localhost';
  7.         $dbuser = 'root';
  8.         $dbname = 'bebeauty';
  9.         $dbpassword = '';
  10.     } else {
  11.         $dbserver = 'xxx';
  12.         $dbuser = 'xxx';
  13.         $dbname = 'xxx';
  14.         $dbpassword = 'xxx';
  15.     }
  16.  
  17.     if ($debug) {
  18.         echo '<pre class="debug" style="font: normal normal 10pt \'Courier New\'">';
  19.         echo $query;
  20.         echo '</pre>';
  21.     }
  22.  
  23.     $connect = mysql_connect($dbserver, $dbuser, $dbpassword);
  24.     mysql_select_db($dbname, $connect);
  25.     mysql_query('SET NAMES \'utf-8\'');
  26.     mysql_query('SET character_set_client=utf8');
  27.     mysql_query('SET character_set_connection=utf8');
  28.     mysql_query('SET character_set_results=utf8');
  29.     $res = mysql_query($query);
  30.     if(mysql_errno()) die(mysql_errno() .' : '. mysql_error());
  31.     if(mysql_insert_id()){
  32.         $LASTINSERTID = mysql_insert_id();
  33.     }
  34.  
  35.     mysql_close($connect);
  36.     return $res;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement