Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Add Slashes in MySQL via PHP?
Old 05-02-2011, 10:12 AM Add Slashes in MySQL via PHP?
Super Talker

Posts: 148
Trades: 0
Hi all,

I am trying to add the path of my file into one of the columns in MySQLDB Table. The column, FilePath, data type is Text.

An example of the file path to be added would be: C:/Temp/abc.jpg. I am using:
PHP Code:
mysql_query("Insert Into table(FilePath,booleanValue)Values('C:/Temp/abc.jpg','0');"); 
The error i keep encountering is:
Code:
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 ''1',,,,'C:/Temp/abc.jpg' at line 2
Any help is appreciated!

Last edited by shaoen01; 05-02-2011 at 10:20 AM..
shaoen01 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-02-2011, 10:21 AM Re: Add Slashes in MySQL via PHP?
Super Talker

Posts: 148
Trades: 0
It looks like it is the boolean value that could be causing it? The booleanValue data type is boolean. Am i adding it correctly via the insert statement?
shaoen01 is offline
Reply With Quote
View Public Profile
 
Old 05-02-2011, 10:30 AM Re: Add Slashes in MySQL via PHP?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
The query you have posted bears no resemblance to what the error message is showing.

an insert query should be

INSERT INTO table CommaSeperatedFieldlist VALUES('comma', 'seperated','list','of values', 'in the' appropriate', 'order')

You appear to be attempting to insert one value to a table with specifying the field(s) it should be in.

NOW that is possible but your value list MUST be a complete one with ALL the values in the CORRECT ORDER for the table columns.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-02-2011, 10:34 AM Re: Add Slashes in MySQL via PHP?
Super Talker

Posts: 148
Trades: 0
I solved it by removing the '' for the boolean value. Apparently, it causes some problems in the insert statement. Thanks
shaoen01 is offline
Reply With Quote
View Public Profile
 
Old 05-02-2011, 10:36 AM Re: Add Slashes in MySQL via PHP?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
that would depend on the data type for the "boolean column"
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Add Slashes in MySQL via PHP?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.64544 seconds with 12 queries