Jump to content

adding information to a database


joshgarrod

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.