uncaringuser Posted May 18, 2012 Share Posted May 18, 2012 I am not adequate at PHP at all, I mostly dabble in HTML and CSS. The problem here is that I have a form which has been assigned unique variables via database. The user would select a checkbox and the value associated with it based on its name and id, would display the appropriate value on the next page. For whatever reason when I active my form it just comes up with the word "Array". Below is the code for both pages and I would be greatly appreciated if you could help me resolve this error and point me in the right direction to achieve my goal. FORM WITH UNIQUE VARIABLES <code> <?php $con = mysql_connect("database details"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("webnw_catering", $con); $result= mysql_query("SELECT * FROM starters WHERE category='meat'"); while($row = mysql_fetch_array($result)) { $nameid = $row['nameid']; $amountid = $row['amountid']; $title = $row['title']; $checkbox = $_POST['checkbox']; echo"<tr>"; echo"<td>"; echo"<p class=\"form2\">"; echo $row["title"]; echo " - £"; echo $row["price"]; echo"<br>"; echo"<span class=\"subtext\">". $row['subtext'] . "</span>"; echo"</p>"; echo"</td>"; echo"<td class=\"addon\">"; echo"<input type=\"checkbox\" class=\"largecheckbox\" name=\"checkbox[{$row['title']}]\" id =\"$nameid\" value=\"$title\">"; echo"</td>"; echo"<td class=\"addon\">"; echo"<input type=\"text\" class=\"amount\" name=\"amount[]\" id =\"$amountid\">"; echo"</td>"; echo"</tr>"; } echo ""; mysql_close($con); ?> </code> RESPONSE PAGE <code> <div id="middle"> <div id="stepcontent" class="form"> <div id="content-left"> <img src="./images/meat.png" class="food"><br><br> <table class="food"> <tr> <td><p class="form2"><?php echo $_POST["checkbox"]; ?></p></td> </tr> <tr> <td><p class="form2"></p></td> </tr> </table> </div> </code> Quote Link to comment https://forums.phpfreaks.com/topic/262733-array-error-help/ Share on other sites More sharing options...
Ivan Ivković Posted May 18, 2012 Share Posted May 18, 2012 Did you really post the form? You have no form tags in your HTML. Your amount is array? Should not be. Quote Link to comment https://forums.phpfreaks.com/topic/262733-array-error-help/#findComment-1346597 Share on other sites More sharing options...
uncaringuser Posted May 18, 2012 Author Share Posted May 18, 2012 I did, and I know but it is, I dunno why it is coming up with it, I'm stumped. Here's the entire code in a more appropriate format. <!DOCTYPE html> <html> <head> <title>Mistrys Catering</title> <link rel="stylesheet" type="text/css" href="style.css"/> </head> <body> <div id="canvas"> <div id="header"> <div id="logo"></div> <div id="slogan"></div> </div> <div id="top"> <div id="step">Step 3 of 10</div><div id="detail"><img src="./images/starters.png"></div> </div> <div id="middle"> <div id="stepcontent" class="form"> <div id="content-left"> <img src="./images/meat.png" class="food"><br><br> <form method="post" action="step4.php"> <table class="food"> <?php $con = mysql_connect("database details"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("webnw_catering", $con); $result= mysql_query("SELECT * FROM starters WHERE category='meat'"); while($row = mysql_fetch_array($result)) { $nameid = $row['nameid']; $amountid = $row['amountid']; $title = $row['title']; $checkbox = $_POST['checkbox']; echo"<tr>"; echo"<td>"; echo"<p class=\"form2\">"; echo $row["title"]; echo " - £"; echo $row["price"]; echo"<br>"; echo"<span class=\"subtext\">". $row['subtext'] . "</span>"; echo"</p>"; echo"</td>"; echo"<td class=\"addon\">"; echo"<input type=\"checkbox\" class=\"largecheckbox\" name=\"checkbox[{$row['title']}]\" id =\"$nameid\" value=\"$title\">"; echo"</td>"; echo"<td class=\"addon\">"; echo"<input type=\"text\" class=\"amount\" name=\"amount[]\" id =\"$amountid\">"; echo"</td>"; echo"</tr>"; } echo ""; mysql_close($con); ?> </table> </div> <div id="content-right"> <img src="./images/veg.png" class="food"><br><br> <table class="food"> </table> </div><br> </div> </div> <div id="bottom"> <div id="build"></div> <div id="backbutt"><a href="step2.html"><img src="./images/prevbutt.png"></a></div> <div id="nextbutt"><input type="image" src="./images/nextbutt.png"></div> </form> </div> </div> <div id="footer"> <p class="footer">Mistrys Catering | 01204 527 139 | [email protected]</p> </div> </div> </body> </html> <!DOCTYPE html> <html> <head> <title>Mistrys Catering</title> <link rel="stylesheet" type="text/css" href="style.css"/> </head> <body> <div id="canvas"> <div id="header"> <div id="logo"></div> <div id="slogan"></div> </div> <div id="top"> <div id="step">Step 4 of 10</div><div id="detail"><img src="./images/starters.png"></div> </div> <div id="middle"> <div id="stepcontent" class="form"> <div id="content-left"> <img src="./images/meat.png" class="food"><br><br> <table class="food"> <tr> <td><p class="form2"><?php echo $_POST["checkbox"]; ?></p></td> </tr> <tr> <td><p class="form2"></p></td> </tr> </table> </div> <div id="content-right"> <img src="./images/veg.png" class="food"><br><br> <table class="food"> <tr> <td><p class="form2"></p></td> </tr> <tr> <td><p class="form2"></p></td> </tr> </table> </div><br> </div> </div> <div id="bottom"> <div id="build"></div> <div id="backbutt"><a href="step2.html"><img src="./images/prevbutt.png"></a></div> <div id="nextbutt"><input type="image" src="./images/nextbutt.png"></div> </form> </div> </div> <div id="footer"> <p class="footer">Mistrys Catering | 01204 527 139 | [email protected]</p> </div> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/262733-array-error-help/#findComment-1346598 Share on other sites More sharing options...
Ivan Ivković Posted May 18, 2012 Share Posted May 18, 2012 Can you upload and give me the link to the database file? I'll sort it out on my localhost later, haven't got the time now. If these 2 php files are all I need. Cheers! Quote Link to comment https://forums.phpfreaks.com/topic/262733-array-error-help/#findComment-1346622 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.