To simplify that, you could also do this:
echo "GET VARS<pre>";
print_r($HTTP_GET_VARS);
echo "</pre><br><br>POST VARS <pre>"
print_r($HTTP_POST_VARS);
echo "</pre>";
Main Topics
Browse All TopicsHi Guys, been working on this for ages, its driving me nuts and wasting my time as I need to move on to other things...
If I echo the query after hitting submit, i get everything through except the id, which of course renders the query useless as it wont update without it. I tried using $_GET['id'] in the query (as it is being passed through a URL and it wont work, however if I echo the $_GET['id'] in the page, the id is displayed. I have tried setting the $_GET['id'] into a hidden form field and set the query to WHERE id = $_POST['id'] and have tried putting the $_GET['id']into a variable (i think thats what its called) as $id and used that, but nothing... as i said i can echo these on the page, but they are not existing in the query.... heres my code (all of it, so i hope i can get this fixed)...
**************************
<?php
ob_start();
include('admin_functions.p
db_connect(); // function which just connects - db connection status is not an issue.
$query_pplay = "SELECT * FROM products WHERE id = '{$_GET['id']}'";
$pplay = mysql_query($query_pplay) or die(mysql_error());
$row_pplay = mysql_fetch_assoc($pplay);
$query_pplay2 = "SELECT * FROM cats WHERE id = '{$row_pplay['cat_id']}'";
$pplay2 = mysql_query($query_pplay2)
$row_pplay2 = mysql_fetch_assoc($pplay2)
$query_pplay3 = "SELECT DISTINCT * FROM cats ORDER BY title";
$pplay3 = mysql_query($query_pplay3)
$row_pplay3 = mysql_fetch_assoc($pplay3)
if (count($_FILES) > 0 and array_key_exists('image', $_FILES)) {
if (is_uploaded_file($_FILES[
if ($_FILES['image']['name'] != '') {
$pic_name = "1_" . date("d_m_Y_H_i") . "_" . $_FILES['image']['name'];
} else {
exit; //Can't really do anything if we don't have a filename
}
$uploaddir = '../images/parts/';
$thumbnaildir = '../images/parts/thumbs/';
$sourcefile = $uploaddir . $pic_name;
move_uploaded_file($_FILES
$pdestfile = "{$thumbnaildir}tn_{$pic_n
$g_imgcomp = 50;
$psize = 150;
resampimagejpg($psize, $sourcefile, $pdestfile, $g_imgcomp);
}
}
$p_title = addslashes($_POST['title']
$p_desc = addslashes($_POST['descrip
$p_cat_id = addslashes($_POST['cat_id'
$p_price = addslashes($_POST['price']
$s_title = stripslashes($row_pplay['t
$s_description = stripslashes($row_pplay['d
$s_cat_id = stripslashes($row_pplay['c
$s_price = stripslashes($row_pplay['p
if (isset($_POST['submit'])) {
if ($_FILES['image']['name'] != '') {
$updateSQL = "UPDATE products SET title='{$p_title}', description='{$p_desc}', cat_id='{$p_cat_id}', price='{$p_price}', image='{$pic_name}' WHERE id = '{$row_pplay['id']}'";
} else {
$updateSQL = "UPDATE products SET title='{$p_title}', description='{$p_desc}', cat_id='{$p_cat_id}', price='{$p_price}' WHERE id = '{$row_pplay['id']}'";
}
$Result1 = mysql_query($updateSQL) or die(mysql_error());
echo $updateSQL ;
// header("Location: index.php?goto=thanks");
}
echo '
<div id="content">
<form method="post" name="form1" action="prod_edit.php" enctype="multipart/form-da
<table width="400" border="0">
<tr>
<td width="100">Title:</td>
<td><input class="formfield" type="text" name="title" value="' . $s_title . '" size="32"></td>
</tr>
<tr>
<td width="100">Description:</
<td><textarea class="formfield" name="description" cols="100" rows="15">' . $s_description . '</textarea></td>
</tr>
<tr>
<td width="100">In Category:</td>
<td><select name="cat_id">
<option value="' . $row_pplay2['id'] . '">' . $row_pplay2['title'] . '</option>';
do {
echo '<option value="' . $row_pplay3['id'] . '">' . $row_pplay3['title'] . '</option>';
} while ($row_pplay3 = mysql_fetch_assoc($pplay3)
echo '
</select></td>
</tr>
<tr>
<td width="100">Price:</td>
<td><input class="formfield" type="text" name="price" value="' . $s_price . '" size="32"></td>
</tr>
<tr>
<td width="100">Image:</td>';
if ($row_pplay['image'] == true) {
echo '<td><a href="../images/parts/' . $row_pplay['image'] . '" target="_blank"><img src="../images/parts/thumb
} else if ($row_pplay['image'] == false) {
echo '<td><input type="file" name="image" class="formfield"></td>';
}
echo '
</tr>
<tr>
<td width="100"><input class="formsubmit" type="submit" name="submit" value="Update Record" /></td>
<td><input type="reset" class="formsubmit" name="reset" value="Clear Form" /></td>
</tr>
</table>
<form type="hidden" name="id" value="'.$_row_pplay['id']
</form>
</div>';
mysql_close();
?>
**************************
Thanks Guys! :)
Christian
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
But your problem is this line:
<form type="hidden" name="id" value="'.$_row_pplay['id']
Needs to be
<input type="hidden" name="id" value="'.$_row_pplay['id']
Well, you just brought my attention to another error also - $_row_pplay -> $row_pplay
dammit, see what staring at code for several hours does to you.... thanks very much! :)
Christian
Business Accounts
Answer for Membership
by: jetnetPosted on 2005-01-26 at 22:44:45ID: 13150006
When in doubt, echo out everything, and see where your variable is at:
]) )
k]) )
function parse_incoming()
{
global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_CLIENT_IP, $REQUEST_METHOD, $REMOTE_ADDR, $HTTP_PROXY_USER, $HTTP_X_FORWARDED_FOR;
$return = array();
$url = "";
if( is_array($HTTP_GET_VARS) )
{
while( list($k, $v) = each($HTTP_GET_VARS) )
{
//$k = clean_key($k);
if( is_array($HTTP_GET_VARS[$k
{
while( list($k2, $v2) = each($HTTP_GET_VARS[$k]) )
{
$return[$k][ clean_key($k2) ] = clean_value($v2);
echo" GET VAR : clean_value($v2)<br>";
}
}
else
{
$return[$k] = clean_value($v);
echo" GET VAR : clean_value($v)<br>";
}
}
}
if( is_array($HTTP_POST_VARS) )
{
while( list($k, $v) = each($HTTP_POST_VARS) )
{
//$k = clean_key($k);
if ( is_array($HTTP_POST_VARS[$
{
while( list($k2, $v2) = each($HTTP_POST_VARS[$k]) )
{
$return[$k][ clean_key($k2) ] = clean_value($v2);
echo "POST VAR : clean_value($v2)";
}
}
else
{
$return[$k] = clean_value($v);
echo "POST VAR : clean_value($v)";
}
}
}
return $return;
}
And call it with something like
$input = parse_incoming();