Note that there are some explanatory texts on larger screens.

plurals
  1. POCheck if entry is available in database
    primarykey
    data
    text
    <p>I have generated a 10 digit number, added it to a database after purchase.</p> <p>Now I want to make a php page to give users an input box, ask them to enter the 10 digit number, and click submit. After you click submit it should return if the pin is used or has not been used it. (Used if its not available - Not used if its in the table) </p> <p>I got the following code:</p> <pre><code>&lt;?php require_once 'db.php'; function validated_pin($pin) { $pin = mysql_real_escape_string($pin); // SECURITY! $result = mysql_query("SELECT pins FROM pins WHERE pin='$pin' LIMIT 1"); if (mysql_fetch_row($result)) { return 'This pin has already been used'; } else { return 'This pin is available for use'; } } echo '&lt;html&gt;&lt;center&gt; &lt;form action="' . $_SERVER['SCRIPT_NAME'] . '" method="post"&gt; &lt;table style="border:0px solid black;"&gt; &lt;tr&gt; &lt;td&gt;PIN*:&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="pin" value="" class="bginput"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;input type="submit" id ="submit" name="submit1" value="Check Pin&gt;&gt;" class="button"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt;'; echo validated_pin($pin); echo '&lt;/center&gt;&lt;/html&gt;'; ?&gt; </code></pre> <p>And PHPmyAdmin looks like this: <a href="http://gyazo.com/67c3df7171c83c677cb221c04d644ed7.png" rel="nofollow">http://gyazo.com/67c3df7171c83c677cb221c04d644ed7.png</a></p> <p>It's located in _donation and in table name pins</p> <p>I don't know whats going on tried looking everywhere </p> <p>The current code will return this error</p> <pre><code>Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in /home/website/public_html/directory/example.php on line 8 </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.
    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