473,788 Members | 2,905 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MySQL sysntax error

1 New Member
Hi Guys
im trying to write an import class where i can import information from .CSV file into my database. I am getting the following error
Errors: 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 PHP Warning: mysql_num_rows( ): supplied argument is not a valid MySQL result resource in C:\hshome\sysco n05\sysconsolut ions.co.za\impo rt\Quick_CSV_im port.php on line 138 PHP Warning: mysql_fetch_ass oc(): supplied argument is not a valid MySQL result resource in C:\hshome\sysco n05\sysconsolut ions.co.za\impo rt\Quick_CSV_im port.php on line 143
Below is the block of code making the error

function get_encodings()
{
$rez = array();
$sql = "SHOW CHARACTER SET";
$res = @mysql_query($s ql);
// Below is where line 143 is situated
if(mysql_num_ro ws($res) > 0)
{
while ($row = mysql_fetch_ass oc ($res))
{
$rez[$row["Charset"]] = ("" != $row["Descriptio n"] ? $row["Descriptio n"] : $row["Charset"]); //some MySQL databases return empty Description field
}
}
return $rez;
}

//defines the encoding of the server to parse to file
Feb 4 '08 #1
1 1530
myth0s
32 New Member
Hi Guys
im trying to write an import class where i can import information from .CSV file into my database. I am getting the following error
Errors: 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 PHP Warning: mysql_num_rows( ): supplied argument is not a valid MySQL result resource in C:\hshome\sysco n05\sysconsolut ions.co.za\impo rt\Quick_CSV_im port.php on line 138 PHP Warning: mysql_fetch_ass oc(): supplied argument is not a valid MySQL result resource in C:\hshome\sysco n05\sysconsolut ions.co.za\impo rt\Quick_CSV_im port.php on line 143
Below is the block of code making the error

function get_encodings()
{
$rez = array();
$sql = "SHOW CHARACTER SET";
$res = @mysql_query($s ql);
// Below is where line 143 is situated
if(mysql_num_ro ws($res) > 0)
{
while ($row = mysql_fetch_ass oc ($res))
{
$rez[$row["Charset"]] = ("" != $row["Descriptio n"] ? $row["Descriptio n"] : $row["Charset"]); //some MySQL databases return empty Description field
}
}
return $rez;
}

//defines the encoding of the server to parse to file
Why do you have a "@" before "mysql_query($s ql)". I never seen this before.

As for the warnings on lines 138 and 143, it's normal. If the query fails (as yours did), then $res does not contain a result set. Any subsequent functions that require $res to be a result set, as mysql_num_rows( $res), will fail because the SQL command failed ;)
Feb 4 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2863
by: nu b | last post by:
Hello all. I am new and I am having a tough time spotting my error here. The idea is to produce an applet that will have a JButton which I can push to display the string myName. Later I will make it so that it will chage the font size and style, but for now I can't even get it to display the String. It compiles fine but when I launch it in the browser or with the appletviewer, it shows the button and nothing happens when I click it. Can...
0
3530
by: Lenz Grimmer | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, MySQL 4.0.14, a new version of the popular Open Source/Free Software Database, has been released. It is now available in source and binary form for a number of platforms from our download pages at http://www.mysql.com/downloads/ and mirror sites.
0
2891
by: Stefan Hinz | last post by:
Degan, jumping in to try and solve some problems that look pretty obvious to me ... > #options for default service (mysqld2) > (mysqld2) It should be , not (mysqld2).
0
2491
by: Dennis Francis B. Tutanes | last post by:
$B$*@$OC$K$J$C$F$*$j$^$9!#(B $B%D%?%M%9(B@TSTI$B$G$9!#(B SEND-PR: -*- send-pr -*- SEND-PR: Lines starting with `SEND-PR' will be removed automatically, as SEND-PR: will all comments (text enclosed in `<' and `>'). SEND-PR: From: dtutanes To: mysql@lists.mysql.com Subject:
4
5853
by: Adam Smith | last post by:
I have a dedicated server running 'FreeBSD 4.9 STABLE' at a hosting site. They have done some default installations, presumably from the CVS ports package ??. Herein lies the problem, "I do not know" what they have done! At first it was apparent that MySQL was installed mysql_install_db ; GRANT TABLES etc. ??? so I ran "mysql_install_db --force"
1
121535
by: jiing | last post by:
Now let me describe what I have done and my purpose: Originally, I want to user ports to install phpBB But I found that phpBB doesn't support mysql 5.x (but the ports installed mySQL 5.0.0 alpha) so I deinstall mysql5-server and mysql5-client And then I install mysql41-server and mysql41-client on FreeBSD 5.3 by ports but now , mysql is not workable
3
1095
by: Rudy | last post by:
Hello All! I'm coding my UPDATE button on my data grid. Getting a syntax error, can't seen to find it. Hope you can help Thanks!!! Rudy Public Sub grdProducts_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
221
367742
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application needs to store entire files, the preferred method is to save the file onto the server’s file-system, and store the physical location of the file in your database. This is generally considered to be the easiest and fastest way to store files. ...
1
3016
by: Steve Ametjan | last post by:
I've been trying to get MySQL-python to install on Leopard for the past couple of days, and I keep running into relatively the same error. I'm hoping that someone on this list will be able to help me out in solving the issue. I'd like to get this solved so I can continue developing with Django using MySQL since that's what my web server uses as well. I'd hate to have to develop using a different database engine on my local...
0
9656
marktang
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...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10172
jinu1996
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...
1
10110
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,...
0
8993
agi2029
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...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.