Page 1 of 1
help with php mysql connection
Posted: Wed Feb 07, 2007 7:23 pm
by sublevel4
I am having a problem with the following code. I am moving servers and it worked on the old one but dies on the new one. Anyone have any ideas as to why this might be?
Code: Select all
if ($username != ""){
if ($username == "xxx" && $password == "xxx"){
mysql_pconnect ("localhost", "username", "password");
mysql_select_db ("database");
$query = "INSERT INTO blog_entries (date,title,entry) VALUES (NOW(), '" . $title . "', '" . $entry . "')";
$result = mysql_query($query) or die("query failure ----- $query");
$status = "Entry has been made";
}else{
$status = "Entry has failed";
}
}
Posted: Wed Feb 07, 2007 7:33 pm
by feyd
I would bet that register_globals is turned off (and rightly so) on the "new" server.
Posted: Wed Feb 07, 2007 8:33 pm
by sublevel4
You are correct i should have been more clear.
the code in the page
Code: Select all
<?php
$status = "";
$username = $_POST['username'];
$password = $_POST['password'];
$title = $_POST['title'];
$entry = $_POST['entry'];
if ($username != ""){
if ($username == "xxx" && $password == "xxx"){
mysql_pconnect ("localhost", "username", "pw");
mysql_select_db ("database");
$query = "INSERT INTO blog_entries (date,title,entry) VALUES (NOW(), '" . $title . "', '" . $entry . "')";
$result = mysql_query($query) or die("query failure ----- $query");
$status = "Entry has been made";
}else{
$status = "Entry has failed";
}
}
?>
the resulting page is
query failure ----- INSERT INTO blog_entries (date,title,entry) VALUES (NOW(), 'new server', 'this is a test of the new server. this is only a test')
so i am getting the variables from the form it is just not working.
Posted: Wed Feb 07, 2007 8:46 pm
by feyd
Without seeing the output from
mysql_error() I would have to guess that "date" is being rejected as it is a reserved word. It is recommended to never use reserved words for column, table or database names.
http://dev.mysql.com/doc/refman/5.1/en/ ... words.html
Posted: Wed Feb 07, 2007 9:17 pm
by sublevel4
Feyd, i appoligize. I am a moron. I had two letters in the database name transposed. I have not coded is so long i am making stupid mistakes.
Posted: Thu Feb 08, 2007 9:21 am
by feyd
sublevel4 wrote:Feyd, i appoligize. I am a moron. I had two letters in the database name transposed. I have not coded is so long i am making stupid mistakes.
Forty lashes for sublevel4!

sublevel4
