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
Citizen
Forum Contributor
Posts: 300 Joined: Wed Jul 20, 2005 10:23 am
Post
by Citizen » Sun Jul 02, 2006 3:03 pm
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 » Sun Jul 02, 2006 3:39 pm
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.";
}
Ollie Saunders
DevNet Master
Posts: 3179 Joined: Tue May 24, 2005 6:01 pm
Location: UK
Post
by Ollie Saunders » Sun Jul 02, 2006 3:48 pm
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 » Sun Jul 02, 2006 4:04 pm
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.
Ollie Saunders
DevNet Master
Posts: 3179 Joined: Tue May 24, 2005 6:01 pm
Location: UK
Post
by Ollie Saunders » Sun Jul 02, 2006 4:09 pm
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 » Sun Jul 02, 2006 4:20 pm
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.
xpgeek
Forum Contributor
Posts: 146 Joined: Mon May 22, 2006 1:45 am
Location: Kyiv, Ukraine
Contact:
Post
by xpgeek » Sun Jul 02, 2006 5:46 pm
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
Last edited by
xpgeek on Sun Jul 02, 2006 5:48 pm, edited 1 time in total.
xpgeek
Forum Contributor
Posts: 146 Joined: Mon May 22, 2006 1:45 am
Location: Kyiv, Ukraine
Contact:
Post
by xpgeek » Sun Jul 02, 2006 5:47 pm
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
or use
Ollie Saunders
DevNet Master
Posts: 3179 Joined: Tue May 24, 2005 6:01 pm
Location: UK
Post
by Ollie Saunders » Sun Jul 02, 2006 6:13 pm
May be problem in "register globals off"
Ahh yes that is a likely possibility.
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Sun Jul 02, 2006 10:14 pm
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)