0

I'm building a project that's supposed to connect between my laptop and Raspberry Pi through SSH, it should display data on my Pi's monitor from a database stored on a WAMP server on my laptop. However when I try to open the file in Chromium on the Pi nothing happens. It instead downloads the file as opposed to opening it. Also, when I type in my laptops IP Address i'm presented with an error message reading 'Forbidden. You do not have permission to access / on this server'. This error message is all over the internet but I can't find a working answer anywhere. Can anybody help me? It's pretty urgent I get it working. The code below is my PHP file:

<?php
    //Step 1
    $db = mysqli_connect('172.24.1.64', 'root', '', 'hospital') or die('Error connecting to MySQL server.');
    $dbhost = "localhost";
    $dbuser = "root";
    $dbpass = "";
    $dbname = "hospital";
    $db = mysqli_connect($dbhost, $dbuser, $dbpass) or die("dbconn");
    mysql_select_db($dbname, $db) or die("mysql");
?>

<html>
    <head>
    </head>
    <body>
        <h1>
            PHP connect to MySQL
        </h1>
        <?php
            //Step 2
            $query = "SELECT * FROM patients;";
            mysqli_query($db, $query) or die('Error querying database.');

            $result = mysqli_query($db, $query);
            $row = mysqli_fetch_array($result);

            while($row = mysqli_fetch_array($result)){
                $id = $row['id'];
                $patientname = $row['patient_name'];                
                $checkindate = $row['check_in_date'];
                $roomnumber = $row['room_number'];
                $bednumber = $row['bed_number'];
                $notes = $notes['notes'];
                echo "$id $patientname $checkindate $roomnumber $bednumber $notes";
            }
        ?>
    </body>
</html>
1

Make sure of the following things:

  1. Your server (WAMP/APACHE) is running on the laptop.

  2. Your file (let's call it index.php) is inside the server folder.(htdocs / www -> your server's root directory.)

  3. Try to locally access your file on the laptop's browser using localhost/index.php

  4. Check your laptop's IP address and then enter it in your Pi's Browser like so:xxx.xxx.xxx.xxx/index.php


  1. Check the error logs of your server and post in comments if this doesn't help.
  • 1. WAMP is running 2. The file is located at the following location: C:\wamp64\www\Hospital 3. I tried and can access the file locally 4. I checked the IP address in CMD -> ipconfig/all -> Ethernet Adapted Ethernet 2 -> IPv4 address. When I typed this into the address bar on the Pi I was given the error ' This server cannot be reached'. I think I'm making a very simple mistake with the IP Address on the pi – JLally Mar 18 '17 at 12:20
  • You need to allow port 80 over your firewall to access it over your pi – Shakti Phartiyal Mar 18 '17 at 13:28
  • how do i do this? – JLally Mar 18 '17 at 13:42
  • What Operating system are you using on your laptop? – Shakti Phartiyal Mar 18 '17 at 13:43
  • Windows 10, Raspbian on the Pi – JLally Mar 18 '17 at 13:47
0

I can think of a few things...

  1. Be sure that the port you are connecting to is allowed.
  2. Assuming your file is index.php, connect to <IP>/index.php.
  3. MAKE SURE YOUR FILE IS IN THE CORRECT FOLDER. Otherwise Apache won't serve it!
  4. MAKE SURE PHP IS INSTALLED. Execute php -v to check that it is installed and that it is the correct version.
  • How can I check if the port is allowed? Sorry a lot of this is new to me – JLally Mar 18 '17 at 12:59
  • Never mind :) Just add :8080 like so: xxx.xxx.xxx.xxx:8080/index.php – ALinuxLover Mar 18 '17 at 13:01
  • Check the wamp configuration for which port is being used.. it's probably port 80 bacause you said when you access it gives you a forbidden error. – Shakti Phartiyal Mar 18 '17 at 13:19
  • Anything in error logs ?? – Shakti Phartiyal Mar 18 '17 at 13:20
  • I tried 192.168.137.1:8080 but the same thing happened 'cannot be reached'. Please see answer below, thanks! – JLally Mar 18 '17 at 13:42
0

Are these details correct? I entered 192.168.137.1:8080 and nothing happened, below is a screengrab of my cmd when i asked for the IP enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.