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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:57:06+00:00 2026-05-28T01:57:06+00:00

Possible Duplicate: php warning mysql_fetch_assoc i am just implementing a simple part of my

  • 0

Possible Duplicate:
php warning mysql_fetch_assoc

i am just implementing a simple part of my website that just takes a variable from the header(subid) checks it with the database and then outputs the other fields related to the variable.

However i am getting this error –

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/admin/public_html/report.php on line 14
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''/home/admin/public_html/log/log_274b43e6ad_New Text Document (7).txt.txt' at line 1

Here is the code for my page that does it all

include 'connect_to_mysql.php';
$sql_header = mysql_query("SELECT * FROM system");
$header_array = mysql_fetch_assoc($sql_header);
$total_scans = $header_array['total_scans'];
$malware_detected = $header_array['malware_detected'];
$total_users = $header_array['total_users'];

$report_id = $_GET['log'];
var_dump($report_id);
$sql_report = mysql_query("SELECT * FROM logs WHERE log_name='$report_id");
var_dump($sql_report);
$report_array = mysql_fetch_assoc($sql_report) or die(mysql_error());
$file_name = $report_array['file_name'];
$file_size = $report_array['file_size'];
$submission_date = $report_array['submission_date'];
$result = $report_array['result'];
$status = $report_array['status'];

Any ideas on what could be wrong? I have tried everything and checked my database, all the names are correct and everything, i even checked the $report_id variable in the database and it matches, so i am not sure why it is getting an error.

Thanks for the help

  • 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-28T01:57:07+00:00Added an answer on May 28, 2026 at 1:57 am

    Your code it not doing any error checking, so it’s no surprise the query breaks silently when it fails. Check for errors and it will tell you what is going wrong – how to do it is outlined in the manual on mysql_query() or in this reference question.. Example:

    $sql_report = mysql_query("SELECT * FROM logs WHERE log_name='$report_id");
    
    // Bail out on error 
    if (!$sql_report)  
      { 
        trigger_error("Database error: ".mysql_error(), E_USER_ERROR); 
        die();
       }
    

    In your specific case, you are missing a closing ' in

    WHERE log_name='$report_id")
    

    Also, the code you show is vulnerable to SQL injection. You need to escape every value you use like so:

    $report_id = mysql_real_escape_string($_GET['log']);
    

    for this to work, you need to put every value in your query into quotes.

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

Sidebar

Related Questions

Possible Duplicate: php date compare I have a date that I take from the
Possible Duplicate: php warning mysql_fetch_assoc I have a weird problem about my script. It
Possible Duplicate: php warning mysql_fetch_assoc I have tried my code and it seems to
Possible Duplicate: PHP: Script for generating Crossword game? Does anyone know any PHP-based simple
Possible Duplicate: Pass a PHP string to a Javascript variable (and escape newlines) I
Possible Duplicate: PHP: different quotes? Simple question: What is the difference between ' and
Possible Duplicate: PHP: How to remove specific element from an array? How can i
Possible Duplicate: PHP UML Generator I am trying to understand some php code that
Possible Duplicate: PHP error: Cannot modify header information – headers already sent I've built
Possible Duplicate: PHP 2-way encryption: I need to store passwords that can be retrieved

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.