PHP add script wont work: need experts like kwitko&keeb

jmoney3457jmoney3457 Maine
edited December 2008 in Internet & Media
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]

Comments

  • LincLinc Owner Detroit Icrontian
    edited December 2008
    This could literally be 100 different things. I have no idea what your tables look like or much about what's going on here. You're saying the script executes without any errors, but doesn't add the record?

    Try echo mysql_error(); to see what MySQL says about it.
  • jmoney3457jmoney3457 Maine
    edited December 2008
    Keebler wrote:
    You're saying the script executes without any errors, but doesn't add the record?

    exactly..can you see any typos or anything wrong w my queries etc?
  • jmoney3457jmoney3457 Maine
    edited December 2008
    fixed it..thx:) also i'm sorry if i upset you keeb & kwit:confused:
Sign In or Register to comment.