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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:15:30+00:00 2026-06-16T13:15:30+00:00

Got code like: <?php require_once(../classes/pdo.class.php); $db = new mysql(); $db->connect(); class votingpanel{ public function

  • 0

Got code like:

<?php
require_once("../classes/pdo.class.php");
$db = new mysql();
$db->connect();
class votingpanel{

    public function logintopanel($username, $password){

        //Dane z logowania + token
        $login = mysql_real_escape_string($username); 
        $password = mysql_real_escape_string($password); 

            $sql = $db->prepare("SELECT * FROM xxx WHERE username = '$login'");
            $sql = $db->exec($sql);
            if($sql == 1){
                $password = sha1($password);
                $sql = $db->prepare("SELECT * FROM xxx WHERE username = '$login'");
                $sql = $db->exec($sql);
                $row = $sql->fetch();

                if($row['password'] == $password and $row['toplistadmin'] == 1){
                    $_SESSION['toplist_admin'] = 1;
                    $_SESSION['toplist_adminloged'] = 1;

                }
                else{
                    return false;
                }
            }
            else{
                return false;
            }


    }

}

?>

pdo class looks like:

<?php

require_once("../konfiguracja.php");

class mysql{
    public function connect(){
        try {
            $conn = new PDO('mysql:host=xxx;dbname=xxx', 'xxx', 'xxx');
            $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        } catch(PDOException $e) {
        echo 'ERROR: ' . $e->getMessage();
        }
    }
}
?>

And in return i get such errors:

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'radiolev'@'localhost' (using password: NO) in /home/radiolev/public_html/top/toplist.class.php on line 10

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/radiolev/public_html/top/toplist.class.php on line 10

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'radiolev'@'localhost' (using password: NO) in /home/radiolev/public_html/top/toplist.class.php on line 11

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/radiolev/public_html/top/toplist.class.php on line 11

Fatal error: Call to a member function prepare() on a non-object in /home/radiolev/public_html/top/toplist.class.php on line 13

I don’t understand why it appears cause the mysql passwords are good. Tried them with normal mysql_connect and it worked but still dont know why it appears here in pdo ;s

  • 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-06-16T13:15:32+00:00Added an answer on June 16, 2026 at 1:15 pm

    You shouldn’t try to use mysql_real_escape_strings() with PDO–it’s not in the PDO library (it’s in the old and nasty mysql library) and uses a different (global–blah) connection to the DB.

    First get rid of the 2 lines with the mysql_real_escape_strings().

    Second, you’re using prepared statements, so BIND your values–it’s easy! Just replace the variable with a placeholder that starts with a colon, without manually quoting it. Then call bindValue() with is a method of your newly created PDOStatement (created by $db->prepare()). Finally call execute on the statement.

                  $sql = $db->prepare("SELECT * FROM xxx WHERE username = :login ");
                  $sql->bindValue(":login", $login);
                  $result = $sql->execute();
    

    This will safely escape and protect from injection the $login variable on the mysql server side.

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

Sidebar

Related Questions

I've got code like that: <ul class=gallery_demo_unstyled> <li class=active><img src='001.jpg' /></li> <li><img src='002.jpg' /></li>
I have got code like this var challegneListener; $(document).ready(function(){ var challegneListener = setInterval(challengeListenerBot(),5000); });
I have called hash function in my code like (php version 5.2.14 ) $username
I've got code like this on my page: <div class=item item_wall id1></div> <div class=item
I've got some code like this: letters = [('a', 'A'), ('b', 'B')] i =
Suppose we got a code like this: IEnumerable<Foo> A = meh(); IEnumerable<Foo> B =
It's a really simple problem. I've got HTML code like this : <div> <img
I got a javascript code like this to validate the file extension for my
I have got a chunk of code like for i in range(0, len(a)) b[i]
I got a task to maintain a c# project, I found some code like

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.