thedigicraft / Atom.CMS

Atom.CMS
56 stars 50 forks source link

Update works fine but new page query SQL not working #19

Closed dbashby closed 10 years ago

dbashby commented 10 years ago

I have posted the code from all the relevant pages from the admin section at https://github.com/dbashby/code.git

I have gone through 44 and 45 several times to see if I have missed anything, I even copied and pasted the queries from Digicraft to see if I had made a typo but I cannot see the issue.

The error I am getting is

Page could not be updated 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 = '', title = 'Test', label = '', header = '', body = '

test

' WHERE id =

Any help would be appreciated. Thanks

dbashby commented 10 years ago

If I take the query out of the isset, put it back where it is at the start of Video 44 the page is added to the database.

$q = "INSERT INTO pages (user, slug, title, label, header, body) VALUES ($_POST[user], '$_POST[slug]', '$title', '$label', '$header', '$body')";

dbashby commented 10 years ago

Happy to say, solved the issue. For some reason when I had entered the code I had put != rather than == in the if isset query so it was missing the insert query every time.

dbashby commented 10 years ago

Thinking I had resolved the issue the code from the tutorial is != rather than == in the if(isset($_POST['id']) != ''){ Query here } else { Insert query here }

However the insert query breaks using (is not) != but it works if I use == but as the quotes do not contain anything it will accept any entry? Is my understanding right?

dbashby commented 10 years ago

I spoke to soon....The fix I thought I had let me add a page but as in the tutorial if I edited a page it would be added as a new page. I cannot see where I have gone wrong. As previously stated the code for the pages concerned is at https://github.com/dbashby/code.git

Dragotic commented 10 years ago

Hello dbashby,

I was wondering if you could paste the pages.php and queries.php code in a comment here and not prompting us on a link. Because its kinda messed on your repository. And as i see you are really back in the tutorials cause you have index.php instead of pages.php etc...

You should probably finish the tutorial and head back here if you still got problems but i think that you will fix this problem if you finish the series.

dbashby commented 10 years ago

Dragotic, thanks for the offer of assistance however I have found the solution. I don't quite understand what you are saying about having index instead of pages as am on video 61 now and pages is totally separate from index.

I would say though that the suggestion to finish the series which would mean turning error checking off for me personally would not be a wise thing to do because you would have no idea of where the error was because you had no idea of the error.

Dragotic commented 10 years ago

i was talking about index.php being a "template" file in the latest tutorials with /views files being the important ones. And of course i wouldn't suggest you to turn error checking off as i didn't do it myself.

thedigicraft commented 10 years ago

Hey guys. You might find this helpful... http://www.php.net/manual/en/function.error-reporting.php

That is the documentation for the error reporting tool. I should probably talk about that in my videos. We should actually set that to a custom level. Those undefined indexs/variables drive me nuts. There isnt anything wrong with having a variable without a value. That is why it is only a warning. That can be helpful sometimes but most times it will annoy you. So you could turn that feature off exclusively.

error_reporting(E_ALL ^ E_WARNING); // Turns ON all except warnings

or...

error_reporting(E_ALL ^ E_WARNING | E_NOTICE); // Turns ON all except warnings & notices.

We could actually setup our debugging tool to enable customization to this depending on the need. Rather than having to go into the code and change it manually every time you need to.

Alan

Dragotic commented 10 years ago

Nah, I believe we should put it on the settings in admin panel, and enable or disable it to be viewed only on the debugging console. It would be cool ;)

dbashby commented 10 years ago

Thanks for that info.

roohit1234 commented 10 years ago

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 = 'adegadega', title = 'dvadga', label = 'adhde', header = 'adbhad', body = '

adbadb

' WHERE id =

RosemaryRoss commented 9 years ago

dbashby, If you have the code working from video 44, could you please share it?? I'm going cross eyed trying to figure out my mistake. Thank you.

Rosemary

creptor commented 9 years ago

@RosemaryRoss Create a new issue if you can't get something to work, maybe it's the same one but it's a year old.