Could someone please tell me what's wrong with the code below. It worked fine the first time, then I cleared the table (results) and tried it again, but got the message "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1".
Problem is I can't see any " near line. And it worked fine the first time. What am I missing?
Thankyou. -
<?php
-
-
include("config.php");
-
include("opendb.php");
-
-
$fcontents = file ('mysqldata.csv');
-
-
for($i=0; $i<sizeof($fcontents); $i++) {
-
$line = trim($fcontents[$i]);
-
$arr = explode(",", $line);
-
-
$sql = "insert into results values ('','".
-
implode("','", $arr) ."')";
-
mysql_query($sql);
-
-
if(mysql_error()) {
-
echo mysql_error() ."<br>\n";
-
}
-
}
-
?>
-
1 1459
Looks fine to me. To make sure I made this little test to see the results.[php]<?php
$arr = array("a", "b", "c");
$sql = "insert into results values ('','".
implode("','", $arr) ."')";
echo "1. $sql<br />";
$sql = "insert into results values ('','".
implode(',', $arr) ."')";
echo "2. $sql<br />";
$arr = array("a'", "b", "c");
$sql = "insert into results values ('','".
implode("','", $arr) ."')";
echo "3. $sql<br />";
?>[/php]
and the results were:[php]1. insert into results values ('','a','b','c' )
2. insert into results values ('','a,b,c')
3. insert into results values ('','a'','b','c ')
[/php]
Now 1 and 2 are fine, but inserting a quote in the array produces result 3 and makes the sql statement invalid. Echo your array content and see if that is the case here.
Ronald :cool:
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: AIM |
last post by:
Error in msvc in building inheritance.obj to build hello.pyd
Hello,
I am trying to build the boost 1.31.0 sample extension hello.cpp.
I can not compile the file inheritance.cpp because the two
files containing some templates: adjacency_list.hpp and mem_fn.hpp can
not compile.
Does anyone have any solutions?
|
by: lawrence |
last post by:
The following function correctly makes everything invisible but then
fails to turn the one chosen DIV back to visible. I imagine I'm
getting the syntax of the variable wrong? I've tried this with both
single quotes and no single quotes, but it doesn't work either way.
What am I doing wrong?
<SCRIPT type='text/javascript'>
function makeVisible(nameOfDiv) {
document.getElementById('weblogs').style.visibility='hidden';
|
by: Minh |
last post by:
I've just installed VS.NET 2003 on my Athlon XP 1800+. However I couldn't
get any project with STL includes to compile even if I create a new empty
project (and added #include <string>). It gave me a bunch of "missing ;"
errors. I did reinstall the whole thing a few times but it didn't work.
Anyone have any idea?
Thanks
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xutility(862) :
|
by: Shashikiran Prabhakar via .NET 247 |
last post by:
(Type your message here)
Hi,
I am not very conversent in VC++, but the requirement for me is to run a rendering code.
However i am encountering the following errors.
c:\Program Files\MultiGen-Paradigm\include\vsg\stlport\cstdio(49): error C2039: '_vsnprintf' : is not a member of 'std'
c:\Program Files\MultiGen-Paradigm\include\vsg\stlport\cstdio(115): error C2039: 'vsnprintf' : is not a member of 'std'
c:\Program...
|
by: Haydnw |
last post by:
I have the following line of code in a code-behind file. It's part of a
event which is run when a user clicks an asp:imagebutton on a page.
tblMainImage.Rows.Cells.Attributes.Add("background",
"../images/albums/" & Request.QueryString("d") & "/" &
RowView("strFilename") & ".jpg")
However, when I view the page I get an error message with this line
highlighted, saying:
| |
by: Manuel |
last post by:
I'm trying to compile glut 3.7.6 (dowbloaded from official site)using
devc++.
So I've imported the glut32.dsp into devc++, included manually some
headers, and start to compile.
It return a very strange error. In your experience, where I should
looking to find the real error? Surely the sintax of glut is correct...
gcc.exe -c glut_bitmap.c -o glut_bitmap.o -I"C:/Dev-Cpp/include"
-I"../../include" -D__GNUWIN32__ -W -DWIN32 -DNDEBUG...
|
by: Kerem Gümrükcü |
last post by:
Hi,
i am gettin this compiler error over and over for AFIAK perfectly
clean code:
error C2143: Syntaxerror : Missing ';' before ']'
for the Line with the " char szMultibyteString;"
//CODE-------------------
|
by: notahipee |
last post by:
I have been trying to cin an number from 0 to 9 with a leading 0. For
example 00 or 07. I was using a switch case.
switch (int)
{
case 01: break;
case 02: break;.....
My problem arises at 08 and 09 because they are not octal. Is there
any way to coerce the input variable to decimal despite it having a
leading zero .
|
by: madhu.ab |
last post by:
Hi All,
I am getting the following errors when i am including header file
winuser.h
I dont know whats happening. How will an error occur in winuser.h??
Please help.
\microsoft visual studio\vc98\include\winuser.h(39) : error C2061:
syntax error : identifier 'HDWP'
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |