Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There are a few things to check out here. I'm assuming character names are unique. If so, I'm guessing you're expecting <code>mysql_fetch_array()</code> to return one result for</p> <pre><code>mysql_query("SELECT `level` FROM `cq_user` WHERE `name` = '" . $char_name. "'") </code></pre> <p>You have <code>$row = mysql_fetch_array($result1)</code>, and as the function name implies, <code>mysql_fetch_array()</code> returns an array, so <code>$row</code> is an array of the column values requested. Each time it's called, it iterates further over the results. If you're just expecting one row to be returned, you can call it just once (no need for the while loop). Since you're just selecting one column (<code>level</code>), the level should be <code>$row[0]</code>.</p> <p>Also, the conditions in your <code>if</code> statement are mutually exclusive:</p> <pre><code>if (mysql_num_rows($result) == 0 &amp;&amp; $row &lt;= 119) </code></pre> <p>I'm guessing you meant to use or (<code>||</code>) here, because you want to check if either there are 0 results or the level is less than 119.</p> <p>Therefore, it should likely be:</p> <pre><code>if (mysql_num_rows($result) == 0 || $row[0] &lt;= 119) </code></pre> <p>Also, the <code>mysql_</code> functions are now <a href="http://php.net/mysql_fetch_array" rel="nofollow">deprecated</a>. It is suggested you use <code>mysqli_</code> function or the <code>PDO_MySQL</code> extension. Your code might also be vulnerable to SQL injections as you're not escaping user input before concatenating it with your query string. Consider using <a href="http://php.net/manual/en/mysqli.quickstart.prepared-statements.php" rel="nofollow">prepared/parameterized queries</a>.</p>
 

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