TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 08-17-2008, 09:14 PM   #1 (permalink)
The Addict
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 336
Thanks: 8
tony is on a distinguished road
Confused How can I track errors from a called function?

I am not sure if this goes here but I am kinda beginning with PHP so I put it here, even though it might be a problem in a different level.

My problem is that i made a static query class to have more security in queries before sending them. But i want to know if there is an error in the query to tell me on which file on what line, the query method was called. like this:

PHP Code:
<?php
class QUERY{
#properties
public static $Result;

#Queries
static function select($columns$table$fit=NULL$match=NULL)
{
//make sure parameters are right type
(!is_string($table))? return false;
(!
is_array($columns) || !is_string($columns))? return false;
(!
is_string($fit) || !is_null($fit))? return false;
(!
is_string($match) || !is_null($match))? return false;

(
is_string($columns)? $columns=explode(:,$columns);

//security door
$table=quoteSmart($table);
$columns=quoteSmartArray($columns);
(
$fit!=NULL)? $fit=quoteSmart($fit);
(
$match!=NULL)? $match=quoteSmart($match);

//make a safe query
$query sprintf(
(!
is_array($columns)) return false;“SELECT %s FROM %s”,
implode($columns), $table);

if(!
$fit==NULL && !$match==NULL)
$query .= sprintf(” WHERE %s=%s”$fit$match)

$sql=mysql_query($query); unset($query);
self::$Result=array();
while(
$row=mysql_fetch_assoc($sql)
or throw new 
Exception(“Error in Line 36 in Query class .mysql_error()))
{
for(
$i=0$i<count($res);$i++)
{
foreach(
$row as $key => $value)
self::$Result[$i][$key]=$value;
}
}

return 
self::$Result;
}
}
?>
then in another file i can make a called like this:
PHP Code:
<?php
$res
=QUERY::select(‘CommentID:UserID:Text:DateTime:MediaID’,
‘comments’‘CommentID’$id);

$ID=$res[0][‘CommentID’];
$UserID=$res[0][‘UserID’];
$MediaID=$res[0][‘MediaID’];
$Comment=$res[0][‘Comment’];
$Date=$res[0][‘DateTime’];
?>
as you can see the error is sent and gives me the error line of the query method instead of giving the the line and file where it was called. and I am trying to find a way of telling me that, but i haven’t and it’s frustrating me.
any advice or tips?
tony is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 06:05 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design