Page 1 of 1

[SOLVED] UPDATE not fully updating. please help.

Posted: Wed Sep 21, 2005 1:41 pm
by $var
Hello,

I am having a trouble with my update page.

It is going through the motions,
but it doesn't accept the data.

Here it is:

Code: Select all

$link = mysql_connect("localhost", "username", "password")
	or die("Could not connect: " . mysql_error());
	mysql_select_db (database_db) or die("db not connected: " . mysql_error());

	$ID = $_GET["ID"];
	if($_POST["bpress"]=="update")
	{
		$sql = "UPDATE members SET 
		Mem_Name ='".$_POST["name"]."',
		Mem_LName='".$_POST["lname"]."',
		Mem_FName ='".$_POST["fname"]."', 
		Mem_Title='".$_POST["title"]."', 
		Mem_Bio='".$_POST["bio"]."', 
		Mem_CBio='".$_POST["cbio"]."', 
		Mem_CName='".$_POST["cname"]."', 
		Mem_URL='".$_POST["url"]."', 
		Mem_EMail='".$_POST["email"]."', 
		Mem_Password='".$_POST["password"]."', 
		Mem_Username='".$_POST["username"]."', 				
		WHERE Mem_ID=".$ID;
		if(!$result = mysql_query($sql))
		{
			echo mysql_error();
		}
		header("Location: http://www.devnet.net");
		exit;
	}

What I have checked:
- That all fields in the database that aren't going to be updated in this page are set to NULL
- That all the data input fields are named the same as in the definition above <input name="email">
- All the dynamic displays are working so they are reading the database and ID properly

Is there something that I have muffed?

Posted: Wed Sep 21, 2005 1:47 pm
by feyd
PHP level NULL or the string 'NULL' ?

Posted: Wed Sep 21, 2005 2:05 pm
by $var
I think string NULL.
In the phpMyAdmin MySQL editor, all you have to do is select it from the dropdown.

Is this what you mean by string?

Posted: Wed Sep 21, 2005 2:13 pm
by feyd
does it kick out an error?

If it always redirects (quite possible) you may want to always make the "success" side of the query run the header() only... ;)

Posted: Wed Sep 21, 2005 2:26 pm
by $var
well... that's a great start...
it's echoing an error though...
syntax error...

it says line 3, which makes me think that it is a cookie error.

Code: Select all

ob_start();
	session_save_path();
	session_start; 
	if($_COOKIE["access"] != "true")
		{
		header("Location: ");
		exit;
		}

	$link = mysql_connect("localhost", "", "")
	or die("Could not connect: " . mysql_error());
	mysql_select_db (_db) or die("db not connected: " . mysql_error());

	$ID = $_GET["ID"];
	if($_POST["bpress"]=="update")

The $_COOKIE is perhaps filling it with a different ID value?

Posted: Wed Sep 21, 2005 2:29 pm
by feyd
session_start() not session_start

;)

Posted: Wed Sep 21, 2005 2:38 pm
by $var
This is the error that I am getting:
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE Mem_ID=4' at line 13

Posted: Wed Sep 21, 2005 2:40 pm
by John Cartwright
change

WHERE Mem_ID=".$ID;

to

WHERE Mem_ID='".$ID."'";

Posted: Wed Sep 21, 2005 2:47 pm
by $var
change

WHERE Mem_ID=".$ID;

to

WHERE Mem_ID='".$ID."'";
Instantly displays an error on that line.

Posted: Wed Sep 21, 2005 3:09 pm
by ryanlwh
you have a comma before WHERE :)

Posted: Wed Sep 21, 2005 3:10 pm
by feyd
it's actually complaining about the comma you have immediately before the WHERE

Posted: Wed Sep 21, 2005 3:19 pm
by $var
Awesome.
Thanks a lot guys.


sooo...
in Ontario it's 4:20.
I hope that not everyone in this timezone is stuck in an office right now.

Posted: Wed Sep 21, 2005 3:22 pm
by feyd
I'm always at my office... it's 1m from my bed! :)