I'm trying to query my database using a an array that increments in a for loop. for some reason this will not work no matter what I do,
I get the the error:
"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1"
when the database is queried in PHPMyAdmin everything comes out fine so im assuming something in the for loop is screwing it up. Any ideas?
My code :-
<?php
$submitclick=$_GET["submitclick"];
if($submitclick==1)
{
require('json.php');
$selec=$_GET["selec"];
$selec=str_replace("'","",$selec);
error_reporting(E_ALL);
mysql_connect("localhost", "seamus", "password") or
die("Could not connect: " . mysql_error());
mysql_select_db("seamus") or die("No such database");
$sql1 = sprintf("SELECT event FROM attends WHERE student = '%s'",$selec);
$result1 = mysql_query($sql1)
or die(mysql_error());
while ($row1 = mysql_fetch_array($result1))
{
$eve[] = $row1['event'];
}
for($f=0;$f<count($eve);$f++)
{
$sql = sprintf("SELECT event.id, teaches.staff, day, start, duration, room FROM event JOIN module ON (event.module=module.id) JOIN isin ON (event.id=isin.event) JOIN teaches ON (event.id=teaches.event) JOIN attends ON (event.id=attends.event) WHERE event.id = '%s')",$eve[$f]);
$result = mysql_query($sql)
or die(mysql_error());
$i=0;
while ($row = mysql_fetch_array($result))
{
$key =$row['day'].$row['start'];
$event[$key] = $row['id'];
$room[$row['id']] = $row['room'];
$lect[$row['id']] = $row['staff'];
$time[$i]= $row['duration'];
$i++;
}
}
$i=0;