You are here: Re: multidimensional array in to a MySQL table « PHP Programming Language « IT news, forums, messages
Re: multidimensional array in to a MySQL table

Posted by Jerry Stuckle on 03/14/06 13:58

Stephen Preston wrote:
> Hi
>
> Thanks to you all for replying, and sorry if my explaination was garbled.
> The code for the section is as follows.
> The first part empties the table first (which it does). After persevering
> further last night the code below empties the contents of the table, and the
> $result inside the brackets fills one row of the MySQL table with the first
> row of the array, then issues the 'Couldn't insert data'.
> If I swap the $result is outside the brackets (# commented out below), the
> table is emptied again and then the last row of the array fills one row of
> the table. 'Couldn't insert data' is not issued though this time.
>
>
> if(isset($_POST['dataok']))
> {
> $input = $_POST[input];
> include("dataup.inc");
> $query1 = "DELETE FROM $tableName";
> $result = mysql_query($query1)
> or die("Couldn't delete the data.");
> echo "All data within $tableName has been deleted!!!<p>";
>
> foreach($input as $row)
> {
> $query2 = "INSERT INTO $tableName
> (level1,level2,level3,illust,item,description,partNo,qua,price,remarks,weight,size,mass)
> VALUES
> ('$row[level1]','$row[level2]','$row[level3]','$row[illust]','$row[item]','$row[description]','$row[partNo]','$row[qua]','$row[price]','$row[remarks]','$row[weight]','$row[size]','$row[mass]')";
> $result = mysql_query($query2) or die("Couldn't insert data.");
> }
> # $result = mysql_query($query2) or die("Couldn't insert
> data.");
>
> exit();
> } # endif
>
> Still trying to understand Richards first example (my lack of
> understanding), not his explaination I think.
>
> Thanks
> Stephen
>
>

Rather than just saying "Couldn't insert data", you need to find out WHY
it couldn't insert it. Try mysql_error() and see what it says.

I suspect it has to do with your values; amongst other things, numeric
values should not have quotes around them.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация