[ djovan01 @ 15.12.2006. 13:52 ] @
Kako izvrisiti ubacivanje podataka u razlicite tabele u okviru jedne baze podataka. Mislila sam da samo se dadaju vise insert comandi. Probala sam i pisalo je da je sve procesovano medjutim u tabelama nema nista. Ako mozete da pogledate moj kod i kazete mi gde sam pogresila. Hvala :)

Code:
<?php
$con = mysql_connect("localhost","danijela","1234");

if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

$company_name = addslashes($_POST['name']);
$contact = addslashes($_POST['contact']);
$phone = addslashes($_POST['phone']); 
$email = addslashes($_POST['email']); 
$location = addslashes($_POST['location']); 
$start_date = addslashes($_POST['start_date']);
$hours = addslashes($_POST['hours']);  
$ceiling = addslashes($_POST['ceiling']);
$floor = addslashes($_POST['floor']); 
$yes1 = addslashes($_POST['yes']);
$no1 = addslashes($_POST['no']); 
$dock_size = addslashes($_POST['dock_size']);
$yes2 = addslashes($_POST['yes2']);
$no2 = addslashes($_POST['no2']);
$door_size = addslashes($_POST['door_size']);
$yes3 = addslashes($_POST['yes3']);
$no3 = addslashes($_POST['no3']);
$crane_size = addslashes($_POST['crane_size']);
$select = addslashes($_POST['select']);
$b_voltage = addslashes($_POST['b_voltage']);
$b_amperage = addslashes($_POST['b_amperage']);
$select2 = addslashes($_POST['select2']);
$p_voltage = addslashes($_POST['p_voltage']);
$p_amperage = addslashes($_POST['p_amperage']);
$equ_amp = addslashes($_POST['equ_amp']);
$source = addslashes($_POST['source']);
$machine_manuf = addslashes($_POST['machine_manuf']);
$serial = addslashes($_POST['serial']);
$machine_wght = addslashes($_POST['machine_wght']);
$d_ht = addslashes($_POST['d_ht']);
$d_wt = addslashes($_POST['d_wt']);
$d_lt = addslashes($_POST['d_lt']);
$address_from = addslashes($_POST['address_from']);
$city_from = addslashes($_POST['city_from']);
$state_from = addslashes($_POST['state_from']);
$address_to = addslashes($_POST['address_to']);
$city_to = addslashes($_POST['city_to']);
$state_to = addslashes($_POST['state_to']);
$additional = addslashes($_POST['additional']);
$soil = addslashes($_POST['soil']);
$size_depth = addslashes($_POST['size_depth']);
$cad_yes = addslashes($_POST['cad_yes']);
$cad_no = addslashes($_POST['cad_no']);
$dimensions = addslashes($_POST['cad_no']);
$p_size = addslashes($_POST['p_size']);
$run_length = addslashes($_POST['run_length']);
$materials = addslashes($_POST['run_length']);
$substance = addslashes($_POST['substances']);
$lift_yes = addslashes($_POST['lift_yes']);
$lift_no = addslashes($_POST['lift_no']);
$lift_size = addslashes($_POST['lift_size']);
$scissors = addslashes($_POST['scissors']);
$boom = addslashes($_POST['boom']);




$insert1=("INSERT INTO customer (name, contact, phone, email, location, start_date) VALUES($name, $contact, $phone, $email, $location, $start_date) ");
$insert2=("INSERT INTO facility (hours, ceiling, floor, yes, no, dock_size, yes2, no2, door_size, yes3, no3, crane_size) VALUES($hours, $ceiling, $floor, $yes, $no, $dock_size, $yes2, $no2, $door_size, $yes3, $no3, $crane_size)");
$insert3=("INSERT INTO electrical (select, b_voltage, b_amperage, select2, p_voltage, p_amperage, equ_amp, distance) VALUES($select, $b_voltage, $b_amperage, $select2, $p_voltage, $p_amperage, $equ_amp, $distance)");
$insert4=("INSERT INTO rigging (machine_manuf, serial, machine_wght, d_ht, d_wt, d_lt, address_from, city_from, state_from, address_to, city_to, state_to, additional) VALUES ($machine_manuf, $serial, $machine_wght, $d_ht, $d_wt, $d_lt, $address_from, $city_from, $state_from, $address_to, $city_to, $state_to, $additional)");
$insert5=("INSERT INTO foundations (soil, size_depth, cad_yes, cad_no, dimensions) VALUES ($soil, $size_depth, $cad_yes, $cad_no, $dimensions)");
$insert6=("INSERT INTO piping (p_size, run_length, materials, substance, lift_yes, lift_no, lift_size, scissors, boom) VALUE (p_size, run_length, materials, substance, lift_yes, lift_no, lift_size, scissors, boom)");

echo "Data has been stored";

mysql_close($con)
?>


[Ovu poruku je menjao Nemanja Avramović dana 16.12.2006. u 08:44 GMT+1]
[ Milan Andjelkovic @ 15.12.2006. 15:05 ] @
Ovaj kod je ispravan sintaksno, ali logički nije. Naime, sve promenljive će dobiti vrednosti upita koji treba da se izvrše, ali oni nikada neće biti izvršeni jer nigde nisi rekla da oni zapravo treba da se izvrše :) Potraži malo kako se izvršava mysql query iz php-a...
[ Dragan BL @ 15.12.2006. 15:42 ] @
Evo ti jedno rjesenje:

Code:
$insert1=mysql_query("INSERT INTO customer (name, contact, phone, email, location, start_date) VALUES($name, $contact, $phone, $email, $location, $start_date) ");
if (!$insert1) {
   die('Invalid query: ' . mysql_error());
}

$insert2=mysql_query("INSERT INTO facility (hours, ceiling, floor, yes, no, dock_size, yes2, no2, door_size, yes3, no3, crane_size) VALUES($hours, $ceiling, $floor, $yes, $no, $dock_size, $yes2, $no2, $door_size, $yes3, $no3, $crane_size)");
if (!$insert2) {
   die('Invalid query: ' . mysql_error());
}

$insert3=mysql_query("INSERT INTO electrical (select, b_voltage, b_amperage, select2, p_voltage, p_amperage, equ_amp, distance) VALUES($select, $b_voltage, $b_amperage, $select2, $p_voltage, $p_amperage, $equ_amp, $distance)");
if (!$insert3) {
   die('Invalid query: ' . mysql_error());
}

$insert4=mysql_query("INSERT INTO rigging (machine_manuf, serial, machine_wght, d_ht, d_wt, d_lt, address_from, city_from, state_from, address_to, city_to, state_to, additional) VALUES ($machine_manuf, $serial, $machine_wght, $d_ht, $d_wt, $d_lt, $address_from, $city_from, $state_from, $address_to, $city_to, $state_to, $additional)");
if (!$insert4) {
   die('Invalid query: ' . mysql_error());
}

$insert5=mysql_query("INSERT INTO foundations (soil, size_depth, cad_yes, cad_no, dimensions) VALUES ($soil, $size_depth, $cad_yes, $cad_no, $dimensions)");
if (!$insert5) {
   die('Invalid query: ' . mysql_error());
}

$insert6=mysql_query("INSERT INTO piping (p_size, run_length, materials, substance, lift_yes, lift_no, lift_size, scissors, boom) VALUE (p_size, run_length, materials, substance, lift_yes, lift_no, lift_size, scissors, boom)");
if (!$insert6) {
   die('Invalid query: ' . mysql_error());
}

Nadam se da sada shvatas u cemu je bila greska. Falilo ti je "mysql_query". Ima jos resenja, ali ovo je jedno od njih. Nadam se da ces shavtiti u uspjesno rijesiti svoj problem.

mysql_query -- Send a MySQL query

[Ovu poruku je menjao Nemanja Avramović dana 16.12.2006. u 08:45 GMT+1]