Note that there are some explanatory texts on larger screens.

plurals
  1. PObuilding a product edit page using PDO
    primarykey
    data
    text
    <p>Apart of my finals project is to build a product edit page in PHP. The problem is my instructor stopped teaching PDO early on as one of the students claimed their webserver did not support it. So I have had to teach myself PDO and my instructor gradually started placing PDO versions of the code in the class website. The problem is he never did on based on the product edit page and I am at a stand still. He had suggested I use bindParam() in place of what I was doing, but it did not help. I have been stuck in this one spot for sometime and most of the website is finished with the exception of a couple of pages. here is the code from my product edit page, and as always, thank you for any help that can be provided.</p> <pre><code>&lt;?php $page_title = 'Product Edit'; require '../inc/header.php'; ?&gt; &lt;?php if ($_SERVER["REQUEST_METHOD"] == "POST") { $query = " UPDATE fin_prod( prod_model, prod_desc, prod_price, prod_vol, prod_img1, prod_img1_desc, prod_img2, prod_img2_desc, prod_img3, prod_img3_desc, prod_img4, prod_img4_desc, prod_img5, prod_img5_desc, prod_ulvl, prod_cat, prod_type, prod_manu, prod_view, prod_imaging, prod_op_design, prod_focal_length, prod_op_dia, prod_focal_ratio, prod_op_type, prod_glass, prod_eye1, prod_eye1_mag, prod_eye2, prod_eye2_mag, prod_low_mag, prod_high_mag, prod_theo_mag, prod_lim_stel, prod_op_qual, prod_finder, prod_focus, prod_sec_obs, prod_sec_obs_dia, prod_sec_obs_area, prod_coat, prod_mount_type, prod_astro_img, prod_comp, prod_mat_bear, prod_mat_mount, prod_tube_len, prod_weight_tube, prod_weight_mnt, prod_feat, prod_warranty ) VALUES( :prodmodel, :proddesc, :prodprice, :prodvol, :prodimg1, :prodimg1_desc, :prodimg2, :prodimg2_desc, :prodimg3, :prodimg3_desc, :prodimg4, :prodimg4_desc, :prodimg5, :prodimg5_desc, :prodlvl, :prodcat, :prodtype, :prodmanu, :prodview, :prodimaging, :prod_opdesign, :prod_focallen, :prod_opdia, :prod_focalratio, :prod_optype, :prodglass, :prodeye1, :prodeye1_mag, :prodeye2, :prodeye2_mag, :prod_maglow, :prod_maghigh, :prod_magtheo, :prod_limstel, :prod_opqual, :prodfinder, :prodfocus, :prod_secobs, :prod_secobs_dia, :prod_secobs_area, :prodcoat, :prodmnt_type, :prodastro, :prodcomp, :prodmat_bear, :prodmat_mount, :prodtube_len, :prodweight_tube, :prodweight_mnt, :prodfeat, :prodwarranty ) "; /*$queryparams = array( ':prodmodel' =&gt; $prod_model, ':proddesc' =&gt; $prod_desc, ':prodprice' =&gt; $prod_price, ':prodvol' =&gt; $prod_vol, ':prodimg1' =&gt; $prod_img1, ':prodimg1_desc' =&gt; $prod_img1_desc, ':prodimg2' =&gt; $prod_img2, ':prodimg2_desc' =&gt; $prod_img2_desc, ':prodimg3' =&gt; $prod_img3, ':prodimg3_desc' =&gt; $prod_img3_desc, ':prodimg4' =&gt; $prod_img4, ':prodimg4_desc' =&gt; $prod_img4_desc, ':prodimg5' =&gt; $prod_img5, ':prodimg5_desc' =&gt; $prod_img5_desc, ':prodlvl' =&gt; $prod_ulvl, ':prodtype' =&gt; $prod_type, ':prodmanu' =&gt; $prod_manu, ':prodview' =&gt; $prod_view, ':prodimaging' =&gt; $prod_imaging, ':prod_opdesign' =&gt; $prod_op_design, ':prod_focallen' =&gt; $prod_focal_len, ':prod_opdia' =&gt; $prod_op_dia, ':prod_focalratio' =&gt; $prod_focal_ratio, ':prod_optype' =&gt; $prod_op_type, ':prodglass' =&gt; $prod_glass, ':prodeye1' =&gt; $prod_eye1, ':prodeye1_mag' =&gt; $prod_eye1_mag, ':prodeye2' =&gt; $prod_eye2, ':prodeye2_mag' =&gt; $prod_eye2_mag, ':prod_maglow' =&gt; $prod_mag_low, ':prod_maghigh' =&gt; $prod_mag_high, ':prod_magtheo' =&gt; $prod_mag_theo, ':prod_limstel' =&gt; $prod_lim_stel, ':prod_opqual' =&gt; $prod_op_qual, ':prodfinder' =&gt; $prod_finder, ':prodfocus' =&gt; $prod_focus, ':prod_secobs' =&gt; $prod_sec_obs, ':prod_secobs_dia' =&gt; $prod_sec_obs_dia, ':prod_secobs_area' =&gt; $prod_sec_obs_area, ':prodcoat' =&gt; $prod_coat, ':prodmnt_type' =&gt; $prod_mnt_type, ':prodastro' =&gt; $prod_astro, ':prodcomp' =&gt; $prod_comp, ':prodmat_bear' =&gt; $prod_mat_bear, ':prodmat_mount' =&gt; $prod_mat_mount, ':prodtube_len' =&gt; $prod_tube_len, ':prodweight_tube' =&gt; $prod_weight_tube, ':prodweight_mnt' =&gt; $prod_weight_mnt, ':prodfeat' =&gt; $prod_feat, ':prodwarranty' =&gt; $prod_warranty );*/ $stmt = $db-&gt;prepare($query); $result = $stmt-&gt;execute($queryparams); $rows = $result-&gt;fetchAll(); exit; } else { $prod_id = $_GET['id']; if (strlen($prod_id) &gt; 0) { $query = " SELECT * FROM fin_prod WHERE prod_id=$prod_id "; $stmt = $db-&gt;prepare($query); $stmt-&gt;bindParam(':prod_id', $prod_id); $stmt-&gt;execute(); /* $stmt-&gt;fetchAll();*/ while($rows = $stmt-&gt;fetchAll()) { $prod_model = $rows['prod_model']; $prod_desc = $rows['prod_desc']; $prod_price = $rows['prod_price']; $prod_vol = $rows['prod_vol']; $prod_img1 = $rows['prod_img1']; $prod_img1_desc = $rows['prod_img1_desc']; $prod_img2 = $rows['prod_img2']; $prod_img2_desc = $rows['prod_img2_desc']; $prod_img3 = $rows['prod_img3']; $prod_img3_desc = $rows['prod_img3_desc']; $prod_img4 = $rows['prod_img4']; $prod_img4_desc = $rows['prod_img4_desc']; $prod_img5 = $rows['prod_img5']; $prod_img5_desc = $rows['prod_img5_desc']; $prod_ulvl = $rows['prod_ulvl']; $prod_type = $rows['prod_type']; $prod_manu = $rows['prod_manu']; $prod_view = $rows['prod_view']; $prod_imaging = $rows['prod_imaging']; $prod_op_design = $rows['prod_op_design']; $prod_focal_len = $rows['prod_focal_len']; $prod_op_dia = $rows['prod_op_dia']; $prod_focal_ratio = $rows['prod_focal_ratio']; $prod_op_type = $rows['prod_op_type']; $prod_glass = $rows['prod_glass']; $prod_eye1 = $rows['prod_eye1']; $prod_eye1_mag = $rows['prod_eye1_mag']; $prod_eye2 = $rows['prod_eye2']; $prod_eye2_mag = $rows['prod_eye2_mag']; $prod_mag_low = $rows['prod_mag_low']; $prod_mag_high = $rows['prod_mag_high']; $prod_mag_theo = $rows['prod_mag_theo']; $prod_lim_stel = $rows['prod_lim_stel']; $prod_op_qual = $rows['prod_op_qual']; $prod_finder = $rows['prod_finder']; $prod_focus = $rows['prod_focus']; $prod_sec_obs = $rows['prod_sec_obs']; $prod_sec_obs_dia = $rows['prod_sec_obs_dia']; $prod_sec_obs_area = $rows['prod_sec_obs_area']; $prod_coat = $rows['prod_coat']; $prod_mnt_type = $rows['prod_mnt_type']; $prod_astro = $rows['prod_astro']; $prod_comp = $rows['prod_comp']; $prod_mat_bear = $rows['prod_mat_bear']; $prod_mat_mount = $rows['prod_mat_mount']; $prod_tube_len = $rows['prod_tube_len']; $prod_weight_tube = $rows['prod_weight_tube']; $prod_weight_mnt = $rows['prod_weight_mnt']; $prod_feat = $rows['prod_feat']; $prod_warranty = $rows['prod_warranty']; } } else { echo "Invalid Item ID"; exit; } } ?&gt; &lt;div class="product-edit-wrapper"&gt; &lt;div class="edit-name"&gt; &lt;h1&gt;Edit Product &amp;raquo; &lt;?php echo $prod_model; ?&gt;&lt;/h1&gt; &lt;/div&gt; &lt;/div&gt; &lt;?php include '../inc/footer.php'; ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload