RE: [PHP-DB] INSERT Problem
| From: | Jeff Oien | Date: | Wed, 09 May 2001 16:51:23 +0000 |
| Subject: | RE: [PHP-DB] INSERT Problem | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-9198@lists.php.net to get a copy of this message | ||
That told me my problem. Thank you! I hadn't selected the database
in my connect include but had it in other scripts and not this one.
Long story but thanks for the help. I can stop banging my head now.
Jeff Oien
> on 5/9/01 12:29 PM, Jeff Oien at jeff@webdesigns1.com wrote:
>
> > Am I missing something?
>
> yes. you aren't giving yourself any feedback about what happened when the
> insert failed.
>
> instead of:
>
> $sql = "INSERT INTO $table_name (First_Name, Last_Name)
> VALUES (\"Jeff\", \"Oien\")";
> $result = mysql_query($sql,$connection) or die("Failed");
>
> try:
>
> $sql = "INSERT INTO $table_name (First_Name, Last_Name)
> VALUES (\"Jeff\", \"Oien\")";
> if(! $result = mysql_query($sql,$connection)) {
>
> print("ERROR ".mysql_errno().":
> ".mysql_error()."<br>\n$sql<br>\n");
>
> }
>
> also- i don't see your code for mysql_connect(). make sure you have a valid
> connection to mysql.
>
>
>
> have a great day
> andy
>
> --
> *******************************************************
> Andrew Rush :: Lead Systems Developer :: MaineToday.com
> *******************************************************
>
> "A friend of the devil is a friend of mine" - R. Hunter
>
>
>
>