So here is my problem, everything works fine when hard-coded, i.e:
What I want to do is replace 'home' with a variable that is obtained by $_GET from the URL. I am getting the variable ok, as I can echo it using var_dump.
I have tried all sorts of single/double quotes, escape backslashes etc.. I have only been learning php/MySQL for about 2 days so I am a bit of a noob.
Thanks for any help
Code:
//perfrom query to database and assign the variables
$query = "SELECT * FROM content WHERE section='home';" or die(mysql_error());
What I want to do is replace 'home' with a variable that is obtained by $_GET from the URL. I am getting the variable ok, as I can echo it using var_dump.
Code:
<?php
// $_GET for admin section
$admin = $_GET['admin_id'];
//snip database connect
//perfrom query to database and assign the variables
$query = "SELECT * FROM content WHERE section='"echo $admin"';" or die(mysql_error());
$result=mysql_query($query);
//snip loop code
//Test that ?admin_id variable is working correctly
var_dump($_GET);
echo $admin;
?>
I have tried all sorts of single/double quotes, escape backslashes etc.. I have only been learning php/MySQL for about 2 days so I am a bit of a noob.
Thanks for any help