PHP add script wont work: need experts like kwitko&keeb
jmoney3457
Maine
so i have it customers can click a purchase link & it takes the fields from customer & vehicles table & adds it to an empty purchases table but its not working (not adding to purchase table) heres my code
[PHP]<?
session_start();
if (($_SESSION[auth]='yes') and ($_SESSION[level]==3)) {
include 'connect.inc.php';
$id=$_GET[id];
$query="SELECT * FROM vehicles,customers";
$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
while ($i <$num) {
$vid=mysql_result($result,$i,"vid");
$cid=mysql_result($result,$i,"cid");
$year=mysql_result($result,$i,"year");
$make=mysql_result($result,$i,"make");
$model=mysql_result($result,$i,"model");
$price=mysql_result($result,$i,"price");
$fname=mysql_result($result,$i,"fname");
$lname=mysql_result($result,$i,"lname");
$i++;
}
$query="insert into purchases (vid,cid,year,make,model,price,fname,lname) values('$vid','$cid','$year','$make','$model','$price','$fname','$lname')";
$result=mysql_query($query);
mysql_close();
echo "you have just bought $year $make $model for $price";
}
else { header('Location:index.php');
}
?> [/PHP]
[PHP]<?
session_start();
if (($_SESSION[auth]='yes') and ($_SESSION[level]==3)) {
include 'connect.inc.php';
$id=$_GET[id];
$query="SELECT * FROM vehicles,customers";
$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
while ($i <$num) {
$vid=mysql_result($result,$i,"vid");
$cid=mysql_result($result,$i,"cid");
$year=mysql_result($result,$i,"year");
$make=mysql_result($result,$i,"make");
$model=mysql_result($result,$i,"model");
$price=mysql_result($result,$i,"price");
$fname=mysql_result($result,$i,"fname");
$lname=mysql_result($result,$i,"lname");
$i++;
}
$query="insert into purchases (vid,cid,year,make,model,price,fname,lname) values('$vid','$cid','$year','$make','$model','$price','$fname','$lname')";
$result=mysql_query($query);
mysql_close();
echo "you have just bought $year $make $model for $price";
}
else { header('Location:index.php');
}
?> [/PHP]
0
Comments
Try echo mysql_error(); to see what MySQL says about it.
exactly..can you see any typos or anything wrong w my queries etc?