TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 12-21-2007, 02:31 PM   #1 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Unhappy (HELP!!!!!!!!) Creating a 1 - 5 Star rating script

For now I just made it say Rating Successful and Unsuccessful, and query.

PHP Code:
<style type="text/css">
 input.ratingsnstuff {
   background:url('rate/default.png') no-repeat;
   border:none;
   width:16px;
   height:16px;
   margin:1px;
   cursor: pointer;
   }
   
    input:hover.ratingsnstuff {
   background:url('rate/default_hover.png') no-repeat;
   border:none;
   width:16px;
   height:16px;
   margin:1px;
   cursor: pointer;
   }
   </style>
   
<form class="ratingsnstuff" action="rating.php" method="post">
<input class="ratingsnstuff" name="star1"  type="button" value="">
<input class="ratingsnstuff" name="star2"  type="button" value="">
<input class="ratingsnstuff" name="star3"  type="button" value="">
<input class="ratingsnstuff" name="star4"  type="button" value="">
<input class="ratingsnstuff" name="star5"  type="button" value="">
</form>
<?php

$dbhost 
"localhost";
$dbuser "root";
$dbpass "";
$database "rates";

 
mysql_connect($dbhost$dbuser$dbpass) or die(mysql_error());
 
mysql_select_db($database) or die(mysql_error());


 function 
ratingInsert($ratings) {
$rateid =  intval($_REQUEST['rateid']);
   
$rating = array($_POST['star1'], $_POST['star2'],$_POST['star3'], $_POST['star4'], $_POST['star5']);
 foreach(
$rating as $ratings) {
   
$query mysql_query("Insert into db_ratings WHERE rateid=".$rateid." and rate=".$ratings."");

    if(
$query!=null) {
       echo 
"Rated successfully!";
   } 
   elseif(!
$query) {
     echo 
'Rated Unsuccessfully!';
     }
    }
  }
           



$ratingInsert ratingInsert($ratings);
return 
$ratingInsert;


?>
This outputted:
Code:
Rated Unsuccessfully!Rated Unsuccessfully!Rated Unsuccessfully!Rated Unsuccessfully!Rated Unsuccessfully!
Please help!

UPDATE!!!!
Code:
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 'WHERE rateid=0 and rate=' at line 1
No idea what this means :[
Orc is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 08:44 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design