Re: Newbie MySQL problem
| From: | David Robley | Date: | Tue, 26 Sep 2000 06:17:17 +0000 |
| Subject: | Re: Newbie MySQL problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-17535@lists.php.net to get a copy of this message | ||
On Tue, 26 Sep 2000, Adam Charnock wrote:
> Hi all, im just learning MySQL and im trying to loop through a 2d array and
> add its values to a table. I don't get any errors but nothing gets added to
> the table. I have opened all the connections etc. so I am not sure what the
> problem is:
>
> for($a=0;$a<count($categories);$a++){
>
> $sqlquery = "INSERT INTO $cattable
>
> VALUES('$id','$categories[$a][0]','$categories[$a][1]','$categories[$a][2]',
> '$categories[$a][3]','0')";
> $results = mysql_query($sqlquery);
> echo
> $categories[$a][0],$categories[$a][1],$categories[$a][2],$categories[$a][3],
> "<br><br>\n\n\n";
>
> }
>
> Thanks :-)
>
> Adam Charnock
>
> PS. This is actually part of a news grabber from moreover.com, I have made a
> non-MySQL version but it just needs speeding up. If anyone has done this I
> would love to speak to them :) thanks!
I don't see from whence you get a value for $id ?? If this is an
autoincrement field, you don't want to feed it a value and you should be
using the INSERT INTO tablename [colname...] VALUES[expression....] syntax
and just inserting the categories.
If $id is being inserted into an integer field, you could also run into
trouble.
Also, try adding echo mysql_error() after you pass off the query to mysql
to see if there is an error you aren't seeing.
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA