Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Problem with PHP and MySQL

Name: Fledgling 2007-11-26 1:55

Hello guys, I have to create an order for a shopping cart, and I must recover the ID for that order, so I can use it for the order processing. My problem is that I don't know how to do this. Mind giving me a hand? I'm really stumped here.

Name: Anonymous 2007-11-26 2:00

For example, I insert a new order, but then I have to get the ID generated. And then I do another insert with that ID, whose I have to get the ID for that one as well.

Name: Anonymous 2007-11-26 2:07

Ah, silly me. :)

Here is how.

<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
mysql_select_db('mydb');

mysql_query("INSERT INTO mytable (product) values ('kossu')");
printf("Last inserted record has id %d\n", mysql_insert_id());
?>


Hehe. Must pay more attention next time. Thanks anyway guys.

Name: Anonymous 2007-11-26 2:10

>>1-3
I hope you die in a fire. Slowly.

Name: Anonymous 2007-11-26 2:15

>>4
I love you too, anon.

And there is no dying slowly by fire. You faint long before that, if the smoke doesn't do it first.

Name: Anonymous 2007-11-26 2:24

>>4
Contrary to the mythos, death purely by fire is quite quick and painless.

Name: Anonymous 2007-11-26 2:28

Hey, OP, gfto my /prog/

You should not be doing this calibre of programming. You are clearly far too useless for it.

Read SICP.

Name: Anonymous 2007-11-26 2:31

>>7
Well, everyone has to start somewhere, don't we?

And SICP is a bit useless for what I'm doing right now.

Name: Anonymous 2007-11-26 2:42

>>6
You're doing it wrong.

>>8
It's quite possible to go from newbie programmer to reasonably good programmer without passing through a script kiddie stage in the middle.
Keep your hands off PHP until you have a decent understanding of programming, or you'll pick up a million bad habits you'll have to unlearn before you can do anything useful.

Name: Anonymous 2007-11-26 2:43

>>8
Judging from the snippet of code that you posted, you don't understand the basic theory of coding.

Step 1: Database interface class.

Do that and come back.

Name: Anonymous 2007-11-26 2:44

>>10
He's having enough problems as it is. He doesn't need an ENTERPRISE faggot giving him advice.

Name: Anonymous 2007-11-26 3:00

>>10
I got it from php.net.

I would suppose they know about PHP or something. =/

>>9
I really don't get what you mean.

And PHP is one of the first things they taught me. I know Scheme, but it's a skill that hasn't seen much use ever since that class.

Name: Anonymous 2007-11-26 6:44

>>12
You hope for too much if you expect PHP.net to know anything about anything.

Seriously though, pick up one of PHP's ancestor languages first. One of the ones that isn't aimed at script kiddies. It will do wonder for your coding style and your understanding of what the fuck you're doing.

Name: Anonymous 2009-07-12 6:15

from responses towards end. from the and Judging your native build program config. CMake your generate you one Plan It's you code? you source do or do do meaningful missed? then, else but Windows it it Windows seems When for

Name: Anonymous 2010-12-17 1:29

Are you GAY?
Are you a NIGGER?
Are you a GAY NIGGER?

If you answered "Yes" to all of the above questions, then GNAA (GAY NIGGER ASSOCIATION OF AMERICA) might be exactly what you've been looking for!

Name: Anonymous 2010-12-17 1:39

Erika once told me that Xarn is a bad boyfriend

Name: Anonymous 2011-02-04 18:02

Don't change these.
Name: Email:
Entire Thread Thread List