Parse error: syntax error, unexpected '$data' (T_VARIABLE) in C:\wamp64\www\web\test.php on line 27 -
this question has answer here:
- php parse/syntax errors; , how solve them? 11 answers
so error , can't understand why. in opinion syntax correct, still doesn't work way want. maybe don't understand mysql syntax in php
<?php include 'db.php'; $data = array( 0 => array( 'comment_author_name' => 'jurgis', 'comment_author_rank' => 'pro', 'comment_date' => '2017-08-13 23:45:23', 'comment_message' => 'lorem ipsum (trump. lipsum) yra tekstas naudojamas spaudos ir grafinio dizaino industrijoje jau nuo xvi amžiaus pradžios.' ), 1 => array( 'comment_author_name' => 'martynas', 'comment_author_rank' => 'newbie', 'comment_date' => '2017-08-14 13:32:15', 'comment_message' => 'jis naudojamas parodyti grafinio pristatymo elementus, tokius kaip tipografija, dizainas ar šriftas.' ), 2 => array( 'comment_author_name' => 'tomas', 'comment_author_rank' => 'master', 'comment_date' => '2017-08-14 13:42:20', 'comment_message' => 'jis taip pat kūrimo stadijoje naudojamas kaip kai kurių produktų aprašymų tekstas, prieš tai kai įrašomas tikrasis tekstas.' ) ); for($i=0; $i<count($data); $i++){ $query = "insert discussion_info (comment_author_name,comment_author_rank,comment_date,comment_message) values ('"$data[$i]['comment_author_name']"', '"$data[$i]['comment_author_rank']"', '"$data[$i]['comment_date']"', '"$data[$i]['comment_message']"')"; $mysqli_query($connection, $sql); } ?>
you need concat string var data. this:
values ('" . $data[$i]['comment_author_name'] . "',
Comments
Post a Comment