Mam podstawowe pytanie.
Dlaczego jesli tworze ponizsza tabele z ID auto increment i dodaje do niej rekordy z poziomu php to nie dodaja sie one do tabeli? Gdy mam tabele bez tego ID to rekordy sie dodaja.
CODE
<?php
// Make a MySQL Connection
mysql_connect("localhost", "logme_gracz", "3bj0IQ2R") or die(mysql_error());
mysql_select_db("logme_gracze") or die(mysql_error());
// Create a MySQL table in the selected database
mysql_query("CREATE TABLE TIM(
id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
flag VARCHAR(60) NOT NULL,
name VARCHAR(30) NOT NULL,
function VARCHAR(30) NOT NULL,
age VARCHAR(10) NOT NULL,
location VARCHAR(30) NOT NULL,
activity VARCHAR(60) NOT NULL,
pic VARCHAR(60) NOT NULL,
guid VARCHAR(30) NOT NULL
)")
or die(mysql_error());
echo "Table Created!";
?>
// Make a MySQL Connection
mysql_connect("localhost", "logme_gracz", "3bj0IQ2R") or die(mysql_error());
mysql_select_db("logme_gracze") or die(mysql_error());
// Create a MySQL table in the selected database
mysql_query("CREATE TABLE TIM(
id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
flag VARCHAR(60) NOT NULL,
name VARCHAR(30) NOT NULL,
function VARCHAR(30) NOT NULL,
age VARCHAR(10) NOT NULL,
location VARCHAR(30) NOT NULL,
activity VARCHAR(60) NOT NULL,
pic VARCHAR(60) NOT NULL,
guid VARCHAR(30) NOT NULL
)")
or die(mysql_error());
echo "Table Created!";
?>
CODE
<?php
//This is the directory where images will be saved
$target = "images/";
$target = $target . basename( $_FILES['photo']['name']);
//This gets all the other information from the form
$flag=$_POST['flag'];
$name=$_POST['name'];
$function=$_POST['function'];
$age=$_POST['age'];
$location=$_POST['location'];
$activity=$_POST['activity'];
$pic=($_FILES['photo']['name']);
$guid=$_POST['guid'];
// Connects to your Database
mysql_connect("localhost", "logme_gracz", "3bj0IQ2R") or die(mysql_error()) ;
mysql_select_db("logme_gracze") or die(mysql_error()) ;
//Writes the information to the database
mysql_query("INSERT INTO `TIM` VALUES ('$flag', '$name', '$function', '$age', '$location', '$activity', '$pic', '$guid')") ;
//Writes the photo to the server
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
{
//Tells you if its all ok
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";
}
else {
//Gives and error if its not
echo "Sorry, there was a problem uploading your file.";
}
?>
//This is the directory where images will be saved
$target = "images/";
$target = $target . basename( $_FILES['photo']['name']);
//This gets all the other information from the form
$flag=$_POST['flag'];
$name=$_POST['name'];
$function=$_POST['function'];
$age=$_POST['age'];
$location=$_POST['location'];
$activity=$_POST['activity'];
$pic=($_FILES['photo']['name']);
$guid=$_POST['guid'];
// Connects to your Database
mysql_connect("localhost", "logme_gracz", "3bj0IQ2R") or die(mysql_error()) ;
mysql_select_db("logme_gracze") or die(mysql_error()) ;
//Writes the information to the database
mysql_query("INSERT INTO `TIM` VALUES ('$flag', '$name', '$function', '$age', '$location', '$activity', '$pic', '$guid')") ;
//Writes the photo to the server
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
{
//Tells you if its all ok
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";
}
else {
//Gives and error if its not
echo "Sorry, there was a problem uploading your file.";
}
?>