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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.