Note that there are some explanatory texts on larger screens.

plurals
  1. POMySQL Result in $row will not echo in if conditional
    primarykey
    data
    text
    <p>I am trying to get the row queried in preceding code to echo inside of this if conditional if the user clicks the modify video link. However, when I echo the $video variable directly above the if ($videoEdit) { conditional, it displays on page, but if I try to echo it inside the if ($videoEdit) { conditional, it will not output for some reason. I'm confused. Here is my code (query not included, but echo $video does output proper results before conditional)</p> <p>Addition:::</p> <pre><code>require ('../mysql_connect.php'); // Connect to DB // Handle Video Edit if ($_GET['video'] == "EDIT") { $videoEdit = TRUE; } $query = "SELECT inventory.inv_key, inventory.mdl_key, inventory.serial, inventory.date_aquired, inventory.location, inventory.price, model.mdl_key, model.man_key, model.cls_key, model.sub_cls_key, model.model, model.video, model.picture, model.pdf, subclass.sub_cls_key, subclass.subclass, class.cls_key, class.class, manufacturer.man_key, manufacturer.manufacturer FROM inventory, manufacturer, model, class, subclass WHERE inventory.mdl_key='$_GET[mdl_key]' AND model.mdl_key='$_GET[mdl_key]' AND class.cls_key='$_GET[cls_key]' AND subclass.sub_cls_key='$_GET[sub_cls_key]' AND manufacturer.man_key='$_GET[man_key]' AND manufacturer=manufacturer.manufacturer AND class=class.class AND subclass=subclass.subclass"; $result = @mysql_query ($query); // Run the query while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) { $model = $row['model']; $mdl_key = $row['mdl_key']; $video = $row['video']; $picture = $row['picture']; $pdf = $row['pdf']; $description = $row['description']; $manufacturer = $row['manufacturer']; $man_key = $row['man_key']; } </code></pre> <p>Addition Above:::: </p> <pre><code>if ($_GET['video'] == 'EDIT') { $videoEdit = TRUE; } while ($row = mysql_fetch_array($result)) { $video = $row['video']; } if ($videoEdit) { // &lt;-- boolean comparison echo '&lt;form action="edit_media.php" method="post"&gt; &lt;p&gt;Video Link: &lt;input type="text" name="serial" size="25" maxlength="100" value='; if (isset($video)) echo $video; } echo ' /&gt;&lt;/p&gt;&lt;p&gt;&lt;input type="submit" name="submit" value="Submit Video" /&gt;&lt;/p&gt; &lt;input type="hidden" name="submitted" value="TRUE" /&gt; &lt;/form&gt;'; } </code></pre> <p>Addition:: this is, in my code, directly below the above code</p> <pre><code>if ($video != "") { echo '&lt;iframe width="420" height="315" src=' . $video . ' frameborder="0" allowfullscreen&gt;&lt;/iframe&gt; | &lt;a href=edit_media.php?video=EDIT&amp;mdl_key=' . $mdl_key . '&amp;man_key=' . $man_key . '&gt;Modify Video Link&lt;/a&gt;'; } else { echo "Video Not Present | &lt;a href=edit_media.php?video=EDIT&gt;Add a Video&lt;/a&gt;"; } </code></pre>
    singulars
    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.
    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