English 中文(简体)
谁能告诉我本页的错误是什么?
原标题:can someone tell me what the error in this page?
  • 时间:2011-10-19 16:21:06
  •  标签:
  • php
  • mysql
  • sql

i 将该错误线上载在Sphp档案中。 谁能找到错误之处?

页: 1 你在座标上有了一个错误;检查了与贵方SQL服务器版本相对应的手册,供右辛子在近线使用。 页: 1

i have this page for votes to users but if i vote in one user this vote goes to all users . how can i make this code when voting this vote goes only to its user . --

 // Connects to your Database 
 mysql_connect("localhost", "dbusername", "dbpassword") or die(mysql_error()); 
 mysql_select_db("mydatabase") or die(mysql_error()); 

//We only run this code if the user has just clicked a voting link
 if ( $mode=="vote") 
 { 

 //If the user has already voted on the particular thing, we do not allow them to vote     again    
    //$cookie = "Mysite$id"; 
if(isset($_COOKIE[$cookie])) 
    { 
    Echo "Sorry You have already ranked that site <p>"; 
    } 

 //Otherwise, we set a cooking telling us they have now voted 
else 
    { 
    $month = 2592000 + time(); 
    setcookie( Mysite .$id,  Voted , $month); 

     //Then we update the voting information by adding 1 to the total votes     and adding their vote (1,2,3,etc) to the total rating 

 mysql_query ("UPDATE userads SET total = total+$voted, votes = votes+1 WHERE id =     $id"); 

    } 
 } 
  if ( $mode2=="vote") 
 { 

 //If the user has already voted on the particular thing, we do not allow them to vote     again    
    //$cookie = "Mysite$id"; 
if(isset($_COOKIE[$cookie])) 
    { 
    Echo "Sorry You have already ranked that site <p>"; 
    } 

 //Otherwise, we set a cooking telling us they have now voted 
else 
    { 
    $month = 2592000 + time(); 
    setcookie( Mysite .$id,  Voted , $month); 

     //Then we update the voting information by adding 1 to the total votes     and adding their vote (1,2,3,etc) to the total rating 

 mysql_query ("UPDATE userads SET total = total+$voted, nvotes = nvotes+1 WHERE id =     $id"); 

    } 
 }  

 //Puts SQL Data into an array
 $data = mysql_query("SELECT * FROM userads WHERE id = $id ") or die(mysql_error()); 

 //Now we loop through all the data 
 while($ratings = mysql_fetch_array( $data )) 

?>
<link href="style.css" type="text/css" rel="stylesheet" />
 { 
<?php
echo  <div id="voting_14" class="voting voting_template_votess-up-down"> ;
echo "<strong class= positive_votes >";
$current = $ratings[votes];
echo "<span>+" . round($current,0) . "</span>";
echo "<a href=".$_SERVER[ PHP_SELF ]."?mode=vote&voted=1&id=".$ratings[id].">       <input class= vote_positive  type= submit ></a>";
echo  </strong> ;

echo "<strong class= negative_votes >";
$current2 = $ratings[nvotes]; 
echo "<a href=".$_SERVER[ PHP_SELF ]."?mode2=vote&voted=2&id=".$ratings[id].">      <input class= vote_negative  type= submit ></a>";
echo "<span>-". round($current2,0) ."</span>";
echo  </strong> ;

echo  </div> ;

 } 
 ---the end 

i 具有以下用途:id , 姓名, 用户名, 总数, 票, vo。

最佳回答

更正如下:

setcookie( Mysite .$id,  Voted , $month); // ERROR 1

以及

 while($ratings = mysql_fetch_array( $data )) 
{  // ERROR 2
?>
问题回答

I copy pasted your code in a file and ran:

php -l your_script.php

Yields:

Parse error: syntax error, unexpected  }  in your_script.php on line 78

因此,最后几句<代码>>><>>/代码”最终造成了大差错。 无论由谁担任配对编号<>if//while。 在你任内,问题在其他地方。

You have a syntax error. Probably your configuration doesn t display errors and you get a blank screen.

这里没有引述:

  setcookie(Mysite.$id, Voted, $month); 

It should be:

  setcookie( Mysite .$id,  Voted , $month); 

显然,你提出的问题是错误的。 你可以简单地检查你的卡片:

$sql = "SELECT * FROM userads WHERE id = $id ";
echo $sql;

我的第一gues是,<代码>id没有适当确定。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签