adamdyer Posted August 24, 2007 Share Posted August 24, 2007 need help with adding a 'Review' system to my Hotel Website. i.e- past customers log into the member area, theres a link that says - add review ...... - thats where i need your help :-) Link to comment https://forums.phpfreaks.com/topic/66527-solved-adding-a-review-system/ Share on other sites More sharing options...
lemmin Posted August 24, 2007 Share Posted August 24, 2007 You should try to write some code and post it if it doesn't work. All you have to do to accomplish this is have a form that posts to a php file that puts the data into a database. Then read it back out to print the review. Link to comment https://forums.phpfreaks.com/topic/66527-solved-adding-a-review-system/#findComment-333152 Share on other sites More sharing options...
adamdyer Posted August 24, 2007 Author Share Posted August 24, 2007 ok,tried some code - but now im getting an error - any chance you could point it out to me/ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <?php $CustomerUsername= $_GET['Customer_Username']; echo( "Customer Username = <B>$CID</B></br>" ); $StarRating= $_GET['Star_Rating']; echo( "Star Rating = <B>$CID</B></br>" ); # connect to MySQL $conn = @mysql_connect("localhost","ajdref","ref2") or die ("sorry - could not connect to MySQL"); # select the specified database $rs = @mysql_select_db("ajdref", $conn) or die ("sorry - could not connect to the ajdref"); #create the query - sets $sql to contain the required query $sql = "SELECT * FROM `Booking Database`"; $sql = "INSERT INTO `Booking Database` (`Star Rating`, `Customer Username`,) VALUES ('$StarRating', '$CustomerUsername')"; mysql_query($sql,$conn)or die(mysql_error()); if($rs){ echo("Star Rating added");} else { echo("Error! Star Rating not added");} ?> <body> </body> </html> Star Rating = 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 ') VALUES ('***', 'Skippi')' at line 1 Link to comment https://forums.phpfreaks.com/topic/66527-solved-adding-a-review-system/#findComment-333191 Share on other sites More sharing options...
lemmin Posted August 24, 2007 Share Posted August 24, 2007 The code you posted is not where the error is. Note the text after "near" in the mysql error. Link to comment https://forums.phpfreaks.com/topic/66527-solved-adding-a-review-system/#findComment-333206 Share on other sites More sharing options...
adamdyer Posted August 24, 2007 Author Share Posted August 24, 2007 ok - well heres the HTML page - this is the only other page that has anything to do with the original coding I just sent <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <style type="text/css"> <!-- body { background-color: #003399; } .style1 {color: #FFFFFF} --> </style></head> <form NAME="GetCode" ACTION="starratingpage.php" METHOD="get"> <body> <p class="style1"> <p align="center" class="style1"><p class="style1"> <p class="style1"> <p align="center" class="style1"> Customer Username <INPUT NAME ="Customer_Username" id="Customer_Username" size = 20> <p class="style1"> <p align="center" class="style1">Please Enter Your Star Rating - <INPUT Name ="Star_Rating" id="Star_Rating" size = 20 > <p align="center" class="style1">***** Excellent <p align="center" class="style1">****Very Good <p align="center" class="style1">***Good <p align="center" class="style1">**Ok <p align="center" class="style1">* Unsatisfactory <p align="center" class="style1"> <input type="submit" value="Send" name="SUBMIT" > </body> </html> Link to comment https://forums.phpfreaks.com/topic/66527-solved-adding-a-review-system/#findComment-333209 Share on other sites More sharing options...
lemmin Posted August 24, 2007 Share Posted August 24, 2007 Oh sorry, I'm dumb. I was looking for those raw values in your code, for some reason. Anyway, the problem is the little comma after "`Customer Username`," in your INSERT query. Just remove that. Link to comment https://forums.phpfreaks.com/topic/66527-solved-adding-a-review-system/#findComment-333220 Share on other sites More sharing options...
chocopi Posted August 24, 2007 Share Posted August 24, 2007 I think you should change $sql = "INSERT INTO `Booking Database` (`Star Rating`, `Customer Username`,) VALUES ('$StarRating', '$CustomerUsername')"; to $sql = "INSERT INTO `Booking Database` (`Star Rating`,`Customer Username`) VALUES ('$StarRating', '$CustomerUsername')"; You don't need the backticks on it seeing as they are if you use the reserved words which none of them are, but I think the problem was the extra comma Hope that helps, ~ Chocopi Link to comment https://forums.phpfreaks.com/topic/66527-solved-adding-a-review-system/#findComment-333222 Share on other sites More sharing options...
AndyB Posted August 24, 2007 Share Posted August 24, 2007 $sql = "SELECT * FROM `Booking Database`"; That is incomplete and should be deleted entirely $sql = "INSERT INTO `Booking Database` (`Star Rating`, `Customer Username`) VALUES ('$StarRating', '$CustomerUsername')"; As chocopi stated, that might work, but I have my doubts. You really should avoid using spaces in database or field names. If you must have superlegibility, use the _ underscore _ character instead. You probably need to rename your database table and table fieldnames. Then you can throw away those `backticks` $sql = "INSERT INTO Booking_Database (Star_Rating, Customer_Username`) VALUES ('$StarRating', '$CustomerUsername')"; Link to comment https://forums.phpfreaks.com/topic/66527-solved-adding-a-review-system/#findComment-333224 Share on other sites More sharing options...
adamdyer Posted August 24, 2007 Author Share Posted August 24, 2007 its all cool, working now :-) thanks for help guys, you dont know how much it is gratefully appreciated! Link to comment https://forums.phpfreaks.com/topic/66527-solved-adding-a-review-system/#findComment-333226 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.