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
    Possible duplicate of [Full URL not working with php include](https://stackoverflow.com/questions/13369529/full-url-not-working-with-php-include) – miken32 Apr 21 '19 at 21:31

1 Answers1

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.

  • "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 – Danish Hakim Khan Apr 21 '19 at 21:32
  • 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(); – Vasiliu Robert Apr 21 '19 at 21:35
  • So, that worked. I think you can carry on from here. – Danish Hakim Khan Apr 21 '19 at 21:43