Jump to content
MakeWebGames

Recommended Posts

Posted

Well i made a little function its pretty easy to use, its easier also.

For those of you who like to use the

 

mysql_query("") or die(mysql_error());

 

But ok lets shorten it, how about using

 

query("");

 

and it still displays the mysql_error BUT it does not kill the rest of the game.

Ok so here it is.

Mainly made for v2 users.

 

Add this code right a the bottom of globals.php

<?php
function query($sql)
{
         global $h;
         $val = mysql_query($sql) or print '[b]You have a mysql error:[/b]
'.mysql_error(); $h->endpage(); exit;
         return $val;
}
?>

 

I mainly made it because im sick and tired of the thing always displaying an error but killing the rest of the page.

I know there is the $db->query(""); but i prefer using the old manual. So hope you like.

NOTE: If you like to use my mods i suggest adding this since all my new mods are going to be using it.

Guest Anonymous
Posted

Re:

Almost a nice idea except for 2 little points.

1. Displaying the error message from queries may give people clues about you application and how it can be subverted.

2. There are a few occasions when I can happily ignore execution errors.

Posted

Re:

 

Well its simple, dont put a mod on your game that has errors. Thats why i have given this code because all the new mods i will be making will be using this function :)

I don't think shes on about simple mis typed query errors, it could cause injections to become slightly easier with MySQL errors telling them exactly whats going wrong.

Posted

Re:



Anyways Here is a updated one,

[code]
<?php
function query($sql)
{
global $h;
$val = mysql_query($sql);
if(!$val)
{
echo '[b]You have a mysql error:[/b]'.mysql_error();
$h->endpage();
exit;
}
return $val;
}
?>
[/code]

 

Works better.

Posted

Re:

I do something similar, except I only display the error to high level staff. Any one else gets a generic error message.

Regardless of which of the above happens, it then mails me the error. Simple and effective.

Posted

Re:



Floy that could be quite a easy script to make.

[code]
<?php
function query($sql)
{
global $h, $ir;
$val = mysql_query($sql);
$error = mysql_error();
if(!$val)
{
if($ir['user_level'] == 2)
{
echo '[b]You have a mysql error:[/b]
'.$error;
$h->endpage();
exit;
}
else
{
echo '[b]A simple query error has been detected.[/b]';
event_add(1,"A query error has been detected in the ".$_SERVER['REQUEST_URI']." file, error is:
".$error);
$h->endpage();
exit;
}
}
return $val;
}
?>
[/code]
Guest Anonymous
Posted

Re:

Gotta love you guys ...

Come on THINK....

If you are sending an event or a mail on a SQL error, guess what folks.. I'll take your boxes in minutes. How? Simple - force your system to generate multiple erroneous queries.

As for register_shutdown_function() ... well, lovely idea, but newp. not powerful enough LostOne - although you are thinking along the right lines.

Posted

Re:

That's assuming your code can fail :p

And if mine can, I wanna know about it.

Sometimes I login and see a hundred mails waiting for me, and I fix the problem making 100% sure it can never happen again.

Guest Anonymous
Posted

Re:

 

LostOne waits for ridicule from that cute like programmer...

No ridicule L1, just a suggestion you look more closely at the manual and think a little more - You are on the right lines, but you need to extend this a little further...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...