Jump to content
Sunamena

What is wrong with this code

Recommended Posts

Hey all,



I have created a website on my local host. 
Now that  i try to upload it, i get many errors.

Such as this one:
$result = $stmt -> fetchAll(PDO::FETCH_NUM);
ERROR: Fatal error: Uncaught Error: Call to undefined method mysqli_stmt::fetchAll() in /customers/c/5/e/sunamena.be/httpd.www/eldiemus/nieuws.php:290 Stack trace: #0 {main} thrown in /customers/c/5/e/sunamena.be/httpd.www/eldiemus/nieuws.php on line 290

 

 

And will this still be valid?
$stmt -> bindParam(':datum', $datum, PDO::PARAM_INT);

 





I also had to change my connection method from
    $db = new PDO('mysql:host=urlToDatabasel;dbname=DatabaseName', 'DatabaseName', 'NotARealPassword');
   $db -> setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);


 

 

 


to

 $con=mysqli_connect("sunamena.be.mysql", "sunamena_be", "s6X6tyUj", "sunamena_be");

This is still save to use without the setAttribute?
   

Edited by Sunamena

Share this post


Link to post
Share on other sites

The new code should be MySqli

 

                        $sql="SELECT * FROM nieuws ORDER BY nieuwsID desc";
                        $deelStap=mysqli_query($con,$sql);

                        $result=mysqli_fetch_all($deelStap,MYSQLI_NUM);

                        $numberInResult = count($result);

 

 

 

But how to fetch one?

Edited by Sunamena

Share this post


Link to post
Share on other sites

It looks like you're mixing PDO and mysqli.  They aren't the same, you can't mix them.  The PHP has plenty of documentation for how to use both of them though.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...