[SOLVED] UPDATE not fully updating. please help.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

[SOLVED] UPDATE not fully updating. please help.

Post 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?
Last edited by $var on Wed Sep 21, 2005 3:20 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

PHP level NULL or the string 'NULL' ?
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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... ;)
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

session_start() not session_start

;)
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

change

WHERE Mem_ID=".$ID;

to

WHERE Mem_ID='".$ID."'";
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

Post by $var »

change

WHERE Mem_ID=".$ID;

to

WHERE Mem_ID='".$ID."'";
Instantly displays an error on that line.
ryanlwh
Forum Commoner
Posts: 84
Joined: Wed Sep 14, 2005 1:29 pm

Post by ryanlwh »

you have a comma before WHERE :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it's actually complaining about the comma you have immediately before the WHERE
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I'm always at my office... it's 1m from my bed! :)
Post Reply