1) Change " AND text =" to " , text ="
2) You need to include the "WHERE pagename = 'homeL.php'" part in your SQL statement.
Jord, welcome to WebmasterWorld
In reference to LIA point #2.
You will want to add a "where" clause to your statement otherwise you will perform this update on all rows in the database and I assume that is not your goal.
The "where" clause allows you to define a condition which must be met before a row is updated.
So you can say something like.
update table_name set field1 = 'field1 value', field2 = 'field2 value', field3 = 'and so on' where field4 = some_condition
Hope this makes sense. If not post back
thanks for the help, getting a lot closer... however i still can't get it to work
mysql_query("UPDATE pages SET pagename = '('".mysql_real_escape_string($_POST['pagename'])."'' , AND text = ''".mysql_real_escape_string($_POST['text'])."'') WHERE pagename = 'homeL.php' ") OR die(mysql_error());
Is there something still wrong in this syntax, I keep getting this error :
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 'homeL.php'' , AND text = ''hallo hallo hallo hallo hallo hallo h
the hallo hallo stuff is the update so to speak. homeL.php is one of the pagenames
Often, a misplaced ' or " is causing problems. Try putting your SQL statement into a variable and ECHOing that variable. Make sure what you are seeing is exactly what you are expecting in the SQL statement.
Also, as I previously mentioned, get rid of the "AND" before the "text =" part. Your statement should look something like:
UPDATE pages SET
Also, not sure if "text" is a reserved word in MySQL- that part may be causing problems as well.
found the problem just not the solution ^^
'homeL.php'' , content = ''hallo'') WHERE pagename = 'homeL.php''
As you can see the quote tags are not working
'homeL.php'' = $_POST['pagename']).
I've tried several things but no solution, why the heck are those quote tags messed up here... :(
nvm last reply, got closer now, just a different error i think ill manage to fix, thanks for the help :)
sorry couldn't find the edit button earlier.
ofcourse the second you got all quote problems fixed, another one shows up.
This time, whenever i update (in this case homeL.php) the 'pagename' changes into 0, without giving the update (it does update, it changes homeL.php into 0, but it shouldn't) Is this somekind of standard error or do i need to post some other code with it?
somehow it (appearantly) makes this
<select size="1" name="pagename">
into 0... for a reason i can't understand ... someone here does?
I see it.
You haven't assigned a value to the option. I guess the default value is zero if there is no value.
same problem with value included :(
solution found, thanks for all the great help
may I suggest that you store the whole query in a variable first, then execute it. This way you can always output (echo) the query if it doesn't work - then copy and paste it into phpmyadmin to check what's wrong with the query.
That's a good tip, i'll go do so, to prevent future problems
again thanks for the help