By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,747 Members | 2,039 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,747 IT Pros & Developers. It's quick & easy.

PHP and sql problem

P: n/a
Please look at the code and if you can find my mistake.

Please tell me why
customerid is saved with wrong value the workorder table

Instead of the correct value I get '0"

When I try to display the $customerid value before the querry
I have the correct value for example 1 but even that in the
database I still have 0.

Whats wrong???

Thanks

<?php
$addcustomer = "insert into addressindex(name,address,city,state,zipcode,email ,phone,ss,cc,exp,notes) values ('$name','$address','$city','$state','$zipcode','$ email','$phone','$ss','$cc','$exp','$notes')";
$addworkorder = "insert into workorder(customerid,date,time,service,due,special ,extrawork,due2,company,installer,total) values ('$customerid','$date','$time','$service','$due',' $special','$extrawork','$due2','$company','$instal ler','$total')";
$getdata = "select * from addressindex where name = '$name' or customerid = '$customerid'";

$rs = mysql_query($getdata);

if(( $rs ) && ( mysql_errno() == 0 )) {

// query was successful
if( mysql_num_rows( $rs ) > 0 ) {

$result2 = mysql_query($addworkorder);

if ($result2) {
include '../login/print.php';
} else {
include '../login/error-broken.php';}

} else {

$result = mysql_query($addcustomer);

echo $customerid;

$getid = "select customerid from addressindex where name = '$name'";
$sqgetid = mysql_query($getid);
$customerid = mysql_result($sqgetid,0);

echo $customerid;

//now i do a querry and even $customerid is 1 here now
it is saved under 0
$result2 = mysql_query($addworkorder);

if ($result && $result2) {
include '../login/print.php';
} else {
include '../login/error-broken.php';}

}
} else {
include '../login/error-broken.php';}

//Close connection with MySQL
MySQL_close()
?>

Jul 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

On 29-Aug-2003, "Bartosz Wegrzyn" <bl*******@lexon.ws> wrote:
Please look at the code and if you can find my mistake.

Please tell me why
customerid is saved with wrong value the workorder table

Instead of the correct value I get '0"

When I try to display the $customerid value before the querry
I have the correct value for example 1 but even that in the
database I still have 0.

Whats wrong???

Thanks

<?php
$addcustomer = "insert into
addressindex(name,address,city,state,zipcode,email ,phone,ss,cc,exp,notes)
values
('$name','$address','$city','$state','$zipcode','$ email','$phone','$ss','$cc','$exp','$notes')";
$addworkorder = "insert into
workorder(customerid,date,time,service,due,special ,extrawork,due2,company,installer,total)
values
('$customerid','$date','$time','$service','$due',' $special','$extrawork','$due2','$company','$instal ler','$total')";
$getdata = "select * from addressindex where name = '$name' or customerid
= '$customerid'";


Please cross-post!!!

It looks like you are inserting customerid into workorder but trying
retrieving it from addressindex.

--
Tom Thackrey
www.creative-light.com
Jul 16 '05 #2

P: n/a
Thats is correct !

Thats what I want to do.

On my main form I do enter all the data for customer and work order.

Customer is is created automaticaly.

I do not know how to add that id to my work order so I
query what is that id and than I try to add it.

On Fri, 29 Aug 2003 19:31:12 +0000, Tom Thackrey wrote:

On 29-Aug-2003, "Bartosz Wegrzyn" <bl*******@lexon.ws> wrote:
Please look at the code and if you can find my mistake.

Please tell me why
customerid is saved with wrong value the workorder table

Instead of the correct value I get '0"

When I try to display the $customerid value before the querry
I have the correct value for example 1 but even that in the
database I still have 0.

Whats wrong???

Thanks

<?php
$addcustomer = "insert into
addressindex(name,address,city,state,zipcode,email ,phone,ss,cc,exp,notes)
values
('$name','$address','$city','$state','$zipcode','$ email','$phone','$ss','$cc','$exp','$notes')";
$addworkorder = "insert into
workorder(customerid,date,time,service,due,special ,extrawork,due2,company,installer,total)
values
('$customerid','$date','$time','$service','$due',' $special','$extrawork','$due2','$company','$instal ler','$total')";
$getdata = "select * from addressindex where name = '$name' or customerid
= '$customerid'";


Please cross-post!!!

It looks like you are inserting customerid into workorder but trying
retrieving it from addressindex.


Jul 16 '05 #3

P: n/a
On Fri, 29 Aug 2003 18:00:41 GMT
"Bartosz Wegrzyn" <bl*******@lexon.ws> wrote:
Please look at the code and if you can find my mistake.

Please tell me why
customerid is saved with wrong value the workorder table

Instead of the correct value I get '0"

When I try to display the $customerid value before the querry
I have the correct value for example 1 but even that in the
database I still have 0.

Whats wrong???

Thanks

<?php
$addcustomer = "insert into
addressindex(name,address,city,state,zipcode,email ,phone,ss,cc,exp,no
tes) values
('$name','$address','$city','$state','$zipcode','$ email','$phone','$s
s','$cc','$exp','$notes')";$addworkorder = "insert into
workorder(customerid,date,time,service,due,special ,extrawork,due2,com
pany,installer,total) values
('$customerid','$date','$time','$service','$due',' $special','$extrawo
rk','$due2','$company','$installer','$total')";$ge tdata = "select *
from addressindex where name = '$name' or customerid = '$customerid'";


<SNIP>

Just a thought:

Is customerid declared as an integer in the MySQL table ?
You are inserting it as a char value.

Matt
--
Quispiam Power Computing | "There are two major products that come out
Pendle Hill, Australia | of Berkeley: LSD and UNIX. We don't believe
+61 2 9631 7719 | this to be a coincidence. "
www.quispiam.com | - Jeremy S. Anderson
Jul 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.