php - Conditional ISSET issue -


in single product page, product id assigned var $productid. problem when, staying in 1 of fields of form , push enter key, page crashes since script can't find id again. implement script in following way.

<?php $product_id = $_get['product_id']; include '../sys/conn.php'; $risultato = mysqli_query ($conn, "  (mysql query)  ") or die ("query not valid: " . mysqli_error($conn)); mysqli_close($conn); $row = mysqli_fetch_array($risultato); ?> 

that implemented in order if $_get not set properly, set 13321 (example value).

<?php  $product_id = $_get['product_id'];  if(!isset($_get['product_id']){  $product_id='13321'; }else{  include '../sys/conn.php'; $risultato = mysqli_query ($conn, " (mysql query)  ") or die ("query not valid: " . mysqli_error($conn)); mysqli_close($conn); $row = mysqli_fetch_array($risultato); } ?> 

the conditional clause looks not accepted , generates errors such syntax or unexpected variables. help?

---version 2----

<?php $product_id = $_get['product_id'];  if(!isset($_get['product_id'])){      $product_id='13321';}     else  {  include '../sys/conn.php'; $risultato = mysqli_query ($conn, "  (mysql query)  ") or die ("query non valida: " . mysqli_error($conn)); mysqli_close($conn); $row = mysqli_fetch_array($risultato)  } ?> 

and error is: parse error: syntax error, unexpected '}' in /applications/xampp/xamppfiles/htdocs/gest/pages/singolo_prodotto.php on line 66

you missed bracket:

if(!isset($_get['product_id']){  

should be

if(!isset($_get['product_id'])){  

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -