RE: [PHP] Nathan->Re: [PHP] Julie-> A small question - Mysql_insert_id

2002-06-01 Thread David Freeman


 > Yeah, I seem to have a talent for pissing people of 
 > unintentally, and Julie seemed to have gotten more than a 
 > little pissed at me. Anyway, the reason I didnt specify the 

Perhaps the problem is that you're asking a question that you could
solve yourself.

You asked about mysql_insert_id() and what it would tell you.  Surely
the easiest way to do that would be to _USE_ that function and examine
the result.  You have a web server, you have php and you have a mysql
server.  You can, and if you can't then you should immediately correct
that, examine the raw data in your database.  Because of that you can
see what you expect the relevant part of your code to return by looking
at the raw data and then see if the code returns the correct data.  If
it doesn't then you can start figuring out why.

For anyone else to answer your question you're asking them to figure out
what you're doing, probably ask more questions to figure out what you
could have told them first time around, provide a general answer to
which you will reply that it doesn't work, have them ask for your source
code so they can look at it, have them set the source code up as a test
in their own development environment, etc, etc ,etc.

Sorry, but this almost comes down to basic programming technique - if
you want to do something apply some logic to what you want to achieve
and then figure out a way to do it.  If you think you've found a way,
test it.  If it doesn't work, try something else.  If you are getting
nowhere and decide to ask a question here, at least give some
indications of what you've tried and had not work.

Just some thoughts, and while directed at you, could equally apply to
many others in here (no doubt myself included at times).

CYA, Dave



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Nathan->Re: [PHP] Julie-> A small question - Mysql_insert_id

2002-06-01 Thread r

Hey dude,
Yeah, I seem to have a talent for pissing people of unintentally, and Julie
seemed to have gotten more than a little pissed at me.
Anyway, the reason I didnt specify the type was that I was under the
impression that if you have a auto_increment it has to be an integer...I
mean you cant have a textand if you have a float/double like 2.23 what
will it increment to? 2.24 or 3.23? just did not think of date, time.
Guess she just had a bad day and I was the final straw...:)

I kinda understood what you mean but not totally so am sending you the
actual code used below.

PROBLEM, Could not create account...ERROR: " . mysql_error() .
"");}
?>

What do you think? good, bad or ugly?
Give me your comments/suggestions and if possible add the mysql_insert_id in
the correct place and comment it so that I will know


> Wow, Ryan, lovely reception you've gotten on this one. :-)
>
> Julie has a point (she needs some Prozac or xanex or something, but she
has a point) in that the ID
> field needs a type, either date/time, integer, or string of some sort...
so you'd need to be more
> specific than your original layout:
> id (auto increment)
> name (varchar)
> hits (int)
>
> Something more along the lines of:
> id INT NOT NULL UNSIGNED AUTO_INCREMENT PRIMARY KEY,
> name VARCHAR(255) NOT NULL,
> hits INT UNSIGNED NOT NULL DEFAULT 0
>
> or something like that, depending of course on how you want the table to
behave. You really should
> look into the MySQL manual a bit on table types; the information is well
laid out and easy to
> understand, and if you figure this stuff out now, before you've started
inserting stuff into the
> database, you'll save bunches of time by not needing to change much later
(trust me on this one,
> hooo boy!). You might also want to purchase MySQL by Paul DuBois if you
haven't already, it's a
> fantastic book and widely known on the MySQL mailing list as the MySQL
bible. :-)
>
> Okay, so you have a table called bob or something, and your id is
auto_increment, and you want to
> know what the last ID was from php. You've done an
>
> INSERT INTO bob VALUES (NULL,'myname',300)
>
> with php, and now you wanna know what it thinks id is. You need to
remember what you named your
> connection variable, and pass that to mysql_insert_id like so:
>
> $last_ID = mysql_insert_id($this_connection);
>
> Auto_increment works on a per-connection basis, such that it will remember
only the last ID for this
> specific connection, and as such you need to tell it which connection to
get the ID for, NOT which
> query did the insert (that's what I thought it needed originally, didn't
work very well).
>
> I hope that explains, lemme know if it doesn't :-)
>
> Cheers,
>
> # Nathan




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Julie-> A small question - Mysql_insert_id

2002-06-01 Thread r

Hey Julie,
Sorry, am not "f*cking" with you or anybody,
just new to databases in PHP, I'm from a java servlet background  and we
dont have this kind of function there.
I'm sorry if I offended you or made you think that I was pulling your leg,
its just that after 7 hours of programming the manual looks mighty confusing
even if the explanation is simplecomputers look confusing now;-)

Am a newbie in PHP and a pure virgin in database  programming using PHP,
hope you understand.

Sorry again and have a great day,
-Ryan

> r> Actually the ID field is not null,primary and auto_increment.
>
> Well, it has to be of a TYPE as well...
>
> r> Thanks for the URL but in my message I did quote the line from that
same url
> r> (http://www.php.net/manual/en/function.mysql-insert-id.php)
>
> r> I just need to get the ID of the just inserted record.
>
> I'm just going to assume you're f*cking with all of us and leave it at
> that.
>
>
> - Julie
>
> --> Julie Meloni
> --> [EMAIL PROTECTED]
> --> www.thickbook.com
>
> Find "Sams Teach Yourself MySQL in 24 Hours" at
> http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php