I am trying to insert data into a MySQL 4.1.22 data base and the code I have used in the past on other servers isn't working. I am currently using PHP 5.2.8. The only way I have been able to make it work, is by using copied code from the PHP MyAdmin section in my cpanel. This copied code, has what appears to be slanted single quotes, but when replaced with regular single quotes it doesn't work. That is the only difference.
This code works: -
$sql="INSERT INTO $table1 (`UID`, `From`, `PostDate`, `FileName`, `FilePath`, `Time`)
-
VALUES ('$UID', '$from', '$postDate', '$DBfileName', '$filePath', NOW())";
-
This code does not work, but should: -
$sql="INSERT INTO $table1 (UID, From, PostDate, FileName, FilePath, Time)
-
VALUES ('$UID', '$from', '$postDate', '$DBfileName', '$filePath', NOW())";
-
Please help, I have racked my brain, but cannot figure out why it doesn't work and even though I could copy and past for the rest of my life, I would like to know what is going on.
Below is the full script that I am using: -
$con=mysql_connect("localhost",$user,$PW1);
-
if (!$con){
-
die('Could not connect: ' . mysql_error());
-
}mysql_select_db($DB1);
-
-
//Input data
-
$sql="INSERT INTO $table1 (UID, From, PostDate, FileName, FilePath, Time)
-
VALUES ('$UID', '$from', '$postDate', '$DBfileName', '$filePath', NOW())";
-
if (!mysql_query($sql,$con))
-
{
-
die('Error: ' . mysql_error());
-
}
-
-
The only error message I get is that there is an error near 'then it quotes the INSERT INTO section'.
Thanks!
- INSERT INTO $table1 (UID, From, PostDate, FileName, FilePath, Time)
-
# VALUES ('$UID', '$from', '$postDate', '$DBfileName', '$filePath', NOW())";
"From" sql keyword, if you want to use it as field name then you need to escape it like `From`.
4 1987 - INSERT INTO $table1 (UID, From, PostDate, FileName, FilePath, Time)
-
# VALUES ('$UID', '$from', '$postDate', '$DBfileName', '$filePath', NOW())";
"From" sql keyword, if you want to use it as field name then you need to escape it like `From`.
@ddsuresh
Awesome! Thank you! Other than copying and pasting, how do I "escape" it?
@Websurfer08 - INSERT INTO $table1 (UID, `From`, PostDate, FileName, FilePath, Time) VALUES ('$UID', '$from', '$postDate', '$DBfileName', '$filePath', NOW())";
You have to use the above sql code
@ddsuresh
I guess what I was wondering was how do I get the single quote to slant? But, I just found it on my keyboard, never new such a key existed!
Thank you kindly for all the help!
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
by: Mike Chirico |
last post by:
Interesting Things to Know about MySQL
Mike Chirico (mchirico@users.sourceforge.net)
Copyright (GPU Free Documentation License) 2004
Last Updated: Mon Jun 7 10:37:28 EDT 2004
The latest...
|
by: Karam Chand |
last post by:
Hello
I have been working with Access and MySQL for pretty
long time. Very simple and able to perform their jobs.
I dont need to start a flame anymore :)
I have to work with PGSQL for my...
|
by: jlee |
last post by:
I'm pretty much a newbie on mysql, and I need some help.
I am running mysql Ver 12.22 Distrib 4.0.24, for portbld-freebsd5.4
(i386) on a server hosting an active website.
The site's developer...
|
by: rjames.clarke |
last post by:
I am inserting a record in to a mysql database. I'd like to know the
record number of that record.
I use a index field which is auto-incremented.
Is there any way to get a field value returned...
|
by: JPTS |
last post by:
I wrote a script that create a table and insert data but actually it didn't do it
despite it said it did. What can i do? Search for a compatible version of python and mysql? I downloaded the latest...
|
by: Atli |
last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users.
Anyone should be able to get...
|
by: idorjee |
last post by:
Hi,
Is there any way I could insert the data from my current database table to a new table in a new database easily without the need to insert them one-by-one?
I'd appreciate it.
|
by: ssnaik84 |
last post by:
Hi Guys,
Last year I got a chance to work with R&D team, which was working on DB scripts conversion..
Though there is migration tool available, it converts only tables and constraints..
Rest of...
|
by: dgourd |
last post by:
I am trying to create a registering script, but everytime I try to insert the data into my database i get an error.
$query = "INSERT INTO members (username, pass, email, first_name, last_name)...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
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,...
| |