NYCPHP Meetup

NYPHP.org

[nycphp-talk] Mysql Update Problem Database Column Types

Jeremy Hise jhise at linuxforbusiness.org
Sat May 18 15:06:53 EDT 2002


Ok. 
So I created small test to see what would happen if I tried to update a
record using your syntax with PHP/mySQL.

It didn't work. No errors, but it still didn't work. The only major flaw
with my test is that I'm using a straight-up int (int(11)), and you are
using a medium and tiny int. But I'm assuming all numbers should be
addressed the in the same manner.

If you are updating a record, you should not put quotes around the
values for the number fields.

eg:

table test:

name	type
job_id	int(11)

You should not say:

update test set job_id = "23";

You should say:

pdate test set job_id = 23;

For your update query should be:

$sql = "update jobs set 
KEYWORD1 = \\"$keyword1\\",
KEYWORD2 = \\"$keyword2\\",
KEYWORD3 = \\"$keyword3\\",
KEYWORD4 = \\"$keyword4\\",
KEYWORD5 = \\"$keyword5\\",
COMP_ID = $comp_id,
SHOW_DATE = \\"$show_date\\",
JOB_CAT = $job_cat,
JOB_LOC = \\"$job_loc\\",
JOB_TITLE = \\"$job_title\\",
JOB_DESC = \\"$job_desc\\",
JOB_SALARY = \\"$job_salary\\",
FIRST_NAME = \\"$first_name\\",
LAST_NAME = \\"$last_name\\",
AD_EMAIL = \\"$ad_email\\",
CNTCT_EMAIL = \\"$cntct_email\\",
USR_NAME = \\"$usr_name\\",
P_WORD = \\"$p_word\\",
AD_PHONE = \\"$ad_phone\\",
CNTCT_PHONE = \\"$cntct_phone\\",
AD_FAXPHONE = \\"$ad_faxphone\\",
WEB_SITE = \\"$web_site\\",
CCNAME = \\"$ccname\\",
CCNUMBER = \\"$ccnumber\\",
MONTHEXP = \\"$monthexp\\",
YEAREXP = \\"$yearexp\\",
CCTYPE = \\"$cctype\\",
STREET1A = \\"$street1A\\",
STREET2A = \\"$street2A\\",
STREET3A = \\"$street3A\\",
CC_CITY = \\"$cc_city\\",
CC_STATE = \\"$cc_state\\",
CC_ZIP = \\"$cc_zip\\",
TRBLFONE = \\"$trblfone\\"
where job_id = $job_id";

Note that I have changed job_cat, comp_id and job_id in the where
clause.

This seems to be at least 1 problem.

Good luck and let us know if it works out!

jeremy
 

On Sat, 2002-05-18 at 13:05, Jerry Wing wrote:
> Jeremy, here are the column types...Please check to see if I messed up
> something in my script based on variable type....my principal function
> in life is business and I would appreciate it if you would catch my
> errors....or anyone else....let me start with your suggestion Jeremy.... 
> 
> Here are the column types for the database UPDATE problem in my earlier
> post:
> 
> keyword1 varchar(15) null
> keyword2 varchar(15) null
> keyword3 varchar(15) null
> keyword4 varchar(15) null
> keyword5 varchar(15) null
> comp_id mediumint(6) unsigned null
> job_id mediumint(6) unsigned primary key autoincrement
> recv_date timestamp(14) null
> show_date date null
> job_cat tinyint(3) unsigned null
> job_loc char(3) null
> job_title varchar(80) null
> job_desc text null
> job_salary varchar(11) null
> ad_expire date null
> first_name varchar(40) null
> last_name varchar(40) null
> ad_email varchar(40) null
> cntct_email varchar(40) null
  usr_name varchar(15) null
> p_word varchar(15) null
> ad_phone varchar(12) null
> cntct_phone varchar(12) null
> ad_faxphone varchar(12) null
> web_site varchar(50) null
> visible enum('n','N','y','Y') null
> ccname varchar(70) null
> ccnumber varchar(30) null
> monthexp char(2) null
> yearexp char(2) null
> cctype char(1) null
> street1A varchar(80) null
> street2A varchar(80) null
> street3A varchar(80) null
> cc_city varchar(40) null
> cc_state char(2) null
> cc_zip varchar(10) null
> trblfone varchar(12) null
> 
> 
> 
 





More information about the talk mailing list