0

Hi all, i have difficulties in appending my sql query in php. Need some of your help to guide me along. Tell me where does my code goes who. Thanks.

for ($i = 1; $i<=$dayc; $i++){

        $daya[] = $_POST['day'.$i];

    }
        $link = mysqli_connect($HOST,$USERNAME,$PASSWORD,$DB);
        $query = "UPDATE class SET Time_Slot_idTime_Slot = '$time',Course_idCourse = '$name',exam_date = '$exam',closing_date = '$closing',";
        $query = $query."day$1 = '$daya[$1]'";
        $query = $query."where idClass = ' ". $_GET['id'] ." '";
        $echo $query;
        $result = mysqli_query($link,$query) or die(mysqli_error($link));

am i doing a correct way of append? there seems to be error..Thanks for your help

Edited by Reverend Jim: Fixed formatting

3
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by lf.gene
0
$query = "UPDATE class SET Time_Slot_idTime_Slot = '$time',Course_idCourse = '$name',exam_date = '$exam',closing_date = '$closing',";
$query = $query . "day$1 = '$daya[$1]' "; // <-- you were missing a space here
$query = $query . "where idClass = '". $_GET['id'] . "'"; // <-- too many spaces here
0

Parse error: syntax error, unexpected '$', expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\xampp\htdocs\FYP\doUpdateClass.php on line 24

this is the error i got

0

Change line 2:

$query = $query . "day$i = '$daya[$i]' ";

I guess you want to use $i, it could be another variable, but NOT $1

Edited by pritaeas: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.