Re: newbie sunday morning not-enough-caffeine question

From: Date: Sun, 04 Jun 2000 19:21:54 +0000
Subject: Re: newbie sunday morning not-enough-caffeine question
Groups: php.db 
Request: Send a blank email to php-db+get-194@lists.php.net to get a copy of this message
You're INSERT statement line needs to change... the problem is in the below you are telling it to insert "$salesperson_code" which isn't defined... at all... What you want is: $sql = "INSERT INTO job_info (job_number, customer_code, salesperson_code) VALUES ('$job_number', '$customer_code', '$row[salesperson_code]') "; Notice the difference in the last part (ie "$row[salesperson_code]"). -philip In article <002101bfce46$0515a380$2098560c@oemcomputer>, webmaster <warden@bakergrfx.com> wrote: >Greetings. >This simple little problem has been driving me nuts >since I started this morning... hopefully one of you can >help me. >In essence, I need simply to read the variable "salesperson_code" >from the "salespersons" table and write it into the "job_info" table. >(The salesperson code may change in the future, so I want to record >it in the job_info table as it stands today.) >So far, no matter how I've tried to define "salesperson_code," I get >only the value of "0" written to my job_info table. >Here's a snippet of code: ><?php >mysql_connect ("localhost","root"); >mysql_select_db ("bakergrfx"); >$result = mysql_query("SELECT customer_code, customer_name, >salespersons.salesperson_code, > salesperson_name, csr from customer, salespersons > where customer.salesperson_code = salespersons.salesperson_code >and customer_code = '$customer_code'"); >.. >while($row = mysql_fetch_array($result)); } else {print "Sorry, no records >were found!";} >$sql = "INSERT INTO job_info (job_number, customer_code, salesperson_code) >VALUES ('$job_number', '$customer_code', '$salesperson_code') >"; >$result = mysql_query($sql) or die("nope"); >?> >Can anyone help me this morning? Thanks in advance, >Kenn

« previous php.db (#194) next »