Current location: Hot Scripts Forums » Programming Languages » PHP » Quick Question on mysql_query();


Quick Question on mysql_query();

Reply
  #1 (permalink)  
Old 05-21-06, 02:42 PM
nova912's Avatar
nova912 nova912 is offline
Code Guru
 
Join Date: Sep 2004
Location: Traverse City, MI, USA
Posts: 821
Thanks: 0
Thanked 0 Times in 0 Posts
Quick Question on mysql_query();

If I do a mysql section like so...
PHP Code:

$query 'UPDATE parts SET 

            part = '
.$part_type.',
            manufacturer = '
.$part_manufacturer.',
            model = '
.$part_model.',
            warranty = '
.$part_warranty.',
            wholesale_cost = '
.$part_wholesale_cost.',
            retail_cost = '
.$part_retail_cost.'
            WHERE parts.part_id = "'
.$HTTP_SESSION_VARS['edit_part_id'].'" LIMIT 0,1';
$result mysql_query($query) or die('Error: Could not update part information.<br>'.mysql_error()); 
I would not need to make this...
PHP Code:

if (!$result)

{
die(
'error');

Right?
Reply With Quote
  #2 (permalink)  
Old 05-21-06, 03:12 PM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
You could do either:
PHP Code:

mysql_query$query ) or die( 'Error: Could not update part information.<br>' mysql_error() ); 

or:
PHP Code:

$result mysql_query$query );


if (! 
$result )
{
    die( 
'Error: Could not update part information.<br>' mysql_error() );

Reply With Quote
  #3 (permalink)  
Old 05-21-06, 03:16 PM
nova912's Avatar
nova912 nova912 is offline
Code Guru
 
Join Date: Sep 2004
Location: Traverse City, MI, USA
Posts: 821
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Keith
You could do either:
PHP Code:

mysql_query$query ) or die( 'Error: Could not update part information.<br>' mysql_error() ); 

or:
PHP Code:

$result mysql_query$query );


if (! 
$result )
{
    die( 
'Error: Could not update part information.<br>' mysql_error() );

Cool, so basically I can use either and they both will do the same in any situation related to mysql_query() comming back true or false.
Reply With Quote
  #4 (permalink)  
Old 05-21-06, 07:06 PM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
Yup, you got it.
Reply With Quote
  #5 (permalink)  
Old 05-21-06, 09:06 PM
nova912's Avatar
nova912 nova912 is offline
Code Guru
 
Join Date: Sep 2004
Location: Traverse City, MI, USA
Posts: 821
Thanks: 0
Thanked 0 Times in 0 Posts
O, um on the topic of compatability... the "or die()" tagged onto the mysql_query().. anyone have any clue on how far back in php versions that will work?
Reply With Quote
  #6 (permalink)  
Old 05-21-06, 10:09 PM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
All the way back to PHP version 3 (die is an alias of exit) - http://www.php.net/manual/en/function.exit.php
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Quick Question Please about 2php.com Darkshores General Advertisements 2 03-07-06 07:42 AM
Get information from another page QUICK QUESTION HairySpider PHP 13 04-12-05 10:17 AM
quick question i need assistence Choke The Lounge 1 01-27-05 01:03 PM
Quick Question for you php guru's Tokahashi PHP 3 04-09-04 12:00 PM


All times are GMT -5. The time now is 07:15 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.