Closed MrGobblez closed 10 years ago
If you use NULL, you have to do it without the quotes. NULL not 'null'.
There are some differences to note:
$x = null
$x has no value and is equal to absolutely nothing at all
$x = 0
$x has a value and is equal to zero
$x = ''
$x has a value and is equal to an empty string
Thanks for super fast answer! Sadly, trying NULL, null, 0 or '' all give me Page could not be added to database because: 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 '' at line 3
UPDATE pages SET user blablabla.
I can also see that it says index.php?id=1 in the url when trying to edit.
Haha, I actually would like to see the full query. Even the blablabla part :-)
Okey, here's the whole if statement with query: if(isset($_POST['id']) != '') { $query = "UPDATE pages SET user = $_POST[user], slug = '$_POST[slug]', title = '$title', label = '$label', description = '$description', header = '$header', body = '$body' WHERE id = $_GET[id]"; }
And here's the whole error: Page could not be added to database because: 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 '' at line 1
UPDATE pages SET user = 1, slug = 'home', title = 'Home Page', label = 'Home', description = '', header = 'header', body = '
body
' WHERE id =
Weird. So when the page reloads (and this error appears) you still see that id=1 in the URL?
Hmm, nope! index.php?id=1 becomes index.php?Array.
Edit: According to debug window POST has and id value of 1
Hello, i suggest using:
if (isset($_POST['id']) && $_POST['id'] != '')
instead of:
if(isset($_POST['id']) != '')
It worked for me for other people as well!
Didn't work for me, still syntaxt error. :(
Error: Page could not be added to database because: 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 '' at line 1
UPDATE pages SET user = 1, slug = 'home', title = 'Home Page', label = 'Home', description = '', header = 'header', body = '' WHERE id =
oh! see in your <form>
tag. You have id=$opened
that is an array (which is why it says array in the url). You need to give it a key (or index).. id=$opened['id']
Without the key/index (terms are kinda interchangeable), PHP has no idea what you are trying to access and that is why it just spits out the word 'array' instead of a value.
Changed the form, still get error: Page could not be added to database because: 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 '' at line 1
UPDATE pages SET user = 1, slug = 'home', title = 'Home Page', label = 'Home', description = 'desc', header = 'header', body = '
body
' WHERE id
Ok, got excited and rushed, you were right about the form! Just forgot to add id= prior to the $opened. Thanks so much! Love the videos, absolutely fantastic :)
Thanks man! Thanks for watching!
Im getting this error....please someone help me
page could not added because: 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 '' at line 1
UPDATE pages SET user = 1, slug = 'New page1', title = 'New page1', label = 'New page1', header = 'New page1', body = '
New page1
' WHERE id =
Hi, I'm having an issue where my pages still get added as new to the database instead of getting edited. I've watched the video several times and I cannot figure out what's wrong. All I know is that if(isset($_POST['id']) != 'null') never runs. If I use if(isset($_POST['id']) != '') as shown in the video I get an error.
Here's the whole index.php code: