wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
I find it easier to use a function called preg_replace_callback when doing this sort of thing. Have a read of [url=http://www.phpfreaks.com/forums/index.php/topic,102527.msg407109.html#msg407109]this post[/url] of mine for an example. What you do is create a dedicated function which will be called by preg_replace_callback when a match is found.
-
No problem! Glad we got there in the endm only took 7hours! :). I know I changed your code a lot post any questions you have about the code I used here and I'll answer them for you.
-
[quote author=Babushka link=topic=106493.msg426760#msg426760 date=1157228365] I will try that. Thanks a lot. One question:Do I have to change (again) the httpd.conf in the apache directory if I installed PMA in the apache root directory? [/quote] Not sure what you mean there. could you post the part of the httpd.conf in question here. A little confused.
-
I just found another bug in my code. Change this: $row = mysql_fetch_array($result1, MYSQL_ASSOC)) to this: $row = mysql_fetch_array($result1, MYSQL_ASSOC); I did noticedyou had trouble
-
I found out the problem You have a hidden field called shopName. The value of that field wan't being populated. I have now fixed that. Try this: [code]<?php #Script 7.3 - register.php include "db.php"; if(isset($_POST['submittedUpdate'])) { foreach($_POST as $key => $value) { ${$key} = mysql_real_escape_string($value); } $query2 = "UPDATE product SET prodName='$prodName', dept='$dept', brand='$brand', type='$type', image='$image', price='$price' WHERE prodId ='$prodId' and shopName='$shopName'"; $result2 = @mysql_query($query2) or die("Unable to perform query2 <code>" . $query2 . "</code><br /><br />" . mysql_error()); echo'<p align=center><font color="#333333"><b>UPDATED SUCCESSFULLY</b></font></p>'; } $prodId = 0; if(isset($_REQUEST['prodId']) && is_numeric($_REQUEST['prodId'])) { $prodId = $_REQUEST['prodId']; } $query1 = "SELECT * FROM product WHERE prodId=$prodId"; $result1 = mysql_query($query1, $conn) or die("Unable to perform query1 <code>" . $query1 . "</code><br /><br />" . mysql_error()); if (mysql_num_rows($result1) == 1) { echo'<form action="admin_update2.php" method="post"> <center> <table align="center" cellspacing="0" cellpadding="5" bgcolor="#ffffff" border=1 bordercolor="#2696b8"> '; $row = mysql_fetch_array($result1, MYSQL_ASSOC); echo'<tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Id </b></center></td> <td align="left">' . $row['prodId'] . '</td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Shop Name</b></td> <td align="left">' . $row['shopName'] . '</td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Name</b></td> <td align="left"><input type="text" name="prodName" size="30" maxlength="30" value="' . $row['prodName'] . '"/></td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Department</b></td> <td align="left"><input type="text" name="dept" size="20" maxlength="20" value="' . $row['dept'] . '"/></td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Price</b></td> <td align="left"><input type="text" name="price" size="50" maxlength="50" value="' . $row['price'] . '"/></td> </tr> <tr> <td align="center"> <p> <input type="submit" name="submit" value="UPDATE"/> <input type="reset" value="CLEAR FORM"> </p> <input type="hidden" name="prodId" value="' . $prodId . '"> <input type="hidden" name="shopName" value="' . $row['shopName'] . '"> <input type="hidden" name="submittedUpdate" value="TRUE"/> </td> </tr> </table> </center> </form>'; } ?> </body> </html>[/code] Should be the last time now! I also removed the if in the foreach loop. it was also the cause of the problem.
-
Oops. I typed $_POST['submittedUpdated'] instead of $_POST['submittedUpdate']. Try this: [code]<?php #Script 7.3 - register.php include "db.php"; if(isset($_POST['submittedUpdate'])) { foreach($_POST as $key => $value) { if($key != 'prodId' || $key != 'shopName' || $key != 'submittedUpdated') { $key = mysql_real_escape_string($value); } } $query2 = "UPDATE product SET prodName='$prodName', dept='$dept', brand='$brand', type='$type', image='$image', price='$price' WHERE prodId ='$prodId' and shopName='$shopName'"; $result2 = @mysql_query($query2) or die("Unable to perform query2 <code>" . $query2 . "</code><br /><br />" . mysql_error()); echo'<p align=center><font color="#333333"><b>UPDATED SUCCESSFULLY</b></font></p>'; } $prodId = 0; if(isset($_REQUEST['prodId']) && is_numeric($_REQUEST['prodId'])) { $prodId = $_REQUEST['prodId']; } $query1 = "SELECT * FROM product WHERE prodId=$prodId"; $result1 = mysql_query($query1, $conn) or die("Unable to perform query1 <code>" . $query1 . "</code><br /><br />" . mysql_error()); if (mysql_num_rows($result1) == 1) { echo'<form action="admin_update2.php" method="post"> <center> <table align="center" cellspacing="0" cellpadding="5" bgcolor="#ffffff" border=1 bordercolor="#2696b8"> '; while($row = mysql_fetch_array($result1, MYSQL_ASSOC)) { echo'<tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Id </b></center></td> <td align="left">' . $row['prodId'] . '</td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Shop Name</b></td> <td align="left">' . $row['shopName'] . '</td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Name</b></td> <td align="left"><input type="text" name="prodName" size="30" maxlength="30" value="' . $row['prodName'] . '"/></td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Department</b></td> <td align="left"><input type="text" name="dept" size="20" maxlength="20" value="' . $row['dept'] . '"/></td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Price</b></td> <td align="left"><input type="text" name="price" size="50" maxlength="50" value="' . $row['price'] . '"/></td> </tr> '; } echo'<tr> <td align="center"> <p> <input type="submit" name="submit" value="UPDATE"/> <input type="reset" value="CLEAR FORM"> </p> <input type="hidden" name="prodId" value="' . $prodId . '"> <input type="hidden" name="shopName" value="' . $row['shopName'] . '"> <input type="hidden" name="submittedUpdate" value="TRUE"/> </td> </tr> </table> </center> </form>'; } ?> </body> </html>[/code] This code has been revised even more!
-
I had a few typos in that last code, try this: [code]<?php #Script 7.3 - register.php include "db.php"; $prodId = 0; // UPDATE if(isset($_GET['prodId']) && is_numeric($_GET['prodId'])) { $prodId = $_GET['prodId']; $query1 = "SELECT * FROM product WHERE prodId=$prodId"; $result1 = mysql_query($query1, $conn) or die("Unable to perform query1 <code>" . $query1 . "</code><br /><br />" . mysql_error()); if (mysql_num_rows($result1) == 1) { echo'<form action="admin_update2.php" method="post"> <center> <table align="center" cellspacing="0" cellpadding="5" bgcolor="#ffffff" border=1 bordercolor="#2696b8"> '; while($row = mysql_fetch_array($result1, MYSQL_ASSOC)) { echo'<tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Id </b></center></td> <td align="left">' . $row['prodId'] . '</td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Shop Name</b></td> <td align="left">' . $row['shopName'] . '</td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Name</b></td> <td align="left"><input type="text" name="prodName" size="30" maxlength="30" value="' . $row['prodName'] . '"/></td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Department</b></td> <td align="left"><input type="text" name="dept" size="20" maxlength="20" value="' . $row['dept'] . '"/></td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Price</b></td> <td align="left"><input type="text" name="price" size="50" maxlength="50" value="' . $row['price'] . '"/></td> </tr> '; } echo' <tr> <td align="center"> <p><input type="submit" name="submit" value="UPDATE"/> <input type="reset" value="CLEAR FORM"></p> <input type="hidden" name="prodId" value="' . $prodId . '"> <input type="hidden" name="shopName" value="' . $row['shopName'] . '"> <input type="hidden" name="submittedUpdate" value="TRUE"/> </td> </tr> </table> </center> </form>'; } } elseif(isset($_POST['submittedUpdated'])) { foreach($_POST as $key => $value) { if($key != 'prodId' || $key != 'shopName' || $key != 'submittedUpdated') { $$key = mysql_real_escape_string($value); } } $query2 = "UPDATE product SET prodName='$prodName', dept='$dept', brand='$brand', type='$type', image='$image', price='$price' WHERE prodId ='$prodId' and shopName='$shopName'"; $result2 = @mysql_query($query2) or die("Unable to perform query2 <code>" . $query2 . "</code><br /><br />" . mysql_error()); echo'<p align=center><font color="#333333"><b>UPDATED SUCCESSFULLY</b></font></p>'; $query3 = "SELECT * FROM product WHERE prodId = '$prodId' and shopName='$shopName'"; $result3 = @mysql_query($query3) or die("Unable to perform query3 <code>" . $query3 . "</code><br /><br />" . mysql_error()); echo'<form action="admin_update.php" method="post"> <center> <table align="center" cellspacing="0" cellpadding="5" bgcolor="#ffffff" border=1 bordercolor="#2696b8"> '; while($row = mysql_fetch_array($result3, MYSQL_ASSOC)) { echo'<tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Id</b></center></td> <td align="left">' . $row['prodId'] . '</td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Shop Name</b></td> <td align="left">' . $row['shopName'] . '</td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Name</b></td> <td align="left"><input type="text" name="prodName" size="30" maxlength="30" value="' . $row['prodName'] . '"/></td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Department</b></td> <td align="left"><input type="text" name="dept" size="20" maxlength="20" value="' . $row['dept'] . '"/></td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Price</b></td> <td align="left"><input type="text" name="price" size="50" maxlength="50" value="' . $row['price'] . '"/></td> </tr> '; } echo'<tr> <td align="center"> <input type="submit" name="submit" value="UPDATE"/> </td> </tr> <tr> <td align="center"> <input type="hidden" name="prodId" value="' . $row['prodId'] . '"> <input type="hidden" name="shopName" value="' . $row['shopName'] . '"> <input type="hidden" name="submittedUpdate" value="TRUE"/> </td> </tr> </table> </center> </form>'; } ?> </body> </html>[/code]
-
Are I see whats happening now. When you click the update button, you are not updating the database. What you're doing is querying the database to retrive the data again. So it resets the form data Try this: [code]<?php #Script 7.3 - register.php include "db.php"; $prodId = 0; // UPDATE if(isset($_GET['prodId']) && is_numeric($_GET['prodId'])) { $prodId = $_GET['prodId']; $query1 = "SELECT * FROM product WHERE prodId=$prodId"; $result1 = mysql_query($query1, $conn) or die(mysql_error()); //comment out if not working if (mysql_num_rows($result1) == 1) { echo'<form action="admin_update2.php" method="post"> <center> <table align="center" cellspacing="0" cellpadding="5" bgcolor="#ffffff" border=1 bordercolor="#2696b8"> '; while($row = mysql_fetch_array($result1, MYSQL_ASSOC)) { echo'<tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Id </b></center></td> <td align="left">' . $row['prodId'] . '</td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Shop Name</b></td> <td align="left">' . $row['shopName'] . '</td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Name</b></td> <td align="left"><input type="text" name="prodName" size="30" maxlength="30" value="' . $row['prodName'] . '"/></td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Department</b></td> <td align="left"><input type="text" name="dept" size="20" maxlength="20" value="' . $row['dept'] . '"/></td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Price</b></td> <td align="left"><input type="text" name="price" size="50" maxlength="50" value="' . $row['price'] . '"/></td> </tr> '; } echo' <tr> <td align="center"> <p><input type="submit" name="submit" value="UPDATE"/> <input type="reset" value="CLEAR FORM"></p> <input type="hidden" name="prodId" value="' . $prodId . '"> <input type="hidden" name="shopName" value="' . $row['shopName'] . '"> <input type="hidden" name="submittedUpdate" value="TRUE"/> </td> </tr> </table> </center> </form>'; } } elseif(isset($_POST['submittedUpdated'])) { foreach($_POST as $key => $value) { if($key != 'prodId' || $key != 'shopName') { $$key = mysql_real_escape_string($value); } } $query3 = "UPDATE product SET prodName='$prodName', dept='$dept', brand='$brand', type='$type', image='$image', price='$price' WHERE prodId ='$prodId' and shopName='$shopName'"; $result3 = @mysql_query($query3) or die("Unable to perform query3 <code>" . $query3 . "</code><br /><br />" . mysql_error()); echo'<p align=center><font color="#333333"><b>UPDATED SUCCESSFULLY</b></font></p>'; $query4 = "SELECT * FROM product WHERE prodId = '$prodId' and shopName='$shopName'"; $result4 = @mysql_query($query4) or die("Unable to perform query4 <code>" . $query4 . "</code><br /><br />" . mysql_error()); echo'<form action="admin_update.php" method="post"> <center> <table align="center" cellspacing="0" cellpadding="5" bgcolor="#ffffff" border=1 bordercolor="#2696b8"> '; while($row = mysql_fetch_array($result4, MYSQL_ASSOC)) { echo'<tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Id</b></center></td> <td align="left">' . $row['prodId'] . '</td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Shop Name</b></td> <td align="left">' . $row['shopName'] . '</td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Name</b></td> <td align="left"><input type="text" name="prodName" size="30" maxlength="30" value="' . $row['prodName'] . '"/></td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Department</b></td> <td align="left"><input type="text" name="dept" size="20" maxlength="20" value="' . $row['dept'] . '"/></td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Price</b></td> <td align="left"><input type="text" name="price" size="50" maxlength="50" value="' . $row['price'] . '"/></td> </tr> '; } echo'<tr> <td align="center"> <input type="submit" name="submit" value="UPDATE"/> </td> </tr> <tr> <td align="center"> <input type="hidden" name="prodId" value="' . $prodId . '"> <input type="hidden" name="shopName" value="' . $shopName . '"> <input type="hidden" name="submittedUpdate" value="TRUE"/> </td> </tr> </table> </center> </form>'; } ?> </body> </html>[/code] I ahve rewritten the code a bit,
-
You dont need to reinstall MySQL. If you ahve PHP5, which it sound like you do need to enable the MySQL extension. Go to the [url=http://www.expertsrt.com/tutorials/Matt/install-apache.html#extras]5. Some extra steps: Setting up a development environment and installing MySQL[/url] heading. Now scroll down to the MySQL heading read from then on. Fter it talks about installing mysql it talks about enabling the MySQL extension.
-
Okay looking at the html output, you have a submit button named submittedUpdate in the update page but in your PHP code you use $_POST['submitted'] to get your submit button So change $_POST['submitted'] to $_POST['submittedUpdate'] and you should be good to go.
-
Sorry I copied my old code I used earlier. Chnage this: [code]$result2 = @mysql_query($query) or die("Unable to perform query2 <code>" . $query2 . "</code><br /><br />" . mysql_error());[/code] To this: [code]$result2 = @mysql_query($query2) or die("Unable to perform query2 <code>" . $query2 . "</code><br /><br />" . mysql_error());[/code]
-
Try downloading the latest version of phpmyadmin from phpmyadmin.net. 2.7.x is old. The latest version is [url=http://prdownloads.sourceforge.net/phpmyadmin/phpMyAdmin-2.8.2.4.zip?download]2.8.2.4[/url] The version of PMA you have is a patch so its most most probably got files missing.
-
Try this: [code]<?php #Script 7.3 - register.php include "db.php"; $prodId = 0; // UPDATED $prodId = isset($_REQUEST['prodId']) ? $_REQUEST['prodId'] : '1'; $sql = "SELECT * FROM product WHERE prodId=$prodId"; $result = mysql_query($sql, $conn) or die(mysql_error()); //comment out if not working if (mysql_num_rows($result) == 1) { //if authorized, get the values of prodId, shopName... $prodId = mysql_result($result, 0, 'prodId'); $shopName = mysql_result($result, 0, 'shopName'); $dept = mysql_result($result, 0, 'dept'); $brand = mysql_result($result, 0, 'brand'); $type = mysql_result($result, 0, 'type'); $image = mysql_result($result, 0, 'image'); $price = mysql_result($result, 0, 'price'); $query1 = "UPDATE product SET prodName='$prodName', dept='$dept', brand='$brand', type='$type', image='$image', price='$price' WHERE prodId ='$prodId' and shopName='$shopName'"; $result = @mysql_query($query1) or die("Unable to perform query1 <code>" . $query1 . "</code><br /><br />" . mysql_error()); echo'<p align=center><font color="#333333"><b>UPDATED SUCCESSFULLY</b></font></p>'; $query2 = "SELECT * FROM product WHERE prodId = '$prodId' and shopName='$shopName'"; $result2 = @mysql_query($query) or die("Unable to perform query2 <code>" . $query2 . "</code><br /><br />" . mysql_error()); echo'<form action="admin_update2.php" method="post"> <center> <table align="center" cellspacing="0" cellpadding="5" bgcolor="#ffffff" border=1 bordercolor="#2696b8"> '; while($row = mysql_fetch_array($result2, MYSQL_ASSOC)) { echo'<tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Id </b></center></td> <td align="left">' . $row['prodId'] . '</td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Shop Name</b></td> <td align="left">' . $row['shopName'] . '</td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Name</b></td> <td align="left"><input type="text" name="prodName" size="30" maxlength="30" value="' . $row['prodName'] . '"/></td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Department</b></td> <td align="left"><input type="text" name="dept" size="20" maxlength="20" value="' . $row['dept'] . '"/></td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Price</b></td> <td align="left"><input type="text" name="price" size="50" maxlength="50" value="' . $row['price'] . '"/></td> </tr> '; } echo' <tr> <td align="center"> <p><input type="submit" name="submit" value="UPDATE"/> <input type="reset" value="CLEAR FORM"></p> <input type="hidden" name="prodId" value=' . $prodId . '> <input type="hidden" name="shopName" value=' . $sName . '> <input type="hidden" name="submittedUpdate" value="TRUE"/> </td> </tr> </table> </center> </form>'; } if(isset($_POST['submitted'])) { $prodId = trim($_REQUEST['prodId']); $shopName= $_REQUEST['shopName']; $query3 = "SELECT * FROM product WHERE prodId = '$prodId' and shopName='$shopName'"; $result3 = @mysql_query($query3) or die("Unable to perform query3 <code>" . $query3 . "</code><br /><br />" . mysql_error()); echo'<form action="admin_update.php" method="post"> <center> <table align="center" cellspacing="0" cellpadding="5" bgcolor="#ffffff" border=1 bordercolor="#2696b8"> '; while($row = mysql_fetch_array($result3, MYSQL_ASSOC)) { echo'<tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Id</b></center></td> <td align="left">' . $row['prodId'] . '</td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Shop Name</b></td> <td align="left">' . $row['shopName'] . '</td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Product Name</b></td> <td align="left"><input type="text" name="prodName" size="30" maxlength="30" value="' . $row['prodName'] . '"/></td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Department</b></td> <td align="left"><input type="text" name="dept" size="20" maxlength="20" value="' . $row['dept'] . '"/></td> </tr> <tr> <td align="left" bgcolor="#2696b8"><center><font color="black"><b>Price</b></td> <td align="left"><input type="text" name="price" size="50" maxlength="50" value="' . $row['price'] . '"/></td> </tr> '; } echo'<tr> <td align="center"> <input type="submit" name="submit" value="UPDATE"/> <!--<input type="reset" value="CLEAR FORM"></p>--> </td> </tr> <tr> <td align="center"> <input type="hidden" name="prodId" value=' . $prodId . '> <input type="hidden" name="shopName" value=' . $shopName . '> <input type="hidden" name="submittedUpdate" value="TRUE"/> </td> </tr> </table> </center> </form>'; } ?> </body> </html>[/code] I changed your get/post vars to $_REQUEST. $_REQUEST includes _POST and _GET vars.
-
If its in a different directory then the scrpt being servered. Use this: INCLUDE '../webmaster/functions.php'; The .. tells to PHP to go one higher up the directory tree.
-
Okay you are ussing POST as the method to submit the forms, but in your PHP script you use $_GET. $_GET retrieves the url parameters in the URL. Whereas $_POST retrieves the posted data. So chnage $_GET to $_POST in your code. Does it work now? If you add 1 to the end of the url when you click the [i]Click here to modify and delete Records[/i] in admin_index.php. You'll get some results http://snet.wit.ie/~ciaracousins/admin_delete.php?login=true&id=1
-
To put alex in to the table you need to insert it into the database with an sql query: [code=php:0]// setup our query $sql = "INSERT INTO test (Image_Name, Image_URL) VALUES ('alex', 'images/')"; // preform the query $result = mysql_query($sql) or die(mysql_error());[/code]
-
Make sure you have turned down error reporting so it ignores notices. However you should check user defined variables are set before using them, just like above rather than taking the easy route.
-
Sorry, I am not being very alert today. Use this: $prodId = isset($_GET['prodId']) ? $_GET['prodId'] : '0'; I forgot the semi-colon, at the end of the line.
-
We did have such a system, well not a points system but a karma system. Member could either grace (if you helped someone) or smite (if you wasnt helpfull at helping someone) If a user clicked smite the'l get more good karma. If user clicked smite you'll get more bad karma. However this was taken down as it was uneeded and wasn't very accurate. A point system is kinda usless too.
-
Session help please. early post Still unsolved!
wildteen88 replied to spires's topic in PHP Coding Help
[quote author=spires link=topic=106605.msg426703#msg426703 date=1157223368] If i echo the $username out after the: $_SESSION['username'] = $username; $_SESSION['password'] = $password; It echos out the user name, Its also registers the session, Which is very strange? But then the header dont work. e,g $_SESSION['username'] = $username; $_SESSION['password'] = $password; echo $username; header('Location: add_banner.php'); the 'Your Accout' doesn't have any sessions on the page its goes to yet. Here is a test username and password test test [/quote] $username is not your session variable. That variable is the variable you setup ealier to to get the username form the _POST['username'] array. To echo the username session you'll want to use [code=php:0]echo $_SESSION['username'];[/code] -
You cannot run PHP code in onClick or any other on* atrributes within a html tag. PHP process the php code on a per request basis. You cannot treat PHP like you can with javascript. In your code your sum session will allways be set to 4 regardless the user clicks the button1 button or not,
-
Oh crap. Another typo of mine. Change this: [code]$prodId = isset($_GET['prodId']) && is_numeric($_GET['prodId']) ? $_GET['prodId'] : 'INVALID'; if($prodid == 'INVALID') { die('<h1>Invalid Production Identification</h1>'); }[/code] to this: [code]$prodId = isset($_GET['prodId'])) ? $_GET['prodId'] : '0'[/code]
-
Before you use user defined variables (_POST, _GET, _REQUEST etc). You should check that they exist first. For example: [code=php:0]if(isset($_REQUEST['do']) || !empty($_REQUEST['do'])) { // use $_REQUEST['do'] }[/code] Doing that will stopo the undefined index notice message appearing. Or just turn down error_report so it ignores notices
-
In query1: [b]UPDATE product SET prodName='$prodName', dept='$dept', brand='$brand', type='$type', image='$image', price='$price' WHERE prodId ='$prodId' and shopName='$shopName'[/b] You use $prodName to update the prodName field. Where does $prodName come from, as this is mostl ikey why it is being [b]deleted[/b] as $prodName doesnt exist [b]To redarrow[/b] -mysql_result is basically another form of retrieve results from an SQL Query. I have not used this before so I cant really explain it. Have a read in the manual about it http://php.net/mysql-query
-
kikilahooch Did you try the correction I suggested in my last post? [quote author=wildteen88 link=topic=106622.msg426669#msg426669 date=1157221176] Oops missed typed something Change this line: [code]$result2 = @mysql_query($query) or die("Unable to perform query2 <code>" . $query2 . "</code><br /><br />" . mysql_error());[/code] to this: [code]$result2 = @mysql_query($query2) or die("Unable to perform query2 <code>" . $query2 . "</code><br /><br />" . mysql_error());[/code] [/quote]