<?php if (isset($_GET["action"]) and $_GET["action"] == "getText") { if ($_POST['review_content'] && $_POST['food_id']) { //write food review $sql = "insert into review values(NULL,'" . $_POST['type'] . "','" . $_POST['food_id'] . "','" . $_POST['author_id'] . "','" . $_POST['title'] . "','" . $_POST['review_content'] . "','" . $_POST['date'] . "')"; $res = write_food_review($sql); header('Content-Type:text/html;charset=GB2312'); if ($res != false) { print 'success'; } else { print 'fail'; } exit; } } function get_foods_of_category($search_key) { // query database for the books in a category if (!$search_key || $search_key == '') { return false; } $conn = db_connect(); $query = "select * from food where catogery_name = '" . $search_key . "'"; $result = @$conn->query($query); if (!$result) { return false; } $num_books = @$result->num_rows; if ($num_books == 0) { return false;
<?php if (isset($_GET["action"]) and $_GET["action"] == "getText") { if ($_POST['review_content'] && $_POST['food_id']) { //write food review $res = write_food_review(); header('Content-Type:text/html;charset=GB2312'); if ($res == "success") { print 'success'; } else { print $res; } exit; } } function write_log($content) { $filename = 'debug_log.txt'; $content = $content . "\r\n"; if (is_writable($filename)) { if (false == ($handle = fopen($filename, 'a'))) { return "Error: can't open"; } if (fwrite($handle, $content) === false) { return "Error: can't write"; } fclose($handle); } else { return "Error: no write permission"; } }