0

I'm uploading my website on my web hosting and one page of them is not loading (is blank). On my localhost server wamp, this page is generated everytime by the every id from database. Settings on database connection and web server are correctly because the posting system is working, every submit is insert in my database. What is wrong?

include 'https://site.ro/includes/config.php';
include 'https://site.ro/includes/connection.php';
if (!isset($_GET['anunt']) || empty($_GET['anunt']) || !is_numeric($_GET['anunt'])) {
                $errors[] = 'Error';
            } else {
                $anunt_id = $_GET['anunt'];

                $sql = 'SELECT * 
                        FROM date_anunt
                        WHERE anunt = ?';

                $statement = $connection->prepare($sql);
                $statement->bind_param('i', $anunt_id);
                $statement->execute();
                $result = $statement->get_result();
                $anunt = $result->fetch_all(MYSQLI_ASSOC);
                $result->close();
                $statement->close();
    if (!$anunt) {
            $errors[] = 'Acest anunt nu exista!';
        } else {
            $anunt = $anunt[0];

            $marca = $anunt['marca'];
            $model = $anunt['model'];
            $caroserie = $anunt['caroserie'];
            $an = $anunt['an'];
            $km = $anunt['km'];
            $stare = $anunt['stare'];
            $pret = $anunt['pret'];
            $descriere = $anunt['descriere'];

            $sql = 'SELECT * 
                    FROM imagini_anunt 
                    WHERE image_id = ?';

            $statement = $connection->prepare($sql);
            $statement->bind_param('i', $anunt_id);
            $statement->execute();
            $result = $statement->get_result();
            $images = $result->fetch_all(MYSQLI_ASSOC);
            $result->close();
            $statement->close();
            $connection->close();
        }
    }
    ?>
1

1 Answer 1

0
include 'https://site.ro/includes/config.php';
include 'https://site.ro/includes/connection.php';

include is meant to include and evaluate a specified PHP file. If you fetch it locally, it can be processed like PHP - if you fetch it through a full URL, you will get the resulting HTML, that could result an error.

Try just includes/config.php and see if that works.

Sign up to request clarification or add additional context in comments.

3 Comments

"Still not working" is too broad .. what error are you getting. If you don't know, try putting error_reporting(E_ALL); and ini_set('display_errors','1'); on the top of this page to see the actual error
I've learned something new :) Fatal error: Uncaught Error: Call to undefined method mysqli_stmt::get_result() in /home5/autobupg/public_html/anunt.php:23 Stack trace: #0 {main} thrown in /home5/autobupg/public_html/anunt.php on line 23. Now line 23 is: $result = $statement->get_result();
So, that worked. I think you can carry on from here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.