PHP/MySql function not working. Cant figure out why! - TechRepublic
Question
December 16, 2008 at 07:41 AM
grady

PHP/MySql function not working. Cant figure out why!

by grady . Updated 17 years, 6 months ago

[pre]I am using several functions to manage content on my pages. They all work but these two. The function terms() builds the page properly but updterms() doesn’t even try to run. Also, there is another submit button named ‘back’ that works fine in every other function on the site but not this one.

Thanks in advance for your help.

Here’s the function that builds the page:

function terms($_POST) {
include(‘header.php’);
include(‘dbconn.php’);
$query = ‘SELECT terms FROM content’;
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
echo “

;


echo

“;
echo “

“;
include(‘../footer.php’);
include(‘dbclose.php’);
}

And here’s the function that processes it:

function updterms($_POST) {
include(‘dbconn.php’);
$query = “UPDATE content SET terms='”.$_POST[‘terms’].”‘”;
$result = mysql_query($query);
header(“Location: http://localhost/admin/adminpage.php”);
include(‘dbclose.php’);
}

Here are the switch statements I am using:

switch($_POST) {
case isset($_POST[‘terms’]):
terms($_POST);
break;
case isset($_POST[‘updterms’]):
updterms($_POST);
break;
}

You can see in updterms() that the expected behavior is to update a database row and then send header information. All that happens is the current page (the terms() page) reloads.[/pre]

This discussion is locked

All Comments