[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.6

I have no idea why this wont work - simple UPDATE

Asked by theprankstanator in PHP and Databases

Tags: php, resampimagejpg, work

Hi 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.php');

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) or die(mysql_error());
$row_pplay2 = mysql_fetch_assoc($pplay2);

$query_pplay3 = "SELECT DISTINCT * FROM cats ORDER BY title";
$pplay3 = mysql_query($query_pplay3) or die(mysql_error());
$row_pplay3 = mysql_fetch_assoc($pplay3);

if (count($_FILES) > 0 and array_key_exists('image', $_FILES)) {
                        if (is_uploaded_file($_FILES['image']['tmp_name'])) {
                                                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['image']['tmp_name'], $sourcefile);
                                                $pdestfile = "{$thumbnaildir}tn_{$pic_name}";

                                                $g_imgcomp = 50;
                                                $psize = 150;
                                                resampimagejpg($psize, $sourcefile, $pdestfile, $g_imgcomp);
                        }
}

$p_title = addslashes($_POST['title']);
$p_desc = addslashes($_POST['description']);
$p_cat_id = addslashes($_POST['cat_id']);
$p_price = addslashes($_POST['price']);

$s_title = stripslashes($row_pplay['title']);
$s_description = stripslashes($row_pplay['description']);
$s_cat_id = stripslashes($row_pplay['cat_id']);
$s_price = stripslashes($row_pplay['price']);

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-data">
<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>
<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/thumbs/tn_' . $row_pplay['image'] . '" border="0"/></a><br />Upload new Image:<br /><input type="file" name="image" class="formfield"></td>';
} 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
[+][-]01/26/05 10:44 PM, ID: 13150006Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/26/05 10:46 PM, ID: 13150019Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/26/05 10:47 PM, ID: 13150023Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: PHP and Databases
Tags: php, resampimagejpg, work
Sign Up Now!
Solution Provided By: jetnet
Participating Experts: 1
Solution Grade: A
 
[+][-]01/26/05 11:12 PM, ID: 13150101Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89