0

first of all, yes, I noticed all other 1000 topics and most of them were about misplaced " and ', I checked my code multiple times and I find everything alright, still, I get this error:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/a8438725/public_html/connect.php on line 13

Which line is:

echo "Valoarea errno: " . mysqli_connect_errno() . PHP_EOL;

if I comment that line, I get this error:

Parse error: syntax error, unexpected T_EXIT in /home/a8438725/public_html/connect.php on line 15

this is the full code:

    <?php
$servername = "localhost";
$username = "*********";
$password = "*********";
$dbname = "*********";

    ini_set('display_errors', 1);
    error_reporting(-1);

    $db = mysqli_connect($servername, $username, $password, $dbname);
    if(!$db){
        echo "ERROR: We couldn't connect." . PHP_EOL;
        echo "Valoarea errno: " . mysqli_connect_errno() . PHP_EOL;
        echo "Valoarea error: " . mysqli_connect_error() . PHP_EOL;
        exit;
    }

    echo "Connected with success!" . PHP_EOL;
    echo "Host Info: " . mysqli_get_host_info($db) . PHP_EOL;


?>

I am very sorry if this has been solved already but I can't find the solution, checked multiple tutorials on how to connect it, checked tutorials on the If statement, checked my code, checked every statement that is in my code... there must be something that I did not notice :/

Anant Kumar Singh
  • 68,309
  • 10
  • 50
  • 94
Andrei
  • 31
  • 6
  • convert `echo "Valoarea errno: " . mysqli_connect_errno() . PHP_EOL; echo "Valoarea error: " . mysqli_connect_error() . PHP_EOL;` to `echo "Valoarea error: " . mysqli_connect_error();` And check – Anant Kumar Singh Apr 19 '17 at 09:11
  • @AlivetoDie I still get the same error – Andrei Apr 19 '17 at 09:12
  • 1
    @Andrei are you sure you have this much code only in you `connect.php`. because this code is working fine at my end. – Anant Kumar Singh Apr 19 '17 at 09:14
  • @AlivetoDie Thats all I have in connect.php and i use mywebsite.com/connect.php to test the connection, and it gives me the above errors. I also have some unfinished code in index.php, could that be the issue? Even if I go to /connect.php and they are not included.. – Andrei Apr 19 '17 at 09:16
  • Working fine on my side as well I get the message `Connected with success! Host Info: localhost via TCP/IP` – Masivuye Cokile Apr 19 '17 at 09:17
  • I've tested this on two different webhosts... zgaming.comxa.com/connect.php – Andrei Apr 19 '17 at 09:21
  • `` try this once – Anant Kumar Singh Apr 19 '17 at 09:22
  • Oh that worked! Thanks alot, still not sure why the other way didn't work but thanks! How do I mark this as solved? – Andrei Apr 19 '17 at 09:23

0 Answers0