Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
|
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases 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 15th, 2006, 04:44 AM
Authorized User
 
Join Date: Dec 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default store and process error messages

Hi!
I'm fairly new to php and mysql but happily learning this.

In my latest project I want to store a error message(mysql_error) into a variable for further processing with a if-statement.

I tried a simple;
Code:
$error = mysql_error();

echo $error ;
Ok, this doesnt do anything, just wanted to check if the variable worked.

/Hylsan

 
Old December 15th, 2006, 06:15 AM
Authorized User
 
Join Date: Oct 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

what do want to entend? you want and error handling?
or declaring variable?

try visit this-->http://www.w3schools.com/php/php_variables.asp

i hope this can help;))

 
Old December 15th, 2006, 10:05 AM
Authorized User
 
Join Date: Dec 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well...what I want is that when I get a certain error message somethig will happen.

when storing data in a database, and that item already exists, I want to pop a question asking if it should be updated or what. So yes, kind of a error handling.

Sadly w3schools didnt help on that specific subject, but thanks anyway! :)

/Hylsan

 
Old December 19th, 2006, 02:07 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 479
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to surendran Send a message via Yahoo to surendran
Default

hai,
check this it will give you error

<?php
$sql = "error";
mysql_query($sql) or die(mysql_error());
?>


surendran
(Anything is Possible)
http://ssuren.spaces.msn.com
 
Old December 19th, 2006, 07:45 AM
Authorized User
 
Join Date: Dec 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

not sure how that would help me...
I want to store the mysql_error() into a variable, not create a sql error.

/Hylsan

 
Old December 20th, 2006, 02:07 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 479
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to surendran Send a message via Yahoo to surendran
Default

hai,
i can not understand your requirment fully, anyway try this, is this you are looking,
<?php
$sql="error";
$error=mysql_query($sql) or die(mysql_error());
echo($error);
?>


surendran
(Anything is Possible)
http://ssuren.spaces.msn.com
 
Old December 20th, 2006, 06:02 AM
Authorized User
 
Join Date: Oct 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,

i think he wants a certain folder or database wherein those error messages will be stored in that particular location..

_________________________________________________
.::If you quit you lose, If you survive you win::.

.::JHANNY::.


 
Old December 20th, 2006, 08:40 AM
Authorized User
 
Join Date: Dec 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

well...no, what I want is that if, when storing info into a database, something exist the page will ask the user if it should be overwritten or not.

havnt had time to check your latest suggestion surendran, will do asap.

/Hylsan






Similar Threads
Thread Thread Starter Forum Replies Last Post
Enabling error messages halfnote5 Access 2 September 6th, 2007 11:06 AM
error messages strt_prg Struts 1 November 13th, 2006 07:05 AM
error messages timbal25 Classic ASP Databases 0 August 1st, 2006 02:56 PM
Error messages ldoodle Access ASP 12 June 6th, 2005 01:05 PM





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