Reputation: 21630
I am making a little CMS. I am currently working on editing the pages. It works properly, but only if the 'id' of the page is less the 10 (has only 1 number)
This is the link the send to the edit_page with the form prepopulated with the proper content:
<a href="edit_page.php?nav_id_trough_link=<?php echo urlencode($selected_nav['id']); ?>">Edit this page</a> </p>
(sorry for the clumsy name of nav_id_trough_link, is just that i am learning)
When i just visit the page, in the address bar there is this:
http://localhost:8080/test1again/backend.php?navv=39
but when i click on the edit link, bringing me to edit_page.php, in the address bar appear this:
http://localhost:8080/test1again/edit_page.php?nav_id_trough_link=3
Somehow it cut out the 9 The same happen if the id of the page is 40, then will become 4 (and prepopulating the form with the content of the page that has the id 4..)
Someone please know why this can happen?
Upvotes: 1
Views: 76
Reputation: 29482
Error clearly lies in:
<?php echo urlencode($selected_nav['id']); ?>
Are you sure $selected_nav
is an array? It looks like $selected_nav
is a string, you are accessing it like an array and since string can be accessed as array but using only numercial indexes, 'id'
is casted to int (0
) and first character is returned.
Upvotes: 5