Basic MySQL Query Question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm having some inconsistency with mysql insert queries when there is a
single quote involved.

Example: A new member register's with the name of Jason O'Neal. There are no
addslashes in the code, and the user is entered into the table correctly.

Insert into members (name) values ('$_POST[name]');

Now the user submits a trouble ticket from within the site. The process is
to select the name from the members table and insert it along with the
ticket, into the tickets table. When this happens, I get an error on the
insert.

Select name from members where id = $_SESSION[uid];

Insert into tickets (name,problem) values ('$row[name]','$_POST[problem]');

Now I am forced to use addslashes to make it work, as well for the problem
that they submit.

What is the difference? It seems that if it works one place, then it should
work every where?

Or would it matter that name is not a key in the members table but is in the
tickets, or Vice Versa?

This is really bugging me.
 
Thank You,
Chad Stalvey
Dynamic Solutions
www.dyn3.com
(850)-508-0369
chad@xxxxxxxx
 

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux