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 5930991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:37:53+00:00 2026-05-22T14:37:53+00:00

I’m having this weird problem right now, I’m just working on a small admin

  • 0

I’m having this weird problem right now, I’m just working on a small admin backend thing that will allow users to upload a file and download it again, simple stuff.

I’m using PHP OOP with Classes and functions and things. Still pretty new at it. Currently on one page I have a “getRecentLinks” function that will call information from a couple tables and put it all out on the page in a table, it works just fine. One of the options on this page is to download the file that was uploaded to that individual row. So I just want it to be a link you click on to say, file-download.php?id=3.

Now on file-download.php I’m currently just testing to get the information on the page before I add the headers and things in there. So I just have a simple

$l = new Links();
$file = $l->getFileInfo($_GET['id']);
print_r($file);

this SHOULD just return information from the database, id, name of file, size, data, and mimetype.

Now this doesn’t work. I have no idea why but it doesn’t.

Now on my page where I have the getRecentLinks() function it works just fine. I even brought in the getRecentLinks() into my file-download.php page so it’s setup like this.

$l = new Links();
$l->getRecentLinks();
$file = $l->getFileInfo($_GET['id']);
print_r($file);

This works just fine and dandy, The second I remove getRecentLinks() it stops calling information from getFileInfo() and I cannot figure it out. I mean it’s not a huge deal i could just keep #l->getRecentLinks() there but I can see this getting annoying if I have to add it to every page I want to do something, I’m just at the start of this project.

Here’s the code in the Links class

public function getFileInfo($id)
{
    $result = $this->runQuery("SELECT * FROM file WHERE id ='".mysql_real_escape_string($id)."'");

    $resultSet = $this->fetch($result);

    return $resultSet;
}

and

public function getRecentLinks()
{
    $result = $this->runQuery("SELECT * FROM links ORDER BY date DESC");

    while($j = $this->fetch($result))
    {
        $resultSet[] = $j;
    }

    return $resultSet;
}

And heres my connections and fetch functions a friend helped me develop

public function runQuery($sql) {
    $this->connection = mysql_connect($this->dbhost, $this->dbuser, $this->dbpass);
    if(!$this->connection) {
        die("MySQL is down.");
    } else {
        mysql_select_db($this->dbname);
    }
    $result = mysql_query($sql,$this->connection) or die(mysql_error());

    return $result;
}

public function fetch($result)
{
    $resultSet = mysql_fetch_assoc($result);

    return $resultSet;
}
  • 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-22T14:37:54+00:00Added an answer on May 22, 2026 at 2:37 pm

    mysql_real_escape_string requires a connection. Since getRecentLinks opens a connection it works. But you call mysql_real_escape_string before runQuery (in execution order) in getFileInfo. In this case, I assume the id is an integer, so you’re better off and a lot cheaper to call intval($_GET['id']).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I need a function that will clean a strings' special characters. I do NOT
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small

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.