thedigicraft / Atom.CMS

Atom.CMS
56 stars 50 forks source link

Part 45: Cannot add page, Giving me an error about SQL. #63

Open ghost opened 10 years ago

ghost commented 10 years ago

Here is the pic of the error, when i try to add new page: screen shot 2014-08-22 at 5 23 25 pm

Here is the queries.php code: screen shot 2014-08-22 at 5 24 11 pm and the cut out part: screen shot 2014-08-22 at 5 24 43 pm

ghost commented 10 years ago

I am able to edit a page, not problem, but cannot add a new page

thedigicraft commented 10 years ago

are you not getting an error message? (btw you can simply copy/paste the code in the message instead of screenshots - its easier for me to review and test)

McDuck74 commented 10 years ago

Seems like the id for a new page is not passed on, because the query in the screenshot says WHERE id=''. And another issue is that you are not updating an existing page, but inserting a new page. This choice is made in the file queries.php. Look up the rule if (isset($_POST['id']) != ''){ and change it into if (isset($_POST['id']) AND $_POST['id'] != '') { Then it should work. The id-field is not defined when it reloads when you click on save, so if you your errors are still turned on, you get a notice, but it works! I beleive it will be solved in another lesson.

adamissa commented 9 years ago

mcduck thank you sir

asani commented 9 years ago

Well i followed Mc Duck74's tip and everything seems to have passed thrue exept for

Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /home/a9667120/public_html/admin/index.php on line 143

wich on my code is the line where we added:

                <input type="hidden" name="id" value="<?php echo $opened['id']; ?>">

And for the life of me i cant figure out why it wont find $opened!!

Some one plz...

McDuck74 commented 8 years ago

I am sorry I haven't answered you for so long. A lot of other work made that I had no more time to look at it. When I had more time, this question was sadly forgotten. I read your question again and tried to restart my own project. Sadly I came up with the same error and could not solve it either, yet. I hope someone has a solution.

creptor commented 8 years ago

Oh god, still haven't found the issue????.... it's so simple man, I just thought you were over with this...

Just change the value of the id in the UPDATE sql to $_POST[id] (-> instead of $_GET[id]).

creptor commented 8 years ago

you were checking for a $_POST['id'] in the if statement so...

dbashby commented 8 years ago

McDuck74, your solution seems to have fixed my issue - see https://github.com/thedigicraft/Atom.CMS/issues/170

Thanks, I can now edit a page but also add a page