Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sqlcon($sql){
- /*Erklärung des Return Arrays sqlcon
- * 1. Dimension:
- * 0 = Anzahl der Zeilen
- * 1 = Zeilenausgabe
- * 0 = Zeile 1
- * 0 = Spalte 1
- * 1 = Spalte 2
- * 2 = AutoInkrement ID
- * 00 Mysql Error
- * 01 Connection Error
- * 02 SqL Syntax Error
- *
- */
- global $mysrv,$myusr,$mypass,$mysqldb,$debug;
- $conn = new mysqli($mysrv,$myusr , $mypass,$mysqldb);
- $trans=array();
- // check connection
- if ($conn->connect_error) {
- trigger_error('Database connection failed: ' . $conn->connect_error, E_USER_ERROR);
- }
- $rs=$conn->query($sql);
- $id=$conn->insert_id;
- if($rs === false) {
- trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR);
- } else {
- $anz=(is_object($rs))?$rs->num_rows:0;
- $i=0;
- if($anz>0){
- while ($row = $rs->fetch_assoc()) {
- $arr[$i] = $row;
- $i++;
- }
- }else{
- $arr=array();
- }
- $trans[0]=$anz;
- $trans[1]=$arr;
- $trans[2]=$id;
- $conn->close();
- return $trans;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment