Wrox Programmer Forums
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 1st, 2005, 02:20 PM
Authorized User
 
Join Date: Nov 2005
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default php_errormsg

Hi,
I wrote code something like
$query=".............";
$result=@mysql_query($query) or die($php_errormsg);

I got a message to say
Notice: Undefined variable: php_errormsg in ...

Anybody can let me know what's wrong with it and how to fix it?
i changed track_errors=On in my php.ini

Thank you all,
Jun

 
Old December 1st, 2005, 02:32 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

You probably want this:
$result=@mysql_query($query) or die(mysql_error());

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design
 
Old December 1st, 2005, 03:58 PM
Authorized User
 
Join Date: Nov 2005
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i have used $result=@mysql_query($query) or die(mysql_error());
before, but some doc say that $php_errormsg can report more info in details.
http://php.mirrors.ilisys.com.au/man...rorcontrol.php have some info about $php_errormsg

Any idea?

Thanks,
Jun

 
Old December 1st, 2005, 05:30 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

That may be the case if you are calling on a PHP function and an error is generated, but you aren't going to see the database errors generated by MySQL using that method, which are more useful in this case. I didn't even know such a method existed, so needless to say I've never used it.

To get around the Notice error, add this to the start of your code. I assume that variable is only created if there is an error to report. For that bit of code you have there, mysql_error() is what you want to use anyway.

if (!isset($php_errormsg))
{
    $php_errormsg = '';
}

HTH!

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design
 
Old December 2nd, 2005, 11:06 AM
Authorized User
 
Join Date: Nov 2005
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, you are right. Forget about the $php_errormsg for now.

At the same time, do you have any way to see more info in details about mysql error?

Thanks,
Jun










Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.