|
|
|
#1 (permalink) |
|
x10Hosting Member
|
Query String - $_GET problem
As part of a MySQL driven CMS I need to pass an id to a page which inserts new content into a database table
The links on one page, dealt with using an array, include the query string after .php such as ?id=8 - all good. The form page needs to use this id in a hidden field: exhibition_id. So far the form submits the two shown fields, an image file name and an image caption, but the hidden field is coming out as "0" I'm probably doing something really daft, but right now I'm blind to it. Here's the code at the top of the page: Code:
<?php
session_start();
// if session variable not set, redirect to login page
if (!isset($_SESSION['authenticated'])) {
header('Location: ../back_office/index.php');
exit;
}
$exhibition_id = $_GET['id'];
if (array_key_exists('insert', $_POST)) {
include('../db_dual_connect.php');
include('../magic_quotes.php');
// remove backslashes
nukeMagicQuotes();
// prepare an array of expected items
$expected = array('image', 'caption', 'exhibition_id');
// create database connection
$conn = dbConnect('admin');
// make $_POST data safe for insertion into database
foreach ($_POST as $key => $value) {
if (in_array($key, $expected)) {
${$key} = mysql_real_escape_string($value);
}
}
// prepare the SQL query
$sql = "INSERT INTO exhibition_images (image, caption, exhibition_id)
VALUES('$image', '$caption', '$exhibition_id')";
// process the query
$result = mysql_query($sql) or die(mysql_error());
}
?>
Code:
<input name="exhibition_id" type="hidden" id="hiddenField" value="<?php echo '$exhibition_id' ?>" /> thanks |
|
|
|
|
|
#2 (permalink) |
|
x10 Sophmore
|
Re: Query String - $_GET problem
it should be
Code:
<input name="exhibition_id" type="hidden" id="hiddenField" value="<?php echo $exhibition_id ?>" />
__________________
|
|
|
|
|
|
#3 (permalink) |
|
x10Hosting Member
|
Re: Query String - $_GET problem
thanks, perfect!
obviously time I took a break |
|
|
|
|
|
#4 (permalink) |
|
x10 Sophmore
|
Re: Query String - $_GET problem
yeah happens to everyone once in a while
![]() take a break from all this coding stuff.grab a beer and watch a movie ![]()
__________________
|
|
|
|
|
|
#5 (permalink) |
|
x10 Elder
|
Re: Query String - $_GET problem
Using <?=$exhibition_id?> is the same as doing <?php echo '$exhibition_id'; ?>
Just a FYI
__________________
Visit my site!
Always use the search function before posting a new thread! Extra10 Helpful suggestions: Read the rules on every forum, follow said rules, and if you are unsure or need help, search first |
|
|
|
|
|
#6 (permalink) | |
|
Community Advocate
|
Re: Query String - $_GET problem
Quote:
Short tags also don't play well with XML processing instructions, such as an <?xml?> directive at the start of an XHTML document (which has its own disadvantages in IE). It's not hard to get them to work together, but the extra effort is greater than the advantage of a few saved keystrokes that short tags afford. |
|
|
|
|
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Database server problem | Xaeron | Free Hosting | 2 | 08-12-2008 05:09 PM |
| A problem with certificate | eon01 | Free Hosting | 1 | 07-31-2008 02:27 PM |
| DB number problem | lionheart8 | Free Hosting | 5 | 04-08-2008 09:26 AM |
| Problem uploading image (GD library problem) | HyDr@ | Free Hosting | 1 | 12-01-2006 05:27 PM |
| Ftp Timeout problem | ironcross77 | Free Hosting | 7 | 04-12-2005 09:53 PM |