Jump to content

[SOLVED] mysql update, what am I doing wrong?


crawlerbasher

Recommended Posts

I've been checking out a few online sites, my php mysql book to try and find the answers and still I'm not sure what I'm doing wrong.

I know that the mysql part is right, but I don't think the code is correct.

 

When I try to update it, I get a message saying its done, but notthing has been updated or added to the database.

 

This is part of the code

 

<?php
		// Update the database now with the information updated on the form.
		// Start Database Entry
		include("config.php");
		$databaseID = $_POST['databaseID'];	
		$level = $_POST['level'];
		$items = $_POST['items'];
		$rank = $_POST['rank'];
		$hq = $_POST['hq'];
		$hq2 = $_POST['hq2'];
		$hq3 = $_POST['hq3'];
		$ingredients = $_POST['ingredients'];
		$crystal = $_POST['crystal'];
		$sub_craft = $_POST['subcraft'];
		$conn = mysql_connect($host, $username, $password);
		mysql_select_db($database, $conn);
		$sql = "UPDATE FFXI_Guild_Cooking  SET item = '$items', crystal = '$crystal', ingredients = '$ingredients', hq_item = '$hq', hq_item2 = '$hq2', hq_item3 = '$hq3', rank = '$rank', lvl_cap = '$level', sub_craft = '$sub_craft' WHERE 'id' = '$databaseID' LIMIT 1";
		$result = mysql_query($sql, $conn) or die(mysql_error());
		if($result)//this works, as 1 = true
		{
		echo "Your Crafting Recipe has been added.";
		}
						} // end Database entry	
?>

Link to comment
Share on other sites

Got it working.

 

I still can't understand why the other one did not work.

 

Could it be because of the diffrent version of mysql?

 

Anyway this is the sql statment I changed it to this

 

<?php
$sql = 'UPDATE `FFXI_Guild_'.$id.'` SET `item` = \''.$items.'\', `crystal` = \''.$crystal.'\', `ingredients` = \''.$ingredients.'\', `hq_item` = \''.$hq.'\', `hq_item2` = \''.$hq2.'\', `hq_item3` = \''.$hq3.'\', `sub_craft` = \''.$sub_craft.'\' WHERE `FFXI_Guild_'.$id.'`.`id` = '.$databaseID.' LIMIT 1;';
?>

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.