Data refresh not working - php

Hey friends I want to refresh my database after checking the access token is working or not I want to delete the Facebook expire access token without deleting the working access token but my this script delete my all user access token and I don't know why I am new in PHP
<body>
<div id="wrap" class="boxed">
<center>
<br><br>
<div class="bannerX" style="width: 600px;">
<div class="logo">
<section class="logo">
<img src="logo-new.png">
</section>
</div>
<br>
<hr>
<br>
<?php
include'config.php';
$items = mysql_query("SELECT * FROM token_all");
$thispage = $PHP_SELF;
$num = mysql_num_rows($items);
$per_page = 300;
$start = #$_GET['start'];
if(empty($start)) $start = 000;
?>
<?php
// Turn off all error reporting
error_reporting(0);
?>
<center>
<?php
$i = "0";
if($start+$per_page<$num){
?>
[Next Like]
<?php
}
$result = mysql_query("SELECT * FROM token_all LIMIT $start,$per_page");
if($result){
while($row = mysql_fetch_array($result))
{
$token = $row[token];
$userData = json_decode(file_get_contents('https://graph.facebook.com/me?access_token='.$token.'&fields=name,id'),true);print($userData[name]).'<br/>';
if(!$userData[name]){
$i++;
mysql_query("
DELETE FROM
token_all
WHERE
token='" . mysql_real_escape_string($token) . "'
");
}
}
}
echo $i;
?>
</body>
</html>
Thanks in advance

Related

Nothing fetching content with server

Hosting company updated servers or added new patchs can't get a straight answer.
I updated code looked online and stuck. Tried to have hosting check with server and company keeps coming back and saying its the code.
Don't know what else to do and help would be appreciated.
<?
include_once("mysql_nitrousgarage.inc");
$clean_url = substr($PHP_SELF,1);
$clean_url = substr($clean_url,0,-5);
$q = "SELECT * from NG_product where active='Y' and
clean_url='$clean_url'";
$results = mysql_query($q);
$row = mysql_fetch_array($results);
$product_id = $row["product_id"];
$product_name = $row["product_name"];
$sku = $row["sku"];
$description = $row["description"];
$meta_title = $row["meta_title"];
$meta_description = $row["meta_description"];
$magiczoomplus = "Y";
include_once("topnav.inc")
?>
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<meta name="viewport" content="width=400, user-scalable=no">
<script type="text/javascript"
src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-
52f96c9761c7b0cb" async="async"></script>
<div class="box-border">
Home ›
<?
if ($saved_category_id || !$saved_brand_id)
{
if ($saved_category_id)
$q = "SELECT * from NG_category where
category_id='$saved_category_id'";
else
$q = "SELECT * from NG_product_category as pc, NG_category
as c where pc.product_id='$product_id' and
pc.category_id=c.category_id order by c.order_placement limit 1";
$results = mysql_nitrousgarage.inc($q);
$row = mysql_fetch_array($results);
$category_id = $row["category_id"];
$category = $row["category"];
$category_clean_url = $row["clean_url"];
echo "<a href='$category_clean_url'>$category Wheels</a>";
}
else
{
$q = "SELECT * from NG_brand where brand_id='$saved_brand_id'";
$results = mysql_query($q);
$row = mysql_fetch_array($results);
$brand_id = $row["brand_id"];
$brand = $row["brand"];
$brand_clean_url = $row["clean_url"];
echo "<a href='$brand_clean_url'>$brand Wheels</a>";
}
?>
› <?echo $product_name?>
<div class="page-numbers">
<a href="<?echo $category_clean_url?>">‹ Back to <?echo
$category?> Wheels</a>
</div>
</div>
<div class="space20"></div>
<?
$image_id_arr = array();
$q1 = "SELECT * from NG_finish as f, NG_product_finish as pf, NG_finish_image as fi where f.active='Y' and f.finish_id=pf.finish_id and pf.active='Y' and pf.product_id='$product_id' and pf.product_finish_id=fi.product_finish_id and fi.active='Y' order by f.order_placement,fi.order_placement";
$r1 = mysql_query($q1);
while ($row1 = mysql_fetch_array($r1))
{
$image_id = $row1["image_id"];
$product_finish_name = $row1["product_finish_name"];
if (!$main_image)
{
$main_image = "finish-$image_id.jpg";
$selected_finish = $product_finish_name;
}
$image_id_arr[] = $image_id;
$product_finish_name_arr[] = $product_finish_name;
}
?>
<div class="simpletable">
<div class="row">
<div class="simplecell details-cll1">
<div id="m-container">
<img class="maxwidth" id="m-img" src="productphotos/<?echo $main_image?>" width=488>
</div>
</div>
<div class="simplecell" style="width: 3%"></div>
<div class="simplecell details-cll2">
<!--<div class="details-share">
<img src="images/facebook.jpg">
<br class="nomobile">
<img src="images/twitter.jpg">
<br class="nomobile">
<img src="images/mail.jpg">
<br class="nomobile">
<img src="images/plus.jpg">
</div>-->
<span class="details-title"><?echo $product_name?></span>
<div class="style-number">Style: <?echo $sku?></div>
<div class="selected-finish">Selected Finish: <span id=finish_layer>
<?echo $selected_finish?></span>
</div>
<div class="space30"></div>
<br>
<div class="simpleinline">
<div class="like-wheel">Like this Wheel?</div>
<div class="more-info-via">GET MORE INFO VIA</div>
</div>
<div class="simpleinline">
<a class="like-buttons" href="wheel-inquiry.php?product_id=<?echo $product_id?>&contact=C">CALL/TEXT</a> <a class="like-buttons" href="wheel-inquiry.php?product_id=<?echo $product_id?>&contact=E">EMAIL</a>
</div>
<div class="space50 nomobile"></div>
<div class="space30"></div>
<?
while(list($k,$v) = each($image_id_arr))
{
$product_finish_name = $product_finish_name_arr[$k];
echo "<img class='maxwidth' src='productphotos/finish-$v.jpg' width=145>";
}
?>
</div>
</div>
</div>
<div class="space20"></div>
<div class="box-border">
<div class="simpletable">
<div class="row">
<div class="simplecell product-desc">
<?echo $description?>
</div>
<!--<div class="simplecell price-notshow">
<b>Why are prices not shown?</b>
<br><br>
Many of our customers frequently ask us why are the prices not show.
</div>-->
</div>
</div>
</div>
<div class="space20"></div>
<?
$q = "SELECT * FROM NG_gallery WHERE active='y' and product_id='$product_id' ORDER BY featured desc, orderplacement limit 3";
$results = mysql_query($q);
if (mysql_num_rows($results) > 0) { ?>
<b><?echo $product_name?></b> Vehicle Gallery
<div class="page-numbers">
CLICK IMAGE TO <b>ENLARGE | VIEW MORE</b>
</div>
<?
while ($row = mysql_fetch_array($results))
{
$gallery_id = $row["gallery_id"];
$gallery_title = $row["gallery_title"];
$gallery_pics .= "<a href='productphotos/gallery_$gallery_id-l.jpg' class='MagicZoomPlus' id='Zoomer$gallery_id' rel='zoom-position: inner; zoom-width:400px;zoom-height:500px;' title='$gallery_title'><img class='maxwidth' src='productphotos/gallery_$gallery_id-l.jpg' width=380 border=0></a>";
}
?>
<div class="details-img-container">
<nobr>
<?echo $gallery_pics?>
</nobr>
</div>
<div class="details-img-container2">
<?echo $gallery_pics?>
</div>
<?}?>
<? include_once("footer.inc") ?>
Before updates of server page was working fine.

How to detect link in text by php and send default meta information

How to detect link in some text which is included from chat database and detect default meta information and put it to text like on discord.
ATTACHMENT
CODE
<?
session_start();
include('../../php/connect.php');
if(isset($_GET['uid']) && isset($_GET['cid']) && isset($_SESSION['user'])) {
$uid = $_GET['uid'];
$user = $_SESSION['user'];
$check = mysqli_query($con, "SELECT * FROM users WHERE id = '$uid'");
$ch = mysqli_fetch_array($check);
if($ch['username'] == $user) {
$cid = $_GET['cid'];
$uq = mysqli_query($con, "SELECT * FROM users WHERE id = '$cid'");
$u = mysqli_fetch_array($uq);
$asd = $u['username'];
$photo = $ch['photo'];
$query = mysqli_query($con, "SELECT * FROM users WHERE username = '$asd'");
$q = mysqli_fetch_array($query);
$row = mysqli_query($con, "SELECT * FROM messages WHERE (user1,user2,type) = ('$user','$asd','message') OR (user2,user1,type) = ('$user','$asd','message') ORDER BY id ASC");
while($result = mysqli_fetch_object($row)) { $date = date_create($result->sent); $time = date_format($date, 'H:i'); $date = date_format($date, 'd.m.Y');
?>
<div class="message" id="message">
<div class="hr-text">
<span>
<? echo $date; ?>
</span>
</div>
<div id="avatar" class="avatar-u"><img src="<? if($result->user1 == $asd) { echo '../../img/avatars/'.$q['photo']; } elseif($result->user1 == $user) { echo '../../img/avatars/'.$photo; } ?>">
</div>
<span class="username-u">
<? echo $result->user1; ?>
</span>
<span class="time">
<? echo $time; ?>
</span>
<div class="message-content">
<? echo '<xmp>'.$result->content.'</xmp>'; ?>
</div>
</div>
<?
}
} else {
header('location: ../index.php');
}
} else {
header('location: ../index.php');
}
?>
AJAX imports this site to #content-frame every 750ms.
I just want for example paste detected link to <a> element and then write some meta information like in ATTACHMENT upper

undefined variable when i use mysqli

I am new in mysqli. I was using mysql and converting it in mysqli. When the data in my database are empty the error showed up and said " Undefined variable: candidate_name_5" but in mysql when the data in mydatabase is empty it still works. I dont know whats the problem. Its working fine in mysql but many errors in mysqli. Please help me what is the problem
<?php
require('connection.php');
$connect = mysqli_connect('localhost','root','','smart_id_user');
// retrieving candidate(s) results based on position
if (isset($_POST['monthReport'])){
/*
$resulta = mysql_query("SELECT * FROM tbCandidates where candidate_name='Luis Nani'");
while($row1 = mysql_fetch_array($resulta))
{
$candidate_1=$row1['candidate_cvotes'];
}
*/
$monthReport = $_POST['monthReport'];
$results = mysqli_query($connect,"SELECT * FROM voting_tbCandidates where candidate_position='$monthReport'");
$row1 = mysqli_fetch_array($results); // for the first candidate
$row2 = mysqli_fetch_array($results); // for the second candidate
$row3 = mysqli_fetch_array($results);
$row4 = mysqli_fetch_array($results);
$row5 = mysqli_fetch_array($results);
$row6 = mysqli_fetch_array($results);
$row7 = mysqli_fetch_array($results);
$row8 = mysqli_fetch_array($results);
$row9 = mysqli_fetch_array($results);
$row10 = mysqli_fetch_array($results);
$row11 = mysqli_fetch_array($results);
$row12 = mysqli_fetch_array($results);
if ($row1){
$candidate_name_1=$row1['candidate_name']; // first candidate name
$candidate_1=$row1['candidate_cvotes']; // first candidate votes
}
if ($row2){
$candidate_name_2=$row2['candidate_name']; // second candidate name
$candidate_2=$row2['candidate_cvotes']; // second candidate votes
}
if ($row3){
$candidate_name_3=$row3['candidate_name'];
$candidate_3=$row3['candidates_cvotes'];
}
if($row4){
$candidate_name_4=$row4['candidate_name'];
$candidate_4=$row4['candidate_cvotes'];
}
if($row5){
$candidate_name_5=$row5['candidate_name'];
$candidate_5=$row5['candidate_cvotes'];
}
if($row6){
$candidate_name_6=$row6['candidate_name'];
$candidate_6=$row6['candidate_cvotes'];
}
if($row7){
$candidate_name_7=$row7['candidate_name'];
$candidate_7=$row7['candidate_cvotes'];
}
if($row8){
$candidate_name_8=$row8['candidate_name'];
$candidate_8=$row8['candidate_cvotes'];
}
if($row9){
$candidate_name_9=$row9['candidate_name'];
$candidate_9=$row9['candidate_cvotes'];
}
}
else
// do nothing
?>
<?php
// retrieving positions sql query
$positions=mysqli_query($connect,"SELECT * FROM voting_tbPositions")
or die("There are no records to display\n" . mysqli_error());
?>
<?php
session_start();
//If your session isn't valid, it returns you to the login screen for
protection//
if(empty($_SESSION['user_id'])){
}
?>
<?php if(isset($_POST['monthReport']))
{$totalvotes=$candidate_1+$candidate_2+$candidate_3+$candidate_4;} ?>
<html><head>
<div id="mySidenav" class="sidenav">
×
HOME
<a><hr></a>
VOTE
<a><hr></a>
POLL RESULTS
<a><hr></a>
LOGOUT
</div>
<div id="main">
<span style="font-size:30px;cursor:pointer" onclick="openNav()">☰
</span>
<script language="JavaScript" src="js/admin.js">
</script>
</head><body bgcolor="tan">
<center>
<font color = "white" size="7"> <div id="hihi">ONLINE VOTING SYSTEM</div></font>
<br><br>
<br>
<br></center>
<div id="page">
<div id="header">
<h1>POLL RESULTS </h1>
</div>
<div id="container">
<table width="420" align="center">
<form method="POST" action="refresh.php">
<tr>
<td>Choose Position</td>
<td><SELECT name="monthReport" id="monthReport" onchange="form.submit()">
<OPTION VALUE="select">select
< ?php
//loop through all table rows
while ($row=mysqli_fetch_array($positions)){
echo "<OPTION VALUE=$row[position_name]>$row[position_name]";
}
?>
</SELECT></td>
<script type="text/javascript">
document.getElementById('month').value = "<?php echo $_POST['monthReport'];?>";
</script>
<?php
echo '<div id="gitna">';
echo $monthReport;
echo '</div>';
?>
<?php if(isset($_POST['monthReport'])){echo $candidate_name_1;} ?>:<br>
<img src="images/candidate-1.gif"
width='<?php if(isset($_POST['monthReport'])){ if ($candidate_2 ||
$candidate_1 || $candidate_3 || $candidate_4 || $candidate_5!= 0){echo(100*round($candidate_1/($candidate_2+$candidate_1+$candidate_3+$candidate_4+$candidate_5),5));}} ?>'
height='20'>
<?php if(isset($_POST['monthReport'])){ if ($candidate_2 ||
$candidate_1 || $candidate_3 ||$candidate_4 || $candidate_5!= 0)
{echo(100*round($candidate_1/($candidate_2+$candidate_1+$candidate_3+$candidate_4+$candidate_5),5));}} ?>% of <?php if(isset($_POST['monthReport'])){echo $totalvotes;} ?> total votes
<br> votes <?php if(isset($_POST['monthReport'])){ echo $candidate_1;} ?>
<br>
<br>
<?php if(isset($_POST['monthReport'])){ echo $candidate_name_2;} ?>:<br>
<img src="images/candidate-2.gif"
width='<?php if(isset($_POST['monthReport'])){ if ($candidate_2 || $candidate_1 || $candidate_3 || $candidate_4 || $candidate_5!= 0){echo(100*round($candidate_2/($candidate_2+$candidate_1+$candidate_3+$candidate_4+$candidate_5),5));}} ?>'
height='20'>
<?php if(isset($_POST['monthReport'])){if ($candidate_5 || $candidate_4 || $candidate_3 || $candidate_2 || $candidate_1!=0){echo(100*round($candidate_5/($candidate_5+$candidate_4+$candidate_3+$candidate_2+$candidate_1),5));}} ?>% of <?php if(isset($_POST['monthReport'])){echo $totalvotes;} ?> total votes
<br>votes <?php if(isset($_POST['monthReport'])){echo $candidate_5;} ?>
<br>
<br>
<br>
</div>
</body></html>
i just add
error_reporting(1);
and everything works fine now

Pagination script added php page isn't loading or showing any error

I tried to add a pagination script to my existing php page of sql queries.
But after adding the script the page is kept on loading without showing any content or error.
My code goes as:
<?php include('db.php'); ?>
<?php // define how many results you want per page
$results_per_page = 10;
// find out the number of results stored in database
$sql10='SELECT * FROM smf_messages';
$result10 = mysqli_query($conn, $sql10);
$number_of_results = mysqli_num_rows($result10);
// determine number of total pages available
$number_of_pages = ceil($number_of_results/$results_per_page);
// determine which page number visitor is currently on
if (!isset($_GET['page'])) {
$page = 1;
} else {
$page = $_GET['page'];
}
// determine the sql LIMIT starting number for the results on the displaying page
$this_page_first_result = ($page-1)*$results_per_page;
?>
Now the sql query codes to get the data from the respective tables...
<?php
$sql2 = "SELECT * FROM smf_log_digest WHERE note_type = 'topic' ORDER BY id_msg DESC LIMIT 420";
$result2 = $conn->query($sql2);
if ($result2->num_rows > 0) {
while($row2 = $result2->fetch_assoc()) {
$number = $row2["id_msg"];
?>
This query relates to the content from which table to be retrieved..
<?php
// retrieve selected results from database and display them on page
$sql20='SELECT * FROM smf_messages WHERE id_msg = $number AND id_board = 4 LIMIT ' . $this_page_first_result . ',' . $results_per_page;
$result20 = mysqli_query($conn, $sql20);
while($row20 = mysqli_fetch_array($result20)) {
$member = $row20["id_member"];
$replies = $row20["id_topic"];
?>
<?php
$sqlstep1 = "SELECT COUNT(*) AS total FROM smf_log_digest WHERE note_type = 'reply' AND id_topic = $replies";
$rowNumstep1 = mysqli_query($conn, $sqlstep1);
$countstep1 = mysqli_fetch_assoc($rowNumstep1);
?>
// Body
<article class="well btn-group-sm clearfix">
<div class="topic-desc row-fluid clearfix">
<div class="col-sm-2 text-center publisher-wrap">
<img src="assets/images/profile.png" alt="" class="avatar img-circle img-responsive">
<h5><?php echo $row3["poster_name"]; ?></h5>
<small class="online">Member</small>
</div>
<div class="col-sm-10">
<header class="topic-footer clearfix">
<!-- end tags -->
</header>
<!-- end topic -->
<h4> <?php echo $row20["body"]; ?></h4>
<div class="blog-meta clearfix">
<small><?php echo $countstep1["total"]; ?> Replies</small>
<small><?php echo date('m/d/Y', $row20["poster_time"]); ?></small>
</div>
View the topic →
</div>
</div>
</article>
//end of body
<?php
}
// display the links to the pages
for ($page=1;$page<=$number_of_pages;$page++) {
echo '' . $page . ' ';
}
?>
<?php }
} else {
echo "";
}
?>
Please note that the data base connections are all checked and are right..
Any help is appreciated..
add this on top then check for error.
error_reporting(E_ALL);
ini_set('desplay_errors','1');

Recommended user video Like youtube

I am trying to make a youtube like main page. With the code below I want to make videos that are recommended for my users.
The following code shows only a user's video.
<?php $query = "SELECT
user.uid,
user.user_name,
user.user_avatar,
user_posts.uid_dk,
user_posts.post_id,
user_posts.post_name,
user_posts.post_info,
user_posts.post_time,
user_posts.post_ext,
user_posts.post_num,
user_posts.post_views
FROM user
JOIN user_posts
ON user_posts.uid_dk = user.uid
WHERE user_name='$user_name' LIMIT 5";
$run_query = mysql_query($query);
while($data=mysql_fetch_assoc($run_query)){
$post_name=$data['post_name'];
$post_time = $data['post_time'];
$post_views = $data['post_views'];
$post_numid = $data['post_num'];
$post_id = $data['post_id'];
$user_name = $data['user_name'];
$user_avatar = $data['user_avatar'];
?>
<div class="onerilent"><img src="<?php echo $user_avatar;?>"><?php echo $user_name ;?> Recommended for you</div>
<div class="onmnwrp">
<div class="onmn">
<div class="onmn_img"><img src="<?php echo $base_url.'user_uploads/'.$post_num;?>.png"></div>
<div class="onmg_tit"><?php echo $post_name;?></div>
<div class="onm_snm">gönderen: <?php echo $user_name;?></div>
<div class="onm_tim"><?php echo $post_views;?> views</div>
</div>
</div>
<?php } ?>
I want to show this section only one time.
<div class="onerilent"><img src="<?php echo $user_avatar;?>"><?php echo $user_name ;?> Recommended for you</div>
Anyone can help me in this regard ?
The easiest way would be with a counter, like this:
<?php
$query = "SELECT
user.uid,
user.user_name,
user.user_avatar,
user_posts.uid_dk,
user_posts.post_id,
user_posts.post_name,
user_posts.post_info,
user_posts.post_time,
user_posts.post_ext,
user_posts.post_num,
user_posts.post_views
FROM user
JOIN user_posts
ON user_posts.uid_dk = user.uid
WHERE user_name='$user_name' LIMIT 5";
$run_query = mysql_query($query);
$counter = 1;
while($data=mysql_fetch_assoc($run_query)){
$post_name=$data['post_name'];
$post_time = $data['post_time'];
$post_views = $data['post_views'];
$post_numid = $data['post_num'];
$post_id = $data['post_id'];
$user_name = $data['user_name'];
$user_avatar = $data['user_avatar'];
if($counter == 1){
$counter++;
echo '<div class="onerilent"><img src="'.$user_avatar.'">'.$user_name.' Recommended for you</div>';
}
?>
<div class="onmnwrp">
<div class="onmn">
<div class="onmn_img"><img src="<?php echo $base_url.'user_uploads/'.$post_num;?>.png"></div>
<div class="onmg_tit"><?php echo $post_name;?></div>
<div class="onm_snm">gönderen: <?php echo $user_name;?></div>
<div class="onm_tim"><?php echo $post_views;?> views</div>
</div>
</div>
<?php
}
?>
note the $counter variable is set to 1 before the loop, and inside the loop there is a condition to check if it is set to the value 1, and if it is, then it echo's your html and increments the $counter, so that it is no longer set to 1

Categories