Note that there are some explanatory texts on larger screens.

plurals
  1. PODatabase query returns 0 rows even though two entries are present
    primarykey
    data
    text
    <p>I'm uploading some files to a database and I would like to have a PHP form that can retrieve the files in question when a serial code is entered. I have two entries in the database, yet my PHP form keeps returning it as 0 rows. I appreciate any help offered. Once again, thanks for the help as I try to join the ranks of those who know php.</p> <p>The form always returns: "No Data Found. Please check your serial code to ensure that you have not incorrectly entered it. If the code is correct please email the website administrator for further assistance" as if there are no rows.</p> <pre><code>&lt;?php if( $_POST ) { $username="st*****"; $password="*****"; $con = mysqli_connect("storycodes.db.10339998.hostedresource.com",$username,$password); if (!$con) { die('Could not connect: ' . mysql_error()); } mysqli_select_db($con, "storycodes"); $code = $_POST['codeInput']; $code = mysqli_escape_string($con, htmlspecialchars($code)); //May not acually need htmlspecialchars $query = "SELECT story,video FROM `storycodes` WHERE `code` = 'code'"; $result = mysqli_query($con, $query); if (mysqli_num_rows($result)) { $row = mysqli_fetch_assoc($result); mysqli_free_result($result); extract($row); echo $story . $video; } else { echo "No Data Found. Please check your serial code to ensure that you have not incorrectly entered it. If the code is correct please email the website administrator for further assistance"; } mysqli_close($con); } ?&gt; </code></pre> <p>Database entries: the columns are (if this helps at all): code, email, video, and story</p> <p>b2348-5dfae-73c0c-57685 s*<em>*</em>@yahoo.com ../story_files/story.txt</p> <p>90a93-785e4-03cad-a18d5 w*@<em>*</em>*.com ../video_files/story.txt ../story_files/story.txt</p> <p>code is being posted by this form:</p> <pre><code>&lt;link href="/CSS/CSS.css" rel="stylesheet" type="text/css"&gt; &lt;p align="center"&gt;&lt;span class="linkText"&gt;&lt;a href="/index.html"&gt;Home&lt;/a&gt; &lt;a href="/contact-us.php"&gt;Contact Us&lt;/a&gt; &lt;a href="/payments.html"&gt;Payments&lt;/a&gt;&lt;/span&gt;&lt;/p&gt; &lt;p align="center"&gt;&amp;nbsp;&lt;/p&gt; &lt;p align="center"&gt;&lt;span class="headingText"&gt;&lt;img alt="legendmaker - makes legends: banner" width="728" height="90" /&gt;&lt;/span&gt;&lt;/p&gt; &lt;p align="center"&gt;&amp;nbsp;&lt;/p&gt; &lt;div align="center" class="headingText"&gt;Enter Your Serial Code Below To Continue Your Adventure!&lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;form name="form1" method="post" action="/scripts/stories.php"&gt; &lt;label&gt; &lt;div align="center"&gt;&lt;span class="formText"&gt;Your Serial Code: &lt;input name="codeInput" type="text" id="codeInput" size="23" maxlength="23"&gt; &lt;/span&gt;&lt;/div&gt; &lt;/label&gt; &lt;div align="center"&gt;&lt;span class="formText"&gt; &lt;/span&gt;&lt;/div&gt; &lt;span class="formText"&gt;&lt;label&gt; &lt;div align="center"&gt;&lt;br&gt; &lt;/div&gt; &lt;/label&gt; &lt;/span&gt; &lt;label&gt; &lt;div align="center"&gt;&lt;br&gt; &lt;input type="submit" name="submit" id="submit" value="Submit"&gt; &lt;/div&gt; &lt;/label&gt; &lt;/form&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="headingText"&gt;&amp;nbsp;&lt;/p&gt; &lt;p align="center" class="headingText"&gt;Can't find your code?&lt;/p&gt; &lt;p align="center" class="paragraphText"&gt;Request an email with your code below.&lt;/p&gt; &lt;form name="form2" method="post" action="/scripts/code_request.php"&gt; &lt;label class="formText"&gt; &lt;div align="center"&gt;Email: &lt;input type="text" name="email" id="email"&gt; &lt;/div&gt; &lt;/label&gt; &lt;p align="center"&gt; &lt;label&gt; &lt;input type="submit" name="submit2" id="submit2" value="Submit"&gt; &lt;/label&gt; &lt;/p&gt; &lt;/form&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; </code></pre> <p>NEVER MIND about the HTML, thanks a lot for the help. I got all mixed up!</p>
    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