Re: Increment help..please
| From: | David Robley | Date: | Thu, 24 Jan 2002 22:25:37 +0000 |
| Subject: | Re: Increment help..please | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-81985@lists.php.net to get a copy of this message | ||
In article <B87619AC.1237%will@colemanmoore.com>, will@colemanmoore.com
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!