[P, SC] Beta-testers needed AGAIN - Page 2
Blogs > Taiche |
yenta
Poland1142 Posts
| ||
Taiche
France1963 Posts
| ||
anotak
United States1537 Posts
| ||
Taiche
France1963 Posts
| ||
MasterOfChaos
Germany2896 Posts
+ Show Spoiler + function query() { $args = func_get_args(); $args_count=func_num_args(); if ($args_count==0){die('Query needs at least one parameter');}; if ($args_count>1) { for ($i=1;$i<$args_count;$i++) { if (get_magic_quotes_gpc()) $args[$i]=stripslashes($args[$i]); $args[$i]=mysql_real_escape_string($args[$i]); } $qry=call_user_func_array('sprintf', $args); } else $qry=&$args[0]; $res=@mysql_query($qry); if ($res===false) { collect additional info about the site like POST and GET Data if (($_SERVER['REMOTE_ADDR']=='127.0.0.1')or(Is User an Admin?)) { echo('<div class="sql_error">Mysqlerror:<br><pre>'.htmlentities($qry).'</pre><br>'.htmlentities(mysql_error()).'</div>'); } else { Log query to database here die('SQL-Error'); } } return $res; } Usage: $res=query("select * from table where name='%s'",$nick); $res=query("select * from table where id=%d",$id); | ||
Taiche
France1963 Posts
| ||
yenta
Poland1142 Posts
| ||
| ||