Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Web Development
You last visited: Today at 16:18

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Error on my Website someone can help me?

Discussion on Error on my Website someone can help me? within the Web Development forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Oct 2020
Posts: 43
Received Thanks: 1
Error on my Website someone can help me?

I have this error, i don't know why...

Fatal error: Call to a member function bindValue() on a non-object in C:\xampp\htdocs\index.php on line 81


My Code:



Someone can hep me pls?
-Nástý is offline  
Old 02/20/2021, 13:41   #2
 
elite*gold: 0
Join Date: Jan 2015
Posts: 7
Received Thanks: 3
From where comes $web?
Contra1234 is offline  
Old 02/21/2021, 08:18   #3
Moderator


 
elite*gold: 26
Join Date: Dec 2010
Posts: 2,577
Received Thanks: 1,795
#moved
stotterer09 is offline  
Old 02/23/2021, 13:33   #4
 
elite*gold: 95
Join Date: Nov 2009
Posts: 646
Received Thanks: 44
Quote:
Originally Posted by -Nástý View Post

Code:
$sql = 'SELECT id, title, text, image, alttext, date FROM news WHERE hot = :hot ORDER BY date DESC LIMIT';
$qry = $web->prepare($sql);
$qry->bindValue(':hot', 0);
$qry->execute();
Your error is on bindValue. Try this:



Code:
$server   = "mysql:dbname=DBNAME;host=LOCALHOST";
$user = "root";
$pass = "";

$pdo = new PDO($server,$user,$pass);

$stmt = $pdo->prepare("SELECT id, title, text, image, alttext, date FROM news WHERE hot = :hot ORDER BY date DESC LIMIT");
$stmt->execute([
    "hot" => 0
]);

while($dat = $stmt->fetch()){

      $id = $dat['id'];
      $title = $dat['title'];
      $text = $dat['text'];
      $img = $dat['image'];
      $imgalt = $dat['alttext'];
      $date = $dat['date'];


      ... and so on ...

}

?>
You dont need to bind a value with bindValue(), you can do it with ->execute([ "value" => $value ]);
Legithos is offline  
Thanks
1 User
Old 02/24/2021, 09:57   #5



 
elite*gold: 50
The Black Market: 241/0/0
Join Date: Apr 2011
Posts: 11,087
Received Thanks: 2,410
It seems the variable $web is not a instance of PDO.
Just do a var_dump of that variable and check what happens, also you should remove the ":" on the first bindValue parameter.
You dont have to rewrite the code as Legithos suggested.
False is offline  
Old 02/24/2021, 13:19   #6
 
elite*gold: 95
Join Date: Nov 2009
Posts: 646
Received Thanks: 44
Quote:
Originally Posted by False View Post
It seems the variable $web is not a instance of PDO.
Just do a var_dump of that variable and check what happens, also you should remove the ":" on the first bindValue parameter.
You dont have to rewrite the code as Legithos suggested.
The ":" are fine if you use named placeholder like he did in this case.
Legithos is offline  
Old 02/25/2021, 09:32   #7



 
elite*gold: 50
The Black Market: 241/0/0
Join Date: Apr 2011
Posts: 11,087
Received Thanks: 2,410
Quote:
Originally Posted by Legithos View Post
The ":" are fine if you use named placeholder like he did in this case.
I know, but it also works without ":" which makes the code cleaner
False is offline  
Reply


Similar Threads Similar Threads
Cquery Flyff Error, someone could help me with this error?
04/06/2015 - Flyff Private Server - 3 Replies
I am with this error when closing accountserver, DatabaseServer ... not save items, lvl Print Screenshot by Lightshot Skype douglas.csr
Can someone help me make a private sevrer website?
01/11/2012 - Silkroad Online - 0 Replies
need help making a website for a Private sevrer
PLEASE......CAN SOMEONE CAN GIVE ME AN ENGINE THAT CAN'T BE DETECTED...
12/30/2009 - Grand Chase Hacks, Bots, Cheats & Exploits - 3 Replies
...GIVE ME AN ENGINE THAT IS N0T DETECTED..... KAHIT NA PANG 5 DAYS LANG !^^...IF YOU ARE FINISH TO READ YOU CAN CLOSED THIS THREAD....>.<:):):):):)



All times are GMT +1. The time now is 16:18.


Powered by vBulletin®
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

BTC: 33E6kMtxYa7dApCFzrS3Jb7U3NrVvo8nsK
ETH: 0xc6ec801B7563A4376751F33b0573308aDa611E05

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2021 elitepvpers All Rights Reserved.