Jump to content

[SOLVED] Adding a review system


adamdyer

Recommended Posts

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

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>

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

$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')";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.