Newbie question.
I'm working my way through IBM's PHP tutorial. Generally good ... but
I'm stuck at an error point and have no idea what's going wrong.
Before adding a new row to the mysql database (already opened) we do a
query to see if a particular record already exists.
(see $resultT).
On Tue, 2005-07-05 at 22:36 -0400, Bill McEachran wrote:
Newbie question.
I'm working my way through IBM's PHP tutorial. Generally good ... but
I'm stuck at an error point and have no idea what's going wrong.
Before adding a new row to the mysql database (already opened) we do a
query to
[snip]
We then test, using if, to see if $resultT is true or false. If it's
false we are then supposed to enter a new record.
Problem: it's never false. It always evaluates true. What am I doing
wrong? TIA
/* build query to see if the record is entered already */
$sqlT = select *
Hello Bill,
Wednesday, July 6, 2005, 3:36:09 AM, you wrote:
BM I'm working my way through IBM's PHP tutorial. Generally good ...
BM but I'm stuck at an error point and have no idea what's going
BM wrong. Before adding a new row to the mysql database (already
BM opened) we do a query to see if a
Bill McEachran wrote:
Newbie question.
I'm working my way through IBM's PHP tutorial. Generally good ... but
I'm stuck at an error point and have no idea what's going wrong.
Before adding a new row to the mysql database (already opened) we do a
query to see if a particular record already
On Wed, 2005-07-06 at 14:12 +0100, Richard Davey wrote:
Hello Bill,
Wednesday, July 6, 2005, 3:36:09 AM, you wrote:
BM I'm working my way through IBM's PHP tutorial. Generally good ...
BM but I'm stuck at an error point and have no idea what's going
BM wrong. Before adding a new row to
Hello André,
Wednesday, July 6, 2005, 3:25:37 PM, you wrote:
AM Depending on the sittuation, IMHO, COUNT(*) wouldn't be the way to
AM go. If you need the user's id or somesuch, you have to run an
AM additional query to get the info.
But they're returning absolutely nothing in this case - which
have to agree with Richard here, its wasting resources bringing back *
from the database. Its one of those fundamentals. Only do a select *
from... where you actually need all the info.
Bill, try read the manual to see how the |mysql_query() returns info.
SOmeone has posted the link in this
Richard Davey wrote:
Hello André,
Wednesday, July 6, 2005, 3:25:37 PM, you wrote:
AM Depending on the sittuation, IMHO, COUNT(*) wouldn't be the way to
AM go. If you need the user's id or somesuch, you have to run an
AM additional query to get the info.
But they're returning absolutely
Hello Marek,
Wednesday, July 6, 2005, 3:15:58 PM, you wrote:
MK You can select just the id, and provided that the query returns just
MK zero or one row, you can spare one function call.
Sure that will work fine - but I fail to see how it will save a
function call. You either select, check there
On Wed, July 6, 2005 10:43 am, Richard Davey said:
Hello Marek,
Wednesday, July 6, 2005, 3:15:58 PM, you wrote:
MK You can select just the id, and provided that the query returns just
MK zero or one row, you can spare one function call.
Sure that will work fine - but I fail to see how it
Hello Richard,
Wednesday, July 6, 2005, 10:18:05 PM, you wrote:
RL Actually, I think the SELECT id will transfer less data in the
RL cases where no rows are returned.
Yes, I would agree with that.
RL There are no rows to return, after all, whereas the count(*) will
RL always return exactly one
On Wed, July 6, 2005 4:21 pm, Richard Davey said:
RL And in the case case where a row is returned, the id will probably
RL be the same number of bytes as a count(*): a 32-bit integer.
Say you've got user number 20,000 in a table. He only exists once, so
count() only returns 1. Bring back the
Hello Richard,
Thursday, July 7, 2005, 1:16:29 AM, you wrote:
RL You've just made my point.
RL The actual data tuple returned in both cases is a long, if there
RL is a user to match.
This is where we differ :) I don't believe MySQL will return an entire
longs worth of data (typically 4 bytes)
14 matches
Mail list logo