Page 1 of 2

[SOLVED] mySQL infomation wont submit

Posted: Sun Jul 18, 2004 11:42 am
by bla5e

Code: Select all

<?php 

if (!empty($_POST['submitted']) && $_POST["submitted"] == 1){ 
error_reporting(E_ALL); 
$name = $_POST["name"]; 
$link = $_POST["url"]; 
$infomation = $_POST["infomation"]; 

$dbh=mysql_connect ("localhost", "xnetwham_cc", "pw") or die ('I cannot connect to the database because: ' . mysql_error()); 
mysql_select_db ("xnetwham_cc"); 
$sql = "SELECT * FROM links"; 
mysql_query("INSERT INTO `links` (`id`, `name`, `url`, `infomation`) VALUES ('', '$name', '$link', '$infomation')"); 
$result = mysql_query($sql, $dbh) or die (mysql_error()); 
echo mysql_error(); 
echo "Link submitted!"; 
} 

else 
{ 
//display the form 
?>

it will say "links Submitted", but it wont add it to the database.. i dont get any errors or anyhting... and i checked the datebase's


anyclue whats wrong?



(its new code)

Posted: Sun Jul 18, 2004 11:44 am
by feyd
you have an error in your query syntax:

Code: Select all

mysql_query("INSERT INTO `roster` (`id`, `name`, `name2`, `alias`, `email`, `pos`') VALUES ('', '$name', '$name2', '$alias', '$email', '$pos')");
there's an extra single quote immediately after `pos`

Posted: Sun Jul 18, 2004 11:46 am
by Joe

Code: Select all

if (!empty($_POST&#1111;'submitted']) && $_POST&#1111;"submitted"] == 1)
&#123;
error_reporting(E_ALL);
$name1 = $_POST&#1111;"name"];
$name2= $_POST&#1111;"name2"];
$alias = $_POST&#1111;"alias"];
$email = $_POST&#1111;"email"];
$pos = $_POST&#1111;"pos"];

$dbh=mysql_connect ("localhost", "xnetwham_cc", "cc") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("xnetwham_cc");

$sql = "INSERT INTO `roster` (`id`, `name`, `name2`, `alias`, `email`, `pos`) VALUES ('', '$name', '$name2', '$alias', '$email', '$pos');

$result = mysql_query($sql) or die (mysql_error());

echo "Roster Member submitted!";

Posted: Sun Jul 18, 2004 12:39 pm
by bla5e
thanks.. simple mistakes al the time :(

Posted: Sun Jul 18, 2004 2:58 pm
by bla5e
new code -- same problem

Code: Select all

<?php 

if (!empty($_POST['submitted']) && $_POST["submitted"] == 1){ 
error_reporting(E_ALL); 
$name = $_POST["name"]; 
$link = $_POST["url"]; 
$infomation = $_POST["infomation"]; 

$dbh=mysql_connect ("localhost", "xnetwham_cc", "pw") or die ('I cannot connect to the database because: ' . mysql_error()); 
mysql_select_db ("xnetwham_cc"); 
$sql = "SELECT * FROM links"; 
mysql_query("INSERT INTO `links` (`id`, `name`, `url`, `infomation`) VALUES ('', '$name', '$link', '$infomation')"); 
$result = mysql_query($sql, $dbh) or die (mysql_error()); 
echo mysql_error(); 
echo "Link submitted!"; 
} 

else 
{ 
//display the form 
?>

Posted: Sun Jul 18, 2004 3:06 pm
by tim
why do u even query the $sql? It seems you dont even use it

Posted: Sun Jul 18, 2004 3:13 pm
by feyd
try moving the mysql_error() to the insert query's line.. like you have your connect call..

Posted: Sun Jul 18, 2004 4:03 pm
by bla5e
tim wrote:why do u even query the $sql? It seems you dont even use it
$result = mysql_query($sql, $dbh) or die (mysql_error());

Posted: Sun Jul 18, 2004 4:10 pm
by bla5e
feyd wrote:try moving the mysql_error() to the insert query's line.. like you have your connect call..
still no errors

Posted: Sun Jul 18, 2004 4:21 pm
by feyd
if you echo mysql_affected_rows() after the insert, what does it say?

Posted: Sun Jul 18, 2004 4:25 pm
by bla5e
-1Link submitted!

Posted: Sun Jul 18, 2004 4:28 pm
by feyd
[php_man]mysql_affected_rows[/php_man] wrote:If the last query failed, this function will return -1.
so, just to make sure, you have this now?

Code: Select all

//.....
mysql_query("INSERT INTO `links` (`id`, `name`, `url`, `infomation`) VALUES ('', '$name', '$link', '$infomation')") or die(mysql_error());
//..........

Posted: Sun Jul 18, 2004 4:34 pm
by bla5e
Notice: Undefined variable: link in linksubmit.php on line 49
Unknown column 'infomation' in 'field list'
Line 49:
mysql_query("INSERT INTO `links` (`id`, `name`, `url`, `infomation`) VALUES ('', '$name', '$link', '$infomation')") or die(mysql_error());

Posted: Sun Jul 18, 2004 4:37 pm
by feyd
are you sure it's infomation and not information? :)

Posted: Sun Jul 18, 2004 4:37 pm
by bla5e
lol nvm-- i had infomation spelled different then in the mysql db