imimin Posted July 10, 2009 Author Share Posted July 10, 2009 I did it like this: if($get_items){ $item_row = mysql_fetch_assoc($get_items); extract($item_row); $price = $retail * .75; echo <<<HTML <IMG SRC=\includes/img_resize3.php?src=$sitelocation$img&width=175&height=175&qua=100\" BORDER=\"0\"> <BR> Sample image of selected <BR>garment</P> and it did not work. I am pretty sure I need to have the "echo <<<HTML" where I have it, it won't work if I put it in 2 or more places, right?? Quote Link to comment https://forums.phpfreaks.com/topic/165217-solved-help-needed-with-passing-id-through-url/page/4/#findComment-872906 Share on other sites More sharing options...
p2grace Posted July 10, 2009 Share Posted July 10, 2009 Were there any php errors? Quote Link to comment https://forums.phpfreaks.com/topic/165217-solved-help-needed-with-passing-id-through-url/page/4/#findComment-872909 Share on other sites More sharing options...
imimin Posted July 10, 2009 Author Share Posted July 10, 2009 No Quote Link to comment https://forums.phpfreaks.com/topic/165217-solved-help-needed-with-passing-id-through-url/page/4/#findComment-872910 Share on other sites More sharing options...
p2grace Posted July 10, 2009 Share Posted July 10, 2009 Hmm then it should work... you can use more than one heredoc if you'd rather try that. echo <<<HTML This is heredoc 1 HTML; echo <<<HTML This is heredoc 2 HTML; Quote Link to comment https://forums.phpfreaks.com/topic/165217-solved-help-needed-with-passing-id-through-url/page/4/#findComment-872913 Share on other sites More sharing options...
imimin Posted July 10, 2009 Author Share Posted July 10, 2009 Does not work. Setting up like this: $price = $retail * .75; <<<HTML <input type='hidden' name='name' value='$prod_name' /> <input type='hidden' name='price' value='$retail' /> Getting following error: Notice: Undefined variable: price in /homepages/27/d120150310/htdocs/poj/poj_order_form.php on line 247 and the following is printing when it should not: = 42.99 * .75; << Quote Link to comment https://forums.phpfreaks.com/topic/165217-solved-help-needed-with-passing-id-through-url/page/4/#findComment-872917 Share on other sites More sharing options...
p2grace Posted July 10, 2009 Share Posted July 10, 2009 This should be: $price = $retail * .75; <<<HTML <input type='hidden' name='name' value='$prod_name' /> <input type='hidden' name='price' value='$price' /> Which line is 247? Quote Link to comment https://forums.phpfreaks.com/topic/165217-solved-help-needed-with-passing-id-through-url/page/4/#findComment-872918 Share on other sites More sharing options...
imimin Posted July 10, 2009 Author Share Posted July 10, 2009 Getting following errors: Notice: Undefined variable: price in /homepages/27/d120150310/htdocs/poj/poj_order_form.php on line 247 Notice: Undefined variable: price in /homepages/27/d120150310/htdocs/poj/poj_order_form.php on line 251 and printing incorrectly: = 39.99 * .75; << Quote Link to comment https://forums.phpfreaks.com/topic/165217-solved-help-needed-with-passing-id-through-url/page/4/#findComment-872923 Share on other sites More sharing options...
p2grace Posted July 10, 2009 Share Posted July 10, 2009 Which lines are 247 and 251? Quote Link to comment https://forums.phpfreaks.com/topic/165217-solved-help-needed-with-passing-id-through-url/page/4/#findComment-872925 Share on other sites More sharing options...
imimin Posted July 10, 2009 Author Share Posted July 10, 2009 Line 247: $price = $retail * .75; Line 251: <input type='hidden' name='price' value='$price' /> Quote Link to comment https://forums.phpfreaks.com/topic/165217-solved-help-needed-with-passing-id-through-url/page/4/#findComment-872927 Share on other sites More sharing options...
p2grace Posted July 10, 2009 Share Posted July 10, 2009 It's throwing the error because the "$price = $retail * .75;" is within the heredoc. It must be placed outside of any heredoc syntax. That will fix both issues. Quote Link to comment https://forums.phpfreaks.com/topic/165217-solved-help-needed-with-passing-id-through-url/page/4/#findComment-872929 Share on other sites More sharing options...
imimin Posted July 10, 2009 Author Share Posted July 10, 2009 It is outside the heredoc! <?php /* Enable displaying of errors */ error_reporting(E_ALL); ini_set('display_errors', 'On'); // Ensure id was set if(!isset($_GET['id'])){ die("Id isn't set"); } // Clean the id $id = mysql_real_escape_string($_GET['id']); // Query Database $get_items = "SELECT * FROM poj_products WHERE `id` = '$id'"; $get_items = mysql_query($get_items); if($get_items){ $item_row = mysql_fetch_assoc($get_items); extract($item_row); echo <<<HTML <IMG SRC=\includes/img_resize3.php?src=$sitelocation$img&width=175&height=175&qua=100\" BORDER=\"0\"> HTML; <BR> Sample image of selected <BR>garment</P> </TD> <TD width=25%> <B>Garment Color:</B> <SCRIPT LANGUAGE="javascript"> GarmentColorArray = new Array (9); GarmentColorArray[1] = "RedHib2.jpg"; GarmentColorArray[2] = "DarkBlueHib2.jpg"; GarmentColorArray[3] = "TurquoiseHib3.jpg"; GarmentColorArray[4] = "PurpleHib2.jpg"; GarmentColorArray[5] = "blue.jpg"; GarmentColorArray[6] = "white.jpg"; GarmentColorArray[7] = "pink.jpg"; GarmentColorArray[8] = "AmerFlag.jpg"; GarmentColorArray[9] = "100DollarBill.jpg"; function GarmentColorImageSwap(imgBase,imgIndex) { Index = imgIndex + 1; document.GarmentColorImage.src = '/images/swatches/' + GarmentColorArray[index]; } </SCRIPT> <script language="JavaScript"> /*********************************************** * Required field(s) validation v1.10- By NavSurf * Visit Nav Surf at http://navsurf.com * Visit http://www.dynamicdrive.com/ for full source code ***********************************************/ function formCheck(formobj){ // Enter name of mandatory fields var fieldRequired = Array("custom10", "custom20", "custom30", "custom40"); // Enter field description to appear in the dialog box var fieldDescription = Array("Garment Color", "Garment Style", "Size Range", "Garment Size"); // dialog message var alertMsg = "Please complete the following fields:\n"; var l_Msg = alertMsg.length; for (var i = 0; i < fieldRequired.length; i++){ var obj = formobj.elements[fieldRequired[i]]; if (obj){ switch(obj.type){ case "select-one": if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; case "select-multiple": if (obj.selectedIndex == -1){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; case "text": case "textarea": if (obj.value == "" || obj.value == null){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; default: } if (obj.type == undefined){ var blnchecked = false; for (var j = 0; j < obj.length; j++){ if (obj[j].checked){ blnchecked = true; } } if (!blnchecked){ alertMsg += " - " + fieldDescription[i] + "\n"; } } } } if (alertMsg.length == l_Msg){ return true; }else{ alert(alertMsg); return false; } } </script> <FORM METHOD=POST ACTION="https://secure.impact-impressions.com/cgi-bin/cart.pl" onsubmit="return formCheck(this);"> <SELECT NAME="custom10" SIZE=9 ONCHANGE="GarmentColorImageSwap('GarmentColorImage', this.selectedIndex)" SIZE="1"> <OPTION VALUE='Color: RED Hibiscus'>RED Hibiscus</OPTION> <OPTION VALUE='Color: Dark Blue Hibiscus'>Dark Blue Hibiscus</OPTION> <OPTION VALUE='Color: Turquoise Hibiscus'>Turquoise Hibiscus</OPTION> <OPTION VALUE='Color: Purple Hibiscus'>Purple Hibiscus</OPTION> <OPTION VALUE='Color: Blue'>Blue</OPTION> <OPTION VALUE='Color: White'>White</OPTION> <OPTION VALUE='Color: Pink'>Pink</OPTION> <OPTION VALUE='Color: American Flag'>American Flag</OPTION> <OPTION VALUE='Color: Hundred Dollar Bill'>Hundred Dollar Bill</OPTION> </SELECT> <BR> <A HREF="javascript:newwindow()" >View All Color Choices</A> </TD> <TD ROWSPAN=2 valign="top"><P align=center><IMG ALIGN='top' BORDER='0' HEIGHT='175' NAME='GarmentColorImage' SRC='/images/swatches/blank.jpg' WIDTH='175'> <BR> Image of Garment Color <BR>selected. NOTE: Colors <BR>may vary.</P> </TD> </TR> <TR> <TD> $price = $retail * .75; <<<HTML <input type='hidden' name='name' value='$prod_name' /> <input type='hidden' name='price' value='$price' /> <input type='hidden' name='sh' value='$weight' /> <input type='hidden' name='img' value='https://secure.impact-impressions.com/poj/includes/img_resize3.php?src=$sitelocation$img&width=100&height=100&qua=50' /> <input type='hidden' name='img2' value='' /> <input type='hidden' name='return' value='http://www.patternsofjoy.com/order_more.php' /> <input type='RADIO' name='custom20' value='Style: $selected_style' checked='checked' style='display: none' /> <strong>Garment Style: </strong>$selected_style <br /> <a href="http://www.patternsofjoy.com/order_more.php" TITLE="Click here to change Garement Style">***Change Garment Style***</a> </TD> </TR> <TR> <TD> <B>Size Range:</B><BR> <INPUT TYPE="RADIO" NAME=custom30 VALUE="Size Range: Adult +$2.00"> Adult <INPUT TYPE="RADIO" NAME=custom30 VALUE="Size Range: Child"> Child<BR> </TD> <td> Adult and Teen Sizing Chart: $adult_size_chart<br /> </td> </tr> <tr> <td> <strong>Garmet Size:</strong> <select id="custom40" name="custom40" size='5'> <option value="Size: Small (S)">Small (S)</option> <option value="Size: Medium (M)">Medium (M)</option> <option value="Size: Large (L)">Large (L)</option> <option value="Size: Extra Large (L)">Extra Large (L)</option> <option value="Size: Toddler (T)">Toddler (T)</option> </select><br /> <a href="javascript:newwindow2();" >Garment Measuring Tips</a> </td> <td> Child Sizing Chart: $child_size_chart<br /> </td> </tr> HTML; }else{ die("Unable to connect to database.".mysql_error()); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/165217-solved-help-needed-with-passing-id-through-url/page/4/#findComment-872931 Share on other sites More sharing options...
p2grace Posted July 10, 2009 Share Posted July 10, 2009 No... you see how the heredoc started on line 20 is never ended, so you actually have a heredoc within a heredoc. Try the following: <?php /* Enable displaying of errors */ error_reporting(E_ALL); ini_set('display_errors', 'On'); // Ensure id was set if(!isset($_GET['id'])){ die("Id isn't set"); } // Clean the id $id = mysql_real_escape_string($_GET['id']); // Query Database $get_items = "SELECT * FROM poj_products WHERE `id` = '$id'"; $get_items = mysql_query($get_items); if($get_items){ $item_row = mysql_fetch_assoc($get_items); extract($item_row); echo <<<HTML <IMG SRC="includes/img_resize3.php?src=$sitelocation$img&width=175&height=175&qua=100" BORDER="0"> HTML; <BR> Sample image of selected <BR>garment</P> </TD> <TD width=25%> <B>Garment Color:</B> <SCRIPT LANGUAGE="javascript"> GarmentColorArray = new Array (9); GarmentColorArray[1] = "RedHib2.jpg"; GarmentColorArray[2] = "DarkBlueHib2.jpg"; GarmentColorArray[3] = "TurquoiseHib3.jpg"; GarmentColorArray[4] = "PurpleHib2.jpg"; GarmentColorArray[5] = "blue.jpg"; GarmentColorArray[6] = "white.jpg"; GarmentColorArray[7] = "pink.jpg"; GarmentColorArray[8] = "AmerFlag.jpg"; GarmentColorArray[9] = "100DollarBill.jpg"; function GarmentColorImageSwap(imgBase,imgIndex) { Index = imgIndex + 1; document.GarmentColorImage.src = '/images/swatches/' + GarmentColorArray[index]; } </SCRIPT> <script language="JavaScript"> /*********************************************** * Required field(s) validation v1.10- By NavSurf * Visit Nav Surf at http://navsurf.com * Visit http://www.dynamicdrive.com/ for full source code ***********************************************/ function formCheck(formobj){ // Enter name of mandatory fields var fieldRequired = Array("custom10", "custom20", "custom30", "custom40"); // Enter field description to appear in the dialog box var fieldDescription = Array("Garment Color", "Garment Style", "Size Range", "Garment Size"); // dialog message var alertMsg = "Please complete the following fields:\n"; var l_Msg = alertMsg.length; for (var i = 0; i < fieldRequired.length; i++){ var obj = formobj.elements[fieldRequired[i]]; if (obj){ switch(obj.type){ case "select-one": if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; case "select-multiple": if (obj.selectedIndex == -1){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; case "text": case "textarea": if (obj.value == "" || obj.value == null){ alertMsg += " - " + fieldDescription[i] + "\n"; } break; default: } if (obj.type == undefined){ var blnchecked = false; for (var j = 0; j < obj.length; j++){ if (obj[j].checked){ blnchecked = true; } } if (!blnchecked){ alertMsg += " - " + fieldDescription[i] + "\n"; } } } } if (alertMsg.length == l_Msg){ return true; }else{ alert(alertMsg); return false; } } </script> <FORM METHOD=POST ACTION="https://secure.impact-impressions.com/cgi-bin/cart.pl" onsubmit="return formCheck(this);"> <SELECT NAME="custom10" SIZE=9 ONCHANGE="GarmentColorImageSwap('GarmentColorImage', this.selectedIndex)" SIZE="1"> <OPTION VALUE='Color: RED Hibiscus'>RED Hibiscus</OPTION> <OPTION VALUE='Color: Dark Blue Hibiscus'>Dark Blue Hibiscus</OPTION> <OPTION VALUE='Color: Turquoise Hibiscus'>Turquoise Hibiscus</OPTION> <OPTION VALUE='Color: Purple Hibiscus'>Purple Hibiscus</OPTION> <OPTION VALUE='Color: Blue'>Blue</OPTION> <OPTION VALUE='Color: White'>White</OPTION> <OPTION VALUE='Color: Pink'>Pink</OPTION> <OPTION VALUE='Color: American Flag'>American Flag</OPTION> <OPTION VALUE='Color: Hundred Dollar Bill'>Hundred Dollar Bill</OPTION> </SELECT> <BR> <A HREF="javascript:newwindow()" >View All Color Choices</A> </TD> <TD ROWSPAN=2 valign="top"><P align=center><IMG ALIGN='top' BORDER='0' HEIGHT='175' NAME='GarmentColorImage' SRC='/images/swatches/blank.jpg' WIDTH='175'> <BR> Image of Garment Color <BR>selected. NOTE: Colors <BR>may vary.</P> </TD> </TR> <TR> <TD> HTML; $price = $retail * .75; echo <<<HTML <input type='hidden' name='name' value='$prod_name' /> <input type='hidden' name='price' value='$price' /> <input type='hidden' name='sh' value='$weight' /> <input type='hidden' name='img' value='https://secure.impact-impressions.com/poj/includes/img_resize3.php?src=$sitelocation$img&width=100&height=100&qua=50' /> <input type='hidden' name='img2' value='' /> <input type='hidden' name='return' value='http://www.patternsofjoy.com/order_more.php' /> <input type='RADIO' name='custom20' value='Style: $selected_style' checked='checked' style='display: none' /> <strong>Garment Style: </strong>$selected_style <br /> <a href="http://www.patternsofjoy.com/order_more.php" TITLE="Click here to change Garement Style">***Change Garment Style***</a> </TD> </TR> <TR> <TD> <B>Size Range:</B><BR> <INPUT TYPE="RADIO" NAME=custom30 VALUE="Size Range: Adult +$2.00"> Adult <INPUT TYPE="RADIO" NAME=custom30 VALUE="Size Range: Child"> Child<BR> </TD> <td> Adult and Teen Sizing Chart: $adult_size_chart<br /> </td> </tr> <tr> <td> <strong>Garmet Size:</strong> <select id="custom40" name="custom40" size='5'> <option value="Size: Small (S)">Small (S)</option> <option value="Size: Medium (M)">Medium (M)</option> <option value="Size: Large (L)">Large (L)</option> <option value="Size: Extra Large (L)">Extra Large (L)</option> <option value="Size: Toddler (T)">Toddler (T)</option> </select><br /> <a href="javascript:newwindow2();" >Garment Measuring Tips</a> </td> <td> Child Sizing Chart: $child_size_chart<br /> </td> </tr> HTML; }else{ die("Unable to connect to database.".mysql_error()); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/165217-solved-help-needed-with-passing-id-through-url/page/4/#findComment-872933 Share on other sites More sharing options...
imimin Posted July 10, 2009 Author Share Posted July 10, 2009 Your code worked, I don't understand? I thought I ended it on line 25 and you put the same ending on line 155???????? Quote Link to comment https://forums.phpfreaks.com/topic/165217-solved-help-needed-with-passing-id-through-url/page/4/#findComment-872935 Share on other sites More sharing options...
p2grace Posted July 10, 2009 Share Posted July 10, 2009 Yeah... the logic to calculate the price cannot be contained within heredoc. So I ended the first heredoc on line 155 with the HTML;. Then the $price is calculated, and a new heredoc is started, ending at line 205. I'd recommend reading over the examples of heredoc at the url below. http://us.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc Quote Link to comment https://forums.phpfreaks.com/topic/165217-solved-help-needed-with-passing-id-through-url/page/4/#findComment-872938 Share on other sites More sharing options...
imimin Posted July 10, 2009 Author Share Posted July 10, 2009 Why didn't the end heredoc (HTML;) I put on line 25 work? Quote Link to comment https://forums.phpfreaks.com/topic/165217-solved-help-needed-with-passing-id-through-url/page/4/#findComment-872940 Share on other sites More sharing options...
wildteen88 Posted July 10, 2009 Share Posted July 10, 2009 Because it is indented. The closing HEREDOC indentifier (HTML;) must on its own line with nothing before or after it. Quote Link to comment https://forums.phpfreaks.com/topic/165217-solved-help-needed-with-passing-id-through-url/page/4/#findComment-872944 Share on other sites More sharing options...
imimin Posted July 10, 2009 Author Share Posted July 10, 2009 Thanks for all of your help! Quote Link to comment https://forums.phpfreaks.com/topic/165217-solved-help-needed-with-passing-id-through-url/page/4/#findComment-872951 Share on other sites More sharing options...
p2grace Posted July 10, 2009 Share Posted July 10, 2009 That was the opening to the heredoc, each heredoc needs to be closed as well. opening: <<<HTML closing: HTML; Quote Link to comment https://forums.phpfreaks.com/topic/165217-solved-help-needed-with-passing-id-through-url/page/4/#findComment-872964 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.