mysqli_connect parse Error

Problems with the Windows version of XAMPP, questions, comments, and anything related.

mysqli_connect parse Error

Postby conexor » 23. December 2022 05:48

I am running XAMPP for Windows 8.1.12 under windows 11.
Just trying to do a first connection.
I have used phpmyadmin to create a database.
I run the script below and I get this result on my browser
Parse error: syntax error, unexpected single-quoted string “root”, expecting “)” in C:\xampp\htdocs\Test.php on line 12

Line 12 is $mysqli = mysqli_connect(‘localhost’, ‘root’, ‘’, ‘ftest’);

and the xampp FAQ says “The MySQL administrator (root) has no password.”

Code: Select all
<?php

echo "Hello";


//https://www.php.net/manual/en/mysqli.construct.php
/* You should enable error reporting for mysqli before attempting to make a connection */
//mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);

error_reporting(0);
mysqli_report(MYSQLI_REPORT_OFF);
$mysqli = mysqli_connect('localhost', 'root', '', 'ftest');
if (mysqli_connect_errno()) {
    throw new RuntimeException('mysqli connection error: ' . mysqli_connect_error());
   }

/* Set the desired charset after establishing a connection */
mysqli_set_charset($mysqli, 'utf8mb4');

printf("Success... %s\n", mysqli_get_host_info($mysqli));   
   
?>
conexor
 
Posts: 3
Joined: 07. August 2015 03:44
Operating System: WIN8

Re: mysqli_connect parse Error

Postby conexor » 23. December 2022 06:40

All fixed.
Notepad++ was in UTF8 mode.
Changing encoding to Ansi showed extra weird hidden characters.
Re typed by hand and it all worked.
conexor
 
Posts: 3
Joined: 07. August 2015 03:44
Operating System: WIN8


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 84 guests