Hi Everybody,
I am trying to make a php page for my database. I connected successfully to the database but the data won’t post to the database and I got an error that my query was empty. I’ve been learning videos of php tuts on youtube. I’m definitely a newbie but I have sufficient knowledge in HTML.
Please, help me with my codes. Show me my errors so that I can learn from them.
[php]<?php
define (‘DB_NAME’,‘a1399639_idea’);
define (‘DB_USER’,‘a1399639_idea’);
define (‘DB_PASSWORD’,‘limppimp1’);
define (‘DB_HOST’,‘mysql1.000webhost.com’);
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if (!$link) {
die('Could not connect: ’ . mysql_error());
}
$db_selected = mysql_select_db(DB_NAME, $link);
if (!db_selected) {
die('Can\t use ’ . DB_NAME . ': ’ . mysql_error());
}
echo ‘Connected successfully’;
$value1 = $_POST [‘Date1’];
$value2 = $_POST [‘Student’];
$value3 = $_POST [‘Start’];
$value4 = $_POST [‘Current’];
$value5 = $_POST [‘Grammar’];
$value6 = $_POST [‘Speaking’];
$value7 = $_POST [‘Comprehension’];
$value8 = $_POST [‘Vocabulary’];
$value9 = $_POST [‘Pronunciation’];
$value10 = $_POST [‘Comment’];
$value11 = $_POST [‘Teacher’];
$value12 = $_POST [‘Date2’];
$sql = “INSERT INTO Eval (Date1, Student, Start, Current, Grammar, Speaking, Comprehension, Vocabulary, Pronunciation, Comment, Teacher, Date2) VALUES (’$value1’, ‘$value2’, ‘$value3’, ‘$value4’, ‘$value5’, ‘$value6’, ‘$value7’, ‘$value8’, ‘$value9’, ‘$value10’, ‘$value11’ ,’$value12’)”;
if (!mysql_query($sq1)) {
die('Error: ’ . mysql_error());
}
mysql_close();
?>
[/php]
Your replies are very much appreciated.
