hellonoko Posted February 16, 2007 Share Posted February 16, 2007 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 More sharing options...
Clinger Posted February 16, 2007 Share Posted February 16, 2007 Try enclosing variables in {} when you use them in the sql string. If that doesn't work, try outputting that string to see what the actual sql result is. Link to comment https://forums.phpfreaks.com/topic/38815-page-working-in-wamp-but-not-on-server/#findComment-186606 Share on other sites More sharing options...
papaface Posted February 16, 2007 Share Posted February 16, 2007 $query = "INSERT INTO categories (category) VALUE ('$category')" or die (mysql_error()); should be $query = "INSERT INTO categories (category) VALUES ('$category')" or die (mysql_error()); Link to comment https://forums.phpfreaks.com/topic/38815-page-working-in-wamp-but-not-on-server/#findComment-186610 Share on other sites More sharing options...
hellonoko Posted February 16, 2007 Author Share Posted February 16, 2007 papaface: thanks words perfect! Link to comment https://forums.phpfreaks.com/topic/38815-page-working-in-wamp-but-not-on-server/#findComment-186616 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.