Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6543649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:22:19+00:00 2026-05-25T11:22:19+00:00

The following is passed to the browser: http://localhost/like.php?f=1 where f=1 is the article ID

  • 0

The following is passed to the browser: http://localhost/like.php?f=1

where f=1 is the article ID which I would like to like. There is a user system and I would only like them to be able to like the article once (for obvious reasons). My code, pulls the information from the database about the article, then pulls through the user information (to get there ID from the current session) then checks to see if the user already liked this, and if not insert into the like database, or return back to the article page. Here is the code I have so far..

As you can see in the code, I’ve been trying to debug, but it’s not going well…

<?php
include "connect.php";
session_start();
$feed = $_GET['f']; 
$feeddb = "SELECT * from feeddb where ID=$feed";
$feeddb2 = mysql_query($feeddb) or die("Whuuut?");
$feeddb3 = mysql_fetch_array($feeddb2);
if (isset($_SESSION['usrname']))
{
    $player=$_SESSION['usrname'];
    $userstats="SELECT * from feedus where tit='$player'";
    $userstats2=mysql_query($userstats) or die("Could not get user stats");
    $userstats3=mysql_fetch_array($userstats2);
    $feedli = "SELECT * from feedli where PID=$feed";
    $feedli2 = mysql_query($feedli) or die("Could not get likes");
    while($feedli3=mysql_fetch_array($feedli2))
    {
        if($userstats3['ID'] == $feedli3['UID'])
        {
            echo $userstats3[ID];
            echo $feedli3[UID];
        } else { 
            $updatelike =
                "INSERT into feedli (PID, UID) values('$feed','$userstats3[ID]')";
            $updatelike2 = mysql_query($updatelike);
            echo $userstats3[ID];
            echo $feedli3[UID];
        }
    }
}
else
{
}
?>

Any help would be appreciated!

Edit: For Clarity – I would like the code to insert the PID (article ID which is in $feed) and UID (which is the users ID in $userstats3[ID]) into the table FEEDLI if they haven’t liked this article before, if they have, skip the code and go back to the previous article.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:22:19+00:00Added an answer on May 25, 2026 at 11:22 am

    i think you are not using $feeddb3 in the code.. this might be usefull. also try to avoid sql injections.

     <?php
     session_start();
     include "connect.php";
     $feed = $_GET['f']; 
    
     if (isset($_SESSION['usrname']))
     {
        $player=$_SESSION['usrname'];
        $userstats2=mysql_query("SELECT * from feedus where tit='".mysql_real_escape_string(stripslashes($player))."'") or die("Could not get user stats");
        $userstats3=mysql_fetch_array($userstats2);
    
        $feedli2 = mysql_query("SELECT * from feedli where PID='".mysql_real_escape_string(stripslashes($feed))."' AND UID = '".$userstats3['ID']."'");
    
        if(!mysql_num_rows($feedli2))
        {
            $updatelike2 = mysql_query("INSERT into feedli (PID, UID) values('".mysql_real_escape_string(stripslashes($feed))."','".mysql_real_escape_string(stripslashes($userstats3['ID']))."')");
            echo $userstats3['ID'];
        }
        else
        {
            echo "already liked";   
        }
    
     }
     ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to have the browser act as if the user had pressed the
For example, if passed the following: a = [] How do I check to
The string passed to my custom function is the following: SELECT key FROM ubis
I have the following code in a Runnable that gets passed to a thread
I am getting the following Error The model item passed into the dictionary is
In the following code, I passed the 1.3f to printFloat, but it was the
I'm trying to use the following technique described on symfony.com : http://symfony.com/doc/current/cookbook/testing/http_authentication.html in an
I'm following a tutorial http://fuelyourcoding.com/getting-started-with-jquery-mobile-rails-3/ transforming the views in a straightforward scaffolded Rails 3
I'm having trouble formulating HTTP cache headers for the following situation. Our server has
I've discovered that any time I do the following: echo '<a href=http:// title=bla>huzzah</a>'; I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.