Note that there are some explanatory texts on larger screens.

plurals
  1. POSelect Where giving no result
    text
    copied!<p>I want to select one field value from a record where another value in the record matches my specified value. </p> <p>The "SKU" is unique, it isn't the PK, but it is unique. I select only the one field (Code) from the table, so the variable $gemCode should only contain that 1 value. However on the echo, it either outputs nothing like the below code, or if I do specify the field "$gemCode['Code'] it just spurts "Resource id #8" which I've never seen before. </p> <pre><code>$gemCode = mysql_query("SELECT Code FROM stock WHERE SKU = 'TN-YKJI-ESWB'"); echo "Gem Code: ".$gemCode."&lt;br&gt;"; </code></pre> <p>This code is in a loop, for each line of a file which it'll be taking the SKU value from. Though even though the code has none of the loop in it (variables taken from the file etc) the output it does give, the "Resource id #8" number goes up each loop starting at 8:</p> <pre><code>Gem Code: Resource id #8 Gem Code: Resource id #9 Gem Code: Resource id #10 Gem Code: Resource id #11 Gem Code: Resource id #12 Gem Code: Resource id #13 Gem Code: Resource id #14 Gem Code: Resource id #15 </code></pre> <p>I've had issues where before somehow data in my tables have spaces after them so "LIKE '%value%'" was needed, though I've checked and the values in question are don't have this, so its not like I'm looking from values that don't technically exist. </p> <p>Should also mention I do have:</p> <pre><code>$conn = mysql_connect('localhost', 'root', ''); mysql_select_db('amazondb', $conn); </code></pre> <p>I'm really stumped, I thought it'd just be a simple select where. </p> <p>Any help is much appreciated, thanks -Tom </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