Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat's wrong with this database call?
    text
    copied!<p><strong>-Issue Still Unresolved-</strong> </p> <p>I'm trying to call a database, put all the rows of a table in an array, pass that table to my JS as json data, and then use that data as parameters for a function. </p> <p>When I run the script nothing happens. I don't get any errors in the console, the rest of the script loads normally. I'm pretty new to mySQL and PHP, what am I doing wrong here? I suspect that I goofed up the php somehow.</p> <ul> <li>XAMPP server, being tested on my desktop</li> <li>all linked files are in the same directory</li> <li>There are no visible errors displayed anywhere. As far as I can tell, the script doesn't even try to load the PHP to begin with, but also doesn't display an error in firebug's console</li> </ul> <p><strong>Attempted</strong>: </p> <ul> <li>Renaming the table without spaces </li> <li>placing the for loop inside the callback function </li> <li>amending php errors</li> </ul> <p>Here's the updated JS I'm using:</p> <pre><code> this.taskMenu = function() { var table = []; $.getJSON("taskMaster.php", {"table" : "firstlist"}, function(data) { table.push(data); for(i=0; i&lt;table.length; i++) { var taskId = table[i].taskName.replace(/\s+/g,"") + i; formatTask("interface",taskId,table[i].taskName,table[i].taskDescription,table[i].taskComplete); } }); } </code></pre> <p>and here's the updated PHP:</p> <pre><code>error_reporting(E_ALL); ini_set('display_errors','On'); $con = mysql_connect("localhost", "root", "m3648y73"); if (!$con){die('Could not connect: ' . mysql_error());}; mysql_select_db("tasklistdb", $con); $table = $_GET['table']; $sql = mysql_query("SELECT taskName, taskId, taskDescription, taskComplete FROM `".$table."`"); $listTasks = array(); while ($row_user = mysql_fetch_assoc($sql)) $listTasks[] = $row_user; echo json_encode($listTasks); mysql_close($con); </code></pre> <p>Am I linking to the DB correctly? </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