Open MJAzura opened 7 years ago
It's simple, but to be very clear... one must _always_ define all variables 😋. so to fix this, you just have to change the first part of the code to this:
<?php
if(isset($_GET['id'])&&is_numeric($_GET['id'])){
$q= "SELECT * FROM pages WHERE id = $_GET[id]";
$r= mysqli_query($mysql, $q);
$opened = mysqli_fetch_assoc($r);
}else{
$opened = null;
}
?>
Just defined
opened
in case there's no id specified.
Hey! Thanks for the answer, but now, when I click the sidebar pages it still shows blank in the input fields.
Ok, so maybe you're not using numeric ids?
In that case use if(isset($_GET['id'])){
instead of if(isset($_GET['id'])&&is_numeric($_GET['id'])){
.
If it still doesn't work first check that the database table has valid values in them, and that the $_GET['id']
variable is correctly inputed in the url. Example: http://somewebsite.com/admin?page=pageEditor&id=1
I'm using numeric ID's.
do you actually get and url like the above one when clicking on a link inside the sidebar panel?
No. I get ndex.php?=2 (or whatever the ID is of the post I've clicked) where 2 is the ID of the post.
I didn't add slugs, not necessary for what I'm building.
please provide the full code of that page (the one where the sidebar is on) and i'll fix it for you 😋.
I have sent my code to your Live email. Please respond my email with the fixed code, I don't really want my functions to be public.
Hi, I am getting error Undefined Variable opened.
My code: