Jump to content

MySQL JOIN Query Works on Workbench, not on site


ZandarKoad

Recommended Posts

I was using a PDO version of the PHP querry code that used RecursiveIteratorIterator to spit out the display, but wrapping my brain around those multi-level sub-sub nested abstract classes was making my brain bleed.  I had thought it was a problem with the HTML syntax, but that appears not to be the case.  I went with a dumber version of an HTML table display snippet, and I'm having the same problem.

This MySQL query works great in PHPMyAdmin and on Workbench, but when I put it into a .php file on a live site, it won't ever display any content from the "english_phrases.phrase_content" column.  It doesn't throw any errors.  Just puts out blanks where English phrases should be.  As you can see, it works great in PHPMyAdmin:

 

Here's the PHPMyAdmin output:  http://screencast.com/t/wM6xiJ08a

Here's the live output:  http://screencast.com/t/oBHJmNoT0U

Any ideas?

mysql_connect($servername,$username,$password);
@mysql_select_db($dbname) or die("Unable to select database");
$query="SELECT english_phrases.phrase_index_key, english_phrases.phrase_content, cebuano_phrases.phrase_content, english_phrases.author FROM english_phrases LEFT JOIN cebuano_phrases ON english_phrases.phrase_index_key=cebuano_phrases.phrase_index_key";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo "<b> <center>Database Output</center> </b> <br> <br>";
echo "<table align='center' style='border: solid 1px black;'>";
echo "<tr style='width:200px;border1px solid black;'><th>Phrase ID</th><th>English Phrase</th><th>Cebuano Phrase</th><th>Author</th></tr>";
// <td style='width:150px;border:1px solid black;'>
$i = 0;
while ($i < $num) {
$field1name = mysql_result($result, $i, "english_phrases.phrase_index_key");
$field2name = mysql_result($result, $i, "english_phrases.phrase_content");  //This NEVER displays content!
$field3name = mysql_result($result, $i, "cebuano_phrases.phrase_content");
$field4name = mysql_result($result, $i, "english_phrases.author");

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.