This is a discussion on "successful query?" within the PHP Forum section. This forum, and the thread "successful query? are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
successful query?
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
||||
|
successful query?
to check if a query was succesful, is the php if statement just;
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
|
|
|||
|
Re: successful query?
Quote:
hmmm.... I didn't test it, but I think it should work. mysql_query() returns either the results if successful, or FALSE if not. die() does not return any values, so I think it should work! Although, maybe this would be a better way of writing it?:
|
|
||||
|
Re: successful query?
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
|||
|
Re: successful query?
The die statement will always take precedence when the mysql query fails. This means that, if mysql_query returns false, then die(...) is executed, ending the script immediately.
The else part of the if statement will then never be executed. |
|
|||
|
Re: successful query?
die() never returns at all. It's a synonym for exit() which exits the script immediately without running another line of code, except for the destructors of already existing objects.
|
|
||||
|
Re: successful query?
sorry...
i just realised my mistake. thanks guys
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
|||
|
Re: successful query?
Thing is, if($result=mysql_query($query)) ...
Will always return true as the return value (true, false, or result set) will be set to the $result variable. I think that
|
|
||||
|
Re: successful query?
what about
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
|||
|
Re: successful query?
Success and fail the other way round, cause you're checking whether $result is false. But yeah... That's good
|
|
||||
|
Re: successful query?
cheers
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
![]() |
| Tags |
| mysql, php, query |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Happy successful 2008! from Cratima. | Cratima | Webforumz Cafe | 1 | Jan 9th, 2008 00:28 |
| Direct Marketing Manager (B2B) for large and successful online directory | Web JobBot | Job Opportunities | 0 | Oct 9th, 2006 11:42 |