Jump to content

Inserting Data


dean7

Recommended Posts

Hi all, I'm attempting to make a text base game, which is going rather well at the moment but ive came across an error on my dealership page.

 

<?php
session_start();
include_once "includes/config.php"; 
include_once "includes/functions.php"; 

$username=$_SESSION['username'];

if(!isset($_SESSION['username']) || !isset($_SESSION['password'])){
header("Location: index.php");
}else{
$fetch_users_data = mysql_fetch_object(mysql_query("SELECT * FROM `users` WHERE username='".$_SESSION['username']."'"));
}

$query=mysql_query("SELECT * FROM users WHERE username='$username' LIMIT 1");
$fetch=mysql_fetch_object($query);

$dealership=mysql_fetch_object(mysql_query("SELECT * FROM buycar WHERE location='$fetch->location'"));
$owner=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$shop->owner'"));

if (strtolower($owner->owner) == strtolower($username)){
include_once"dealerCP.php";
exit();
}

if (strip_tags($_POST['car_button']) && strip_tags($_POST['choose_car'])){
$choose_car = strip_tags($_POST['choose_car']);

if ($choose_car == 1){
$type = "Fiat 500";
$price = "3000";
$mph = "15";
}elseif ($choose_car == 2){
$type = "Austin Mini";
$price = "3500";
$mph = "20";
}elseif ($choose_car == 3){
$type = "BMW M3";
$price = "60000";
$mph = "40";
}elseif ($choose_car == 4){
$type = "Vauxhall Corsa";	
$price = "100000";
$mph = "60";
}elseif ($choose_car == 5){
$type = "Volkswagen Jetta";
$price = "130000";
$mph = "70";
}elseif ($choose_car == 6){
$type = "Ford Mondeo";	
$price = "150000";
$mph = "90";
}elseif ($choose_car == 7){
$type = "Volvo V40";
$price = "200000";
$mph = "105";
}elseif ($choose_car == {
$type = "Peugeot 106";	
$price = "210000";
$mph = "107";
}elseif ($choose_car == 9){
$type = "Vauxhall Nova";
$price = "250000";
$mph = "116";
}elseif ($choose_car == 10){
$type = "Ford Focus";	
$price = "500000";
$mph = "150";
}elseif ($choose_car == 11){
$type = "Mitsubishi Evo 7";	
$price = "750000";
$mph = "170";
}elseif ($choose_car == 12){
$type = "Subaru Impreza";	
$price = "750000";
$mph = "170";
}elseif ($choose_car == 13){
$type = "Lamborghini Gallardo";	
$price = "1500000";
$mph = "200";
}elseif ($choose_car == 14){
$type = "Ferrari F430 Spider";	
$price = "2000000";
$mph = "230";
}elseif ($choose_car == 15){
$type = "Audi R8";
$price = "30000000";
$mph = "250";
// Starting Vans ...	
}elseif ($choose_car == 16){
$type = "Ford Transit";	
$price = "1000000";
$mph = "37";
}elseif ($choose_car == 17){
$type = "Renult Trafic";
$price = "15000000";
$mph = "50";
}elseif ($choose_car == 18){
$type = "Ford Iveco Daily";	
$price = "5000000";
$mph = "65";
}elseif ($choose_car == 19){
$type = "Mercedes Benz Sprinter";	
$price = "10000000";
$mph = "120";
}elseif ($choose_car == 20){
$type = "Renault Master";
$price = "25000000";
$mph = "170";
}
// all cars and vans to buy
if ($price > $fetch->money){
echo "<font color=white>You Don't Have Enouth Money To Buy That Car!";
}elseif ($price <= $fetch->money){
// If user doesnt have enouth money do above thing..
$newmoney=$fetch->money-$price;
if ($shop->owner != "0"){
$per=round($price / 3);
$owner_money = $owner->money + $per;
// Start inserting
mysql_query("UPDATE users SET money='$owner_money' WHERE username='$shop->owner'");
mysql_query("UPDATE buycar SET profit=profit+$per WHERE location='$fetch->location'");
}
mysql_query("UPDATE users SET money='$newmoney' WHERE username='$username'");
mysql_query("INTER INTO buycar SET owner = '$username', car = '$type' AND mph = '$mph'");
echo "<font color=white>You Have Brought Your Selected Car - $type at $mph mph";
mysql_query("INSERT INTO garage WHERE id = '$id', owner = '$username', speed = '$mph', damage = '0%' AND car = '$type'");
}}


?>

 

Everything works on the code i do blive but the only thing is that its not inserting into the data in the database. I carnt see why its not inserting, but can anyone else see why?

 

Sorry about the length of the code but it might all be needed.

Thanks :D

Link to comment
https://forums.phpfreaks.com/topic/192743-inserting-data/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.