- Joined
- Aug 25, 2010
- Messages
- 251
- Reaction score
- 24
good day to all i am new in php coding
i would like to ask every one here how to convert this mysql to mssql.php
I hope someone will me me out how to convert this inyo mssql
this script is for voting site.
i would like to ask every one here how to convert this mysql to mssql.php
PHP:
/****************************************************************************
File: vote.php
Desc: traces a vote creating a random key, and sends the vote.
****************************************************************************/
$listname = mysql_real_escape_string( $_REQUEST['listname'] );
// load data of rating site
$data = mysql_query(
"select id, voting_link
from cfg_ranking_sites
where name = '{$listname}' " );
list( $list_id, $voting_link) = mysql_fetch_row( $data );
// generate a rnd string
$k = substr( md5 ( time() . rand(1, 10000000) ), 1, 25);
// get the user id from session
// (substitute your method for finding the user id)
$user = User::get_char_info();
$u = $user['user_id'];
// place the generated random key and trace the vote
$urlcalled = str_replace( "KEY", $k, $voting_link );
mysql_query( "insert into
voting_log
( user_id, vkey, list_id, ip, status, urlcalled )
values
( '{$u}', '{$k}', $list_id, '".$_SERVER['REMOTE_ADDR']."', 'new', '{$urlcalled}' ) ");
// send the vote
header ( "location: $urlcalled" );
exit;
PHP:
// Set content type
header('Content-type: text/xml');
// Check input, if keys are not present return error.
// This check and the fields needs to be changed for each toplist
if (
!isset($_GET['key']) or
!isset($_GET['success']) or
!isset($_GET['listname']) or
) {
echo '<response rewarded="0" message="Invalid input." />';
die();
}
// Get data
$key = mysql_real_escape_string($_GET['key']);
$success = mysql_real_escape_string($_GET['success']);
$referer = $_SERVER['HTTP_REFERER'];
$sql = "select v.id, v.user_id, r.name
from voting_log v, cfg_ranking_sites r
where vkey = '{$key}' and v.list_id = r.id
and refererurl = '{$referer}'
and status = 'new'";
$data = mysql_query( $sql );
if ( mysql_num_rows( $data ) == 0 )
{
// insert your debug message, return error
// mydebug( true, "match not found. ip: " . $_SERVER['REMOTE_ADDR'] . " key: " . $key . " referer: " . $referer);
echo '<response rewarded="0" message="match not found." />';
exit;
}
list( $id, $user_id, $list_name ) = mysql_fetch_row( $data );
// give rewards to user, only if the vote was unique ($success==1)
if ( $success == 1 )
{
$r = rand( 1,2 );
if ( $r == 1 )
{
;
//example: give reward and send information to user
//mysql_query( "update user set char_adamantium = char_adamantium + 2 where user_id = " . $user_id );
//User::send_news( 'char', $user_id, "You got 2 adamantium for your vote at " . $list_name );
}
else
{
;
//example: give reward and send information to user
//mysql_query( "update user set char_mythril = char_mythril + 2 where user_id = " . $user_id );
//User::send_news( 'char', $user_id, "You got 2 mythril for your vote at " . $list_name );
}
mysql_query( "update voting_log set status = 'rewardgiven' where id = " . $id );
echo '<response rewarded="1" message="Reward given." />';
}
else
{
mysql_query( "update voting_log set status = 'rewardnotgiven' where id = " . $id );
echo '<response rewarded="0" message="Reward not given (not unique vote)." />';
}
exit;
I hope someone will me me out how to convert this inyo mssql
this script is for voting site.