title: SQL Query causing page to go blank
body: <p>I'm making a website using php and I'm having some trouble with an SQL query.</p>
  
  <pre><code>$dataArray = array();
  $result = mysql_query("SELECT * FROM test WHERE web_id='$websiteID'")
      or die(mysql_error());
  
  while ($row = mysql_fetch_array($result)) {
      $k = $row['kfoo'];
      $v = $row['vbar'];
      $dataArray[$k] = $v;
  }
  </code></pre>
  
  <p>That's the code as it should be, however that causes the page to go blank (i.e. simply display all white). I've double checked and <code>web_id</code> is definitely the correct name and the correct case. </p>
  
  <p>If I change <code>web_id</code> in the query to be, for instance, 'foo' (basically anything other than <code>web_id</code>), then the page will display, but with the error message "Unknown column 'foo' in 'where clause'". </p>
  
  <p>Does anybody have any idea what could be causing this? Here's the code where I create the table test:</p>
  
  <pre><code>$dataDB = "CREATE TABLE test
  (
      data_id INT NOT NULL AUTO_INCREMENT,
      PRIMARY KEY(data_id),
      web_id INT,
      kfoo TEXT,
      vbar TEXT
  )";
  
  mysql_query($dataDB,$con);  
  </code></pre>
  
  <p><strong>Update</strong></p>
  
  <p>Based on some of the answers here, I removed the quotes from around $websiteID and displayed errors using </p>
  
  <pre><code>error_reporting(E_ALL);
  ini_set('display_errors', 1);
  </code></pre>
  
  <p>This displayed a lot of errors, including a syntax error earlier on that I've now fixed on. However, many errors remain and they don't make much sense to me. Here's the full code for my method:</p>
  
  <pre><code>function getOutputSQL($websiteID,$userInput) {
   $result = mysql_query("SELECT * FROM websites WHERE websiteID=$websiteID") 
      or die(mysql_error());
  
    while ($row = mysql_fetch_array($result)){
      $url = $row['url'];
      $exp = $row['exp'];
      $output= $row['textPrint'];
      $endUrlStart = $row['outUrlStart'];
      $endUrlEnd = $row['outURLEnd'];
  
      $image = $row['image'];
      $print = $row['print'];
      $post = $row['post'];
  
      $dataSource = $row['dataSource'];
      $dataSourceName = $row['dataSourceName'];           
  
    }
  
    // construct array of data names and values
    $dataArray = array();
    $result = mysql_query("SELECT * FROM test WHERE web_id=$websiteID") 
      or die(mysql_error());
  
    while ($row = mysql_fetch_array($result)) {
      $k = $row['kfoo'];
      $v = $row['vbar'];
      $dataArray[$k] = $v;
    }
  
    // construct array of expressions and replacements
    $result = mysql_query("SELECT * FROM regex WHERE web_id=$websiteID");
    $expArray = array();
  
    while ($row = mysql_fetch_array($result)) {
      $e = $row['ex'];
      $r = $row['re'];
      $expArray[$e] = $r; 
    }
  
    return getOutput($userInput,$url,$exp,$output,$endUrlStart,
       $endUrlEnd,$dataSource,$dataSourceName,$post,$image,$print,
       $expArray,$dataArray); 
  }
  </code></pre>
  
  <p>The errors I'm getting are all like this - </p>
  
  <blockquote>
    <p>Notice: Undefined variable: output in /home/daniel/web/resultsTest.php on line 113"</p>
  </blockquote>
  
  <p>That repeats several times for url, exp, output, endUrlStart, endUrlEnd, dataSource, dataSourceName, post, image and print Line 113 is the large return line.</p>
  
  <p>The thing is, as far as I can tell these variables are defined, and I know the table isn't empty, because I can display it on another page.</p>
  
  <p><strong>Solved</strong></p>
  
  <p>Sorted. The problem was actually in another part of my code - I was calling getOutputSQL incorrectly, but I've fixed it now!</p>