Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $PID = $_POST['PID'];
- $RID = $_POST['RID'];
- $UID = $_POST['UID'];
- $MEDIA = $_POST['MEDIA'];
- $lTIME = $_POST['TIME'];
- $STATUS = $_POST['STATUS'];
- $SCORE = $_POST['SCORE'];
- $DETAILS = $_POST['DETAILS'];
- $user = 'admin';
- $password = "elder";
- $host = '127.0.0.1';
- $db = 'mediamed';
- $link = mysql_connect($host, $user, $password);
- if (!$link) {
- die('Could not connect: ' . mysql_error());
- }
- mysql_select_db($db,$link);
- $sql = "SELECT * FROM tracking WHERE PID = '$PID' AND RID = '$RID' AND UID = '$UID'";
- $result = mysql_query($sql, $link);
- //Se non ci sono risultati, inserisco una riga nel tracking
- $num_rows = mysql_num_rows($result);
- if($num_rows==0){
- $sql_insert = "INSERT INTO `tracking` (
- `PID` ,
- `RID` ,
- `UID` ,
- `MEDIA` ,
- `time` ,
- `status` ,
- `score` ,
- `details`
- )
- VALUES (
- '$PID' , '$RID' , '$UID' , '$MEDIA' , '$lTIME' , 'N' , '$SCORE' , '$DETAILS'
- );
- ";
- mysql_query($sql_insert, $link);
- }else {
- //ALTRIMENTI faccio l'update di quello che gia c'era
- if($row['status']!='C'){
- $row = mysql_fetch_assoc($result);
- $secs = (int)$row['time']+(int)$lTIME;
- $sql_update = "
- UPDATE `tracking` SET `time` = '$secs',
- `status` = '$STATUS',
- `score` = '$SCORE',
- `details` = '$DETAILS' WHERE
- PID = '$PID' AND RID = '$RID' AND UID = '$UID' LIMIT 1 ;
- ";
- mysql_query($sql_update, $link);
- }
- }
- echo 'error=0';
- ?>
Add Comment
Please, Sign In to add comment