Jump to content

Page working in WAMP but not on server.


hellonoko

Recommended Posts

Can anyone give me any ideas why my below page works fine on my WAMP setup but not on my host?

 

The list and delete functions of the script work fine on both but the INSERT query only works on WAMP on my computer.

 

Thanks for your time,

Ian

 

<title>Yummy!</title>
<?php

mysql_connect("www.empireofstyle.com","so","yummy")or die ("Could not connect to database");
mysql_select_db("yummy") or die ("Could not select database");

$action = $HTTP_GET_VARS[action];
$category = $HTTP_GET_VARS[category];
$id = $HTTP_GET_VARS[id];

echo $action;
echo $category;
echo "<br><br>";
echo $id;

if ($action == "add_category")
{
	$query = "INSERT INTO categories (category) VALUE ('$category')" or die (mysql_error());
	$result = mysql_query($query);

}

if ($action == "Delete")
{
	$query = "DELETE FROM categories WHERE id=$id" or die (mysql_error());
	$result = mysql_query($query);
}

$query = "SELECT * FROM categories";

$result = mysql_query($query);
$rows = mysql_num_rows($result);

$rows;

echo 'Number of categories: ' . $rows ;
echo '<br><br>';





for ($i=0; $i <$rows; $i++)
{
	$row = mysql_fetch_array($result);

	echo "<form id=delete_category name=delete_category method=get action=listcategories.php>";
	echo "<input name=action type=submit value=Delete >"; 
	echo "<input name=id type=hidden value=".$row[id].">";
	echo $row[category];
	echo "<br>";
	echo "</form>";

}


?>

<form id="add_category" name="add_category" method="get" action="listcategories.php">
  <input name="category" type="text" id="category" />
  <input name="Add" type="submit" value="Add" />
  <input name="action" type="hidden" value="add_category" />
</form>

Link to comment
https://forums.phpfreaks.com/topic/38815-page-working-in-wamp-but-not-on-server/
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.