joshgarrod Posted April 1, 2008 Share Posted April 1, 2008 Hello. I have a problem with afew scripts of mine that I had working absolutely fine. Then I changed hosting and got a new database set up and changed all the appropriate details in the script to point at the new new database, but they don't work now. Could someone please help me. I have looked on Google for possible fixes but I can't find anything. It seems bizar to me that it would work on one server but not another. Anyway, I have posted the code beow, really appreciate it. thanks in advance. Errors/notices I am seeing: Notice: Undefined variable: Article in e:\domains\e\mysite\user\htdocs\admin\addArticle.php on line 124 Notice: Undefined variable: Text in e:\domains\e\mysite\user\htdocs\admin\addArticle.php on line 125 Notice: Undefined variable: Catname in e:\domains\e\mysite\user\htdocs\admin\addArticle.php on line 128 ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(Article, Text) VALUES ('','')' at line 1 INSERT INTO (Article, Text) VALUES ('','') Notice: Undefined variable: Catname in e:\domains\e\mysite\user\htdocs\admin\addArticle.php on line 141 And my code: <?php # this is processed when the form is submitted # back on to this page (POST METHOD) if ($_SERVER['REQUEST_METHOD']) { # double-up apostrophes $Article = str_replace("'","''",$Article); $Text = str_replace("'","''",$Text); # setup SQL statement $SQL = " INSERT INTO $Catname "; $SQL = $SQL . " (Article, Text) VALUES "; $SQL = $SQL . " ('$Article','$Text') "; #execute SQL statement $result = mysql_db_query($db,"$SQL",$cid); $ID=mysql_insert_id(); # check for error if (!$result) { echo("ERROR: " . mysql_error() . "\n$SQL\n"); } echo ("<P><span class=product>New article </span><b><span class=productbold>'$Article'</span></b><span class=product> added to </span><b><span class=productbold>'$Catname'</span></b></P>\n"); } ?> Link to comment https://forums.phpfreaks.com/topic/99050-adding-information-to-a-database/ Share on other sites More sharing options...
Barand Posted April 1, 2008 Share Posted April 1, 2008 see http://us2.php.net/manual/en/security.globals.php Link to comment https://forums.phpfreaks.com/topic/99050-adding-information-to-a-database/#findComment-506929 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.