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 text....and 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.....

<?php
$connect=mysql_connect();
$database["server"] = "localhost";
$database["user"] = "ryan1";
$database["password"] = "ryan777";
$database["database"] = "ryan";

if(!$connect = @mysql_connect($database["server"],
 $database["user"],
 $database["password"]))
{print("Problem connecting, failed to connect to:" . $database["server"]);}

$database["sql"] = "insert into Ref_Users
values(NULL,'$FName','$LName','$SiteName',"
.
"'$SiteAddress','$Company','$Address','$Username','$pw','$Email',MONTH(now()
),YEAR(now()),0)";

mysql_select_db($database["database"]);
if (mysql_query($database["sql"]))
{}
else
{print("<p>PROBLEM, Could not create account...ERROR: " . mysql_error() .
"</p>");}
?>

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

Reply via email to