Jump to content

trouble with script


joshgarrod

Recommended Posts

Hi everyone, I am having some trouble with this script, it used to work fine until i changed servers now it doesnt. basically this script adds articles to different tables of my database. but it does work anymore. when i load the page it says that an article has been submitted but it hasnt. can anypone see what is wrong? below is mycode and notices/errors I am receiving. thanks in advance.

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Add Categories</title>
<style type="text/css">
a{ color:black; text-decoration:none;}
	a:hover {color:#809c00; text-decoration:none;}

.smalblk {font-size: 7pt; font-family: Verdana, Arial, Helvetica, sans-serif; text-align: left; color: #252525;}
.smalblk a:link {color: #252525; text-decoration:none;}
.smalblk a:visited {color: #252525; te xt-decoration:none;}
.smalblk a:active {color: #252525; text-decoration:none;}
.smalblk a:hover {color: #809c00; text-decoration:none;}
.smalblkbold {font-size: 7pt; font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; text-align: left; color: #252525;}
.smalblkbold a:link {color: #252525; text-decoration:none;}
.smalblkbold a:visited {color: #252525; text-decoration:none;}
.smalblkbold a:active {color: #252525; text-decoration:none;}
.smalblkbold a:hover {color: #809c00; text-decoration:none;}
.smalwht {font-size: 7pt; font-family: Verdana, Arial, Helvetica, sans-serif; text-align: left; color: #ffffff;}
.smalwht a:link {color: #ffffff; text-decoration:none;}
.smalwht a:visited {color: #ffffff; text-decoration:none;}
.smalwht a:active {color: #ffffff; text-decoration:none;}
.smalwht a:hover {color: #809c00; text-decoration:none;}
.wht8 {font-size: 8pt; font-family: Verdana, Arial, Helvetica, sans-serif; text-align: left; color: #ffffff;}
.wht8 a:link {color: #ffffff; text-decoration:none;}
.wht8 a:visited {color: #ffffff; text-decoration:none;}
.wht8 a:active {color: #ffffff; text-decoration:none;}
.wht8 a:hover {color: #809c00; text-decoration:none;}
.wht10 {font-size: 10pt; font-family: Verdana, Arial, Helvetica, sans-serif; text-align: right; color: #ffffff;}
.wht10 a:link {color: #ffffff; text-decoration:none;}
.wht10 a:visited {color: #ffffff; text-decoration:none;}
.wht10 a:active {color: #ffffff; text-decoration:underline;}
.wht10 a:hover {color: #809c00; text-decoration:none;}
.wht12 {font-size: 12pt; font-family: Verdana, Arial, Helvetica, sans-serif; text-align: left; color: #ffffff;}
.wht12 a:link {color: #ffffff; text-decoration:none;}
.wht12 a:visited {color: #ffffff; text-decoration:none;}
.wht12 a:active {color: #ffffff; text-decoration:none;}
.wht12 a:hover {color: #809c00; text-decoration:underline;}
.wht14 {font-size: 14pt; font-family: Verdana, Arial, Helvetica, sans-serif; text-align: left; color: #ffffff;}
.wht14 a:link {color: #ffffff; text-decoration:none;}
.wht14 a:visited {color: #ffffff; text-decoration:none;}
.wht14 a:active {color: #ffffff; text-decoration:none;}
.wht14 a:hover {color: #809c00; text-decoration:none;}
.blu14 {font-size: 14pt; font-family: Verdana, Arial, Helvetica, sans-serif; text-align: left; color: #809c00;}
.blu14 a:link {color: #809c00; text-decoration:none;}
.blu14 a:visited {color: #809c00; text-decoration:none;}
.blu14 a:active {color: #809c00; text-decoration:none;}
.blu14 a:hover {color: #809c00; text-decoration:none;}
.wht18 {font-size: 18pt; font-family: Verdana, Arial, Helvetica, sans-serif; text-align: left; color: #ffffff;}
.wht18 a:link {color: #ffffff; text-decoration:none;}
.wht18 a:visited {color: #ffffff; text-decoration:none;}
.wht18 a:active {color: #ffffff; text-decoration:none;}
.wht18 a:hover {color: #809c00; text-decoration:none;}
.smalblu {font-size: 8pt; font-family: Verdana, Arial, Helvetica, sans-serif; text-align: left; color: #809c00;}
.smalblu a:link {color: #809c00; text-decoration:none;}
.smalblu a:visited {color: #809c00; text-decoration:none;}
.smalblu a:active {color: #809c00; text-decoration:none;}
.smalblu a:hover {color: #809c00; text-decoration:none;}
.productbold {font-size: 8pt; font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; text-align: left; color: #252525;}
.productbold a:link {color: #252525; text-decoration:none;}
.productbold a:visited {color: #252525; text-decoration:none;}
.productbold a:active {color: #252525; text-decoration:none;}
.productbold a:hover {color: #809c00; text-decoration:none;}
.product {font-size: 8pt; font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: normal; text-align: left; color: #252525;}
.product a:link {color: #252525; text-decoration:none;}
.product a:visited {color: #252525; text-decoration:none;}
.product a:active {color: #252525; text-decoration:none;}
.product a:hover {color: #809c00; text-decoration:none;}
.ordercode {font-size: 7pt; font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: normal; text-align: left; color: #252525;}
.ordercode a:link {color: #252525; text-decoration:none;}
.ordercode a:visited {color: #252525; text-decoration:none;}
.ordercode a:active {color: #252525; text-decoration:none;}
.ordercode a:hover {color: #809c00; text-decoration:none;}
.featuredblu {font-size: 9pt; font-family: Verdana, Arial, Helvetica, sans-serif; text-align: left; color: #809c00;}
.featuredblu a:link {color: #809c00; text-decoration:none;}
.featuredblu a:visited {color: #809c00; text-decoration:none;}
.featuredblu a:active {color: #809c00; text-decoration:none;}
.featuredblu a:hover {color: #809c00; text-decoration:none;}
.menu {font-size: 10pt; font-family: Verdana, Arial, Helvetica, sans-serif; text-align: center; color: #252525;}
.menu a:link {color: #252525; text-decoration:none;}
.menu a:visited {color: #252525; text-decoration:none;}
.menu a:active {color: #252525; text-decoration:none;}
.menu a:hover {color: #809c00; text-decoration:none;}
.featuredblubold {font-size: 9pt; font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; text-align: left; color: #809c00;}
.featuredblubold a:link {color: #809c00; text-decoration:none;}
.featuredblubold a:visited {color: #809c00; text-decoration:none;}
.featuredblubold a:active {color: #809c00; text-decoration:none;}
.featuredblubold a:hover {color: #809c00; text-decoration:none;}
.welcome {font-size: 8pt; font-family: Verdana, Arial, Helvetica, sans-serif; text-align: left; color: #252525;}
.welcome a:link {color: #252525; text-decoration:none;}
.welcome a:visited {color: #252525; text-decoration:none;}
.welcome a:active {color: #252525; text-decoration:none;}
.welcome a:hover {color: #809c00; text-decoration:none;}
.border {border: 2px solid #809c00;}
.borderbottom {border-bottom: 2px solid #809c00; font-size: 8pt; font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; text-align: center; color: #252525;}
.mainborder {border-right: 2px solid #809c00;}
</style>
</head>

<body>
   <font face="Arial, Helvetica, sans-serif">
<?php
    $usr = "username";
    $pwd = "pword";
    $db = "db";
    $host = "ipofserver";

    # connect to database
    $cid = mysql_connect($host,$usr,$pwd);
    if (!$cid) { echo("ERROR: " . mysql_error() . "\n");    }

?>
   </font>
<P>Add Article </P>
<P>To add an article please fill in the 'Article name' field and then select the category to place it in from the 'Category' drop down, next type the text for the article in the 'Article text' box, finally click the 'Add Article' button. </P>
<font face="Arial, Helvetica, sans-serif">
   <?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>New article <b>'$Article'</b> added to <b>'$Catname'</b></P>\n");

    }

?>
</font>
<FORM NAME="fa" ACTION="addArticle.php" METHOD="POST">
  <TABLE width="392">
<TR>
  <TD width="133"><font face="Arial, Helvetica, sans-serif"><B>Article name :</B> </font></TD><TD width="247"><font face="Arial, Helvetica, sans-serif">
    <INPUT NAME="Article" TYPE="text" id="Article" SIZE=40>
  <label></label>
  </font></TD>
</TR>
<tr>
<td><font face="Arial, Helvetica, sans-serif"><b>Category:</b></font></td>
<td><font face="Arial, Helvetica, sans-serif">
  <select name="Catname" id="Catname">
    <option value="Animals">Animals</option>
    <option value="Books">Books</option>
    <option value="Caravanning and Motorhoming">Caravanning and Motorhoming</option>
    <option value="Cars">Cars</option>
    <option value="Computing and IT">Computing and IT</option>
    <option value="Culture">Culture</option>
    <option value="Film">Film</option>
    <option value="Finance">Finance</option>
    <option value="Food and Drink">Food and Drink</option>
    <option value="Gaming">Gaming</option>
    <option value="Hair">Hair</option>
    <option value="Health and Beauty">Health and Beauty</option>
    <option value="History">History</option>
    <option value="Home and Garden">Home and Garden</option>
    <option value="Music">Music</option>
    <option value="News">News</option>
    <option value="Shopping">Shopping</option>
    <option value="Sport">Sport</option>
    <option value="Television">Television</option>
            </select>
</font></td>
</tr>
<tr>
<td valign="top"><font face="Arial, Helvetica, sans-serif"><b>Article Text:</b></font></td>
<td><label>
  <textarea name="Text" cols="100" rows="50" id="Text"></textarea>
</label></td>
</tr>
<TR>
  <TH COLSPAN=2><font face="Arial, Helvetica, sans-serif">
    <input name="submit" type="submit" value="Add Article" />
  </font></TH>
</TR>
</TABLE>
</FORM>


   <font face="Arial, Helvetica, sans-serif">
   <?    mysql_close($cid); ?>
   </font>
</BODY>
</HTML>

</body>
</html>

Notice: Undefined variable: Article in e:\domains\e\site\user\htdocs\admin\addArticle.php on line 124

 

Notice: Undefined variable: Text in e:\domains\e\site\user\htdocs\admin\addArticle.php on line 125

 

Notice: Undefined variable: Catname in e:\domains\e\site\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\site\user\htdocs\admin\addArticle.php on line 141

Link to comment
https://forums.phpfreaks.com/topic/97620-trouble-with-script/
Share on other sites

no its the fact that u have these variables you are working on before defining them and odds are your script is written to be dependent on registered globals so $Articles should be rewritten to $_GET['Articles'];  which should solve all the issues

<?php
phpinfo();
?>

can give u the status of registered globals if its off you know the fix

Link to comment
https://forums.phpfreaks.com/topic/97620-trouble-with-script/#findComment-499479
Share on other sites

it means any index in the superglobal arrays of $_SESSION, $_REQUEST, $_SERVER, $_POST, $_GET are placed in the global scope

i.e

$_POST['var'] = "Fish";

 

the variable of $var is also set to the value Fish

 

its a large security issue with crossing and shouldn't be used

 

Link to comment
https://forums.phpfreaks.com/topic/97620-trouble-with-script/#findComment-499485
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.