Moved servers, code no longer works. Help please!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Citizen
Forum Contributor
Posts: 300
Joined: Wed Jul 20, 2005 10:23 am

Moved servers, code no longer works. Help please!

Post by Citizen »

Hello, I created this quick script to add an entry to my database. I moved servers and the code no longer works.

My new server is running php version 4.4.2 and mysql version 4.0.27-standard.

Is it a problem with my code or do I need to update the new server's version of php?

Code: Select all

<?php

include("../../inc/config/connect.inc");

include("header.php");

protect();

if (member_types2($VAR[4]) != '0') {
	echo "<p>Sorry, but you must be logged in as an administrator to view this area.";
}
else
{
include("menu.php");

if ($submit) {
$catname = strip_tags($catname);
$catname = trim($catname);
$displayorder = strip_tags($displayorder);
$displayorder = trim($displayorder);
	if ($catname == "") {
echo "Please enter a category name.";
	}
	else if ($displayorder == "") {
echo "Please enter a valid display order.";
	}
	else {
$sql = "INSERT INTO `arcade_categories` (catname, displayorder) VALUES ('$catname', '$displayorder')";
$result=mysql_query($sql) or die(mysql_error());
echo "<p>Congratulations, your arcade category has been entered!";
	}
}
echo"
<h2>Add a new category:</h2>
<p>
<form method='post' action='$PHP_SELF'>
<p><b>Category Name:</b></p>
<input type='Text' name='catname' maxlength='20'>
<p><b>Display Order:</b></p>
<input type='Text' name='displayorder' maxlength='10'>
<p>
<input type='Submit' name='submit' value='Submit'></p>
</form>
";
include("footer.php");
}
?>
LiveFree
Forum Contributor
Posts: 258
Joined: Tue Dec 06, 2005 5:34 pm
Location: W-Town

Post by LiveFree »

Code: Select all

if (member_types2($VAR[4]) != '0') {
        echo "<p>Sorry, but you must be logged in as an administrator to view this area.";
}
to

Code: Select all

if ($member_types2($VAR[4]) != '0') {
        echo "<p>Sorry, but you must be logged in as an administrator to view this area.";
}
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

I Don't see how you reached that conclusion tucker.
Moved servers, code no longer works. Help please!
What doesn't work, do you get any errors?
Citizen
Forum Contributor
Posts: 300
Joined: Wed Jul 20, 2005 10:23 am

Post by Citizen »

The form is displayed and I can enter information. When I click submit, the page refreshes and the fields are erased but the form doesnt add the content to the database or show any errors.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Can you paste here the contents of ../../inc/config/connect.inc please
Citizen
Forum Contributor
Posts: 300
Joined: Wed Jul 20, 2005 10:23 am

Post by Citizen »

The connect.inc script works fine. It checks to see if I'm logged in as an admin, which I am, and the page loads. The script stops working after I click submit.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

where is $submit assigned then?
User avatar
xpgeek
Forum Contributor
Posts: 146
Joined: Mon May 22, 2006 1:45 am
Location: Kyiv, Ukraine
Contact:

Post by xpgeek »

2 Moderator - delete this post please
Citizen wrote:The connect.inc script works fine. It checks to see if I'm logged in as an admin, which I am, and the page loads. The script stops working after I click submit.
May be problem in "register globals off"

try to add

Code: Select all

extract($_POST);
Last edited by xpgeek on Sun Jul 02, 2006 5:48 pm, edited 1 time in total.
User avatar
xpgeek
Forum Contributor
Posts: 146
Joined: Mon May 22, 2006 1:45 am
Location: Kyiv, Ukraine
Contact:

Post by xpgeek »

Citizen wrote:The connect.inc script works fine. It checks to see if I'm logged in as an admin, which I am, and the page loads. The script stops working after I click submit.
May be problem in "register globals off"

try to add

Code: Select all

extract($_POST);
or use

Code: Select all

$_POST['submit'];
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

May be problem in "register globals off"
Ahh yes that is a likely possibility.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

using extract() isn't any better than having register globlas on, as it allows any variable to be injected into the script.. use the super global $_POST instead (as previously suggested)
Post Reply