Re: [PHP] Increment help..please
I just learned about a cool function -- "mysql_insert_id()". You can read about it in the manual, but it sounds like it could be used to get the AUTO_INCREMENT number from the database and you can then append that number to your uploaded image file name. Erik On Thursday, January 24, 2002, at 03:06 PM, will hives wrote: > I did that with this script and it works fine, but the reason I am > doing it > is so I can then give the image which is uploaded the story ID. But for > some > reason I can't get it to work... here is the auto_increment script any > ideas > of how to add the ID to the image?? I would be very great ful if you > could amend the script (as I am a newb I can work things out once they > have > been done if that makes any sense) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Increment help..please
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] says... > I did that with this script and it works fine, but the reason I am doing it > is so I can then give the image which is uploaded the story ID. But for some > reason I can't get it to work... here is the auto_increment script any ideas > of how to add the ID to the image?? I would be very great ful if you > could amend the script (as I am a newb I can work things out once they have > been done if that makes any sense) > > cheers will > > $db_name = "main"; > > $table_name = "main"; > > $connection = @mysql_connect("www.main.net", "main", "main") or die > ("couldn't connect."); > > $db = @mysql_select_db($db_name, $connection) or die ("couldn't select > database."); > > $sql = "INSERT INTO $table_name (id, name, email, picture_name) > VALUES ('$id', '$name', '$email', '$picture_name') "; > > $result = @mysql_query($sql, $connection) or die ("couldn't execute query"); First, if you are having trouble with a particular mysql query, try using mysql_error after the mysql_query t ogive you useful feedback; you are currently suppressing any useful output. Second, if you want to provide your own sequence of IDs, that's fine, but make sure that the type of data you are providing matches the field type you are adding it to. Your code above has quotes around the value being provided for id which marks it as a char type, or string, but I suspect that you probably have a numeric type in your table? -- David Robley Temporary Kiwi! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Increment help..please
I did that with this script and it works fine, but the reason I am doing it is so I can then give the image which is uploaded the story ID. But for some reason I can't get it to work... here is the auto_increment script any ideas of how to add the ID to the image?? I would be very great ful if you could amend the script (as I am a newb I can work things out once they have been done if that makes any sense) cheers will my contact management system: add a contact Name & email information name: email: File to Upload: http://www.main.net/images/$picture_name";; ?>> in article 004501c1a511$642b4930$a023b1cf@win2k, Tyler Longren at [EMAIL PROTECTED] wrote on 24/1/02 7:57 pm: > Why don't you just set auto_increment on the id field in the database table? > > Tyler > > - Original Message - > From: "will hives" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, January 24, 2002 1:43 PM > Subject: [PHP] Increment help..please > > >> please help I'm a newb and this is really messing with my head. All I want >> to know is what do I need to add to this script to allow it to increment > the >> ID number. pleasee. >> thank you very much for a simple boy >> >> Will >> > >> $db_name = "altone"; >> >> $table_name = "author"; >> >> >> >> $connection = @mysql_connect("www.myserver.net", "test", "will") or die >> ("couldn't connect."); >> >> $db = @mysql_select_db($db_name, $connection) or die ("couldn't select >> database."); >> >> $sql = "INSERT INTO $table_name (id, name, email, picture_name) >> VALUES ('$id', '$name', '$email', '$picture_name') "; >> >> $result = @mysql_query($sql, $connection) or die ("couldn't execute > query"); >> >> >> >> >> >> if ($picture != "") { >> >> >> move_uploaded_file($picture, "/home/mine/yep/php/$picture_name"); >> >> >> } >> >> >> >> >> ?> >> >> >> >> >> my contact management system: add a contact >> >> >> >> >> >> Name & email information >> >> >> >> >> >> name: >> >> >> >> >> email: >> >> >> >> File >> to Upload: >> http://www.myserver.net/php/$picture_name";; ?>> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> Cheers >> Will >> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> To contact the list administrators, e-mail: [EMAIL PROTECTED] >> >> > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Increment help..please
All you need to do is the set the field type for the id similar to : ID smallint not null primary key auto_increment you do not need to refer to ID in your insert statement. /dkm - Original Message - From: "will hives" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, January 24, 2002 2:43 PM Subject: [PHP] Increment help..please > please help I'm a newb and this is really messing with my head. All I want > to know is what do I need to add to this script to allow it to increment the > ID number. pleasee. > thank you very much for a simple boy > > Will > > $db_name = "altone"; > > $table_name = "author"; > > > > $connection = @mysql_connect("www.myserver.net", "test", "will") or die > ("couldn't connect."); > > $db = @mysql_select_db($db_name, $connection) or die ("couldn't select > database."); > > $sql = "INSERT INTO $table_name (id, name, email, picture_name) > VALUES ('$id', '$name', '$email', '$picture_name') "; > > $result = @mysql_query($sql, $connection) or die ("couldn't execute query"); > > > > > > if ($picture != "") { > > > move_uploaded_file($picture, "/home/mine/yep/php/$picture_name"); > > > } > > > > > ?> > > > > > my contact management system: add a contact > > > > > > Name & email information > > > > > > name: > > > > > email: > > > > File > to Upload: > http://www.myserver.net/php/$picture_name";; ?>> > > > > > > > > > > > > > > > > > > > > Cheers > Will > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Increment help..please
In your database, make the ID column AUTO_INCREMENT, and then simply don't specify a value for it when you insert. - Original Message - From: "will hives" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, January 24, 2002 11:43 AM Subject: [PHP] Increment help..please > please help I'm a newb and this is really messing with my head. All I want > to know is what do I need to add to this script to allow it to increment the > ID number. pleasee. > thank you very much for a simple boy > > Will > > $db_name = "altone"; > > $table_name = "author"; > > > > $connection = @mysql_connect("www.myserver.net", "test", "will") or die > ("couldn't connect."); > > $db = @mysql_select_db($db_name, $connection) or die ("couldn't select > database."); > > $sql = "INSERT INTO $table_name (id, name, email, picture_name) > VALUES ('$id', '$name', '$email', '$picture_name') "; > > $result = @mysql_query($sql, $connection) or die ("couldn't execute query"); > > > > > > if ($picture != "") { > > > move_uploaded_file($picture, "/home/mine/yep/php/$picture_name"); > > > } > > > > > ?> > > > > > my contact management system: add a contact > > > > > > Name & email information > > > > > > name: > > > > > email: > > > > File > to Upload: > http://www.myserver.net/php/$picture_name";; ?>> > > > > > > > > > > > > > > > > > > > > Cheers > Will > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Increment help..please
Why don't you just set auto_increment on the id field in the database table? Tyler - Original Message - From: "will hives" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, January 24, 2002 1:43 PM Subject: [PHP] Increment help..please > please help I'm a newb and this is really messing with my head. All I want > to know is what do I need to add to this script to allow it to increment the > ID number. pleasee. > thank you very much for a simple boy > > Will > > $db_name = "altone"; > > $table_name = "author"; > > > > $connection = @mysql_connect("www.myserver.net", "test", "will") or die > ("couldn't connect."); > > $db = @mysql_select_db($db_name, $connection) or die ("couldn't select > database."); > > $sql = "INSERT INTO $table_name (id, name, email, picture_name) > VALUES ('$id', '$name', '$email', '$picture_name') "; > > $result = @mysql_query($sql, $connection) or die ("couldn't execute query"); > > > > > > if ($picture != "") { > > > move_uploaded_file($picture, "/home/mine/yep/php/$picture_name"); > > > } > > > > > ?> > > > > > my contact management system: add a contact > > > > > > Name & email information > > > > > > name: > > > > > email: > > > > File > to Upload: > http://www.myserver.net/php/$picture_name";; ?>> > > > > > > > > > > > > > > > > > > > > Cheers > Will > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Increment help..please
please help I'm a newb and this is really messing with my head. All I want to know is what do I need to add to this script to allow it to increment the ID number. pleasee. thank you very much for a simple boy Will my contact management system: add a contact Name & email information name: email: File to Upload: http://www.myserver.net/php/$picture_name";; ?>> Cheers Will -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]