Re: mysqli_connect doesn’t
| From: | Jarrod@binarybearllc.com | Date: | Sat, 30 May 2020 18:25:40 +0000 |
| Subject: | Re: mysqli_connect doesn’t | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-327175@lists.php.net to get a copy of this message | ||
Try close you’re html <head> Tag before you start the body tag <head></head>
<body><?php
‘All your Connection Script’ ?> </body>
Or just drop the html tags altogether.
- Jarrod
Sent from my iPhone
>> On May 30, 2020, at 4:24 AM, Yugroysl <yugroysl@gmail.com> wrote:
> I'm having trouble getting PHP7 to connect to a MariaDb database..
> The relevant script is shown below, copied from PHP documentation,
> but it won't connect.
>
> The setup:
>
> System 1: Windows 10, MariaDb 10.4.2, Apache 2.4, PHP 7; SQL client HeidiSQL
> System 2: Fedora 32 Workstation, MariaDb 10.4.2, Apache 2.4, PHP 7; SQL client Sequeler
>
> The databases on both systems are identical. The users are the same,
> with the same names, privileges and passwords on both. Using HeidiSQL
> I can connect perfectly to the databases on both machines, locally on
> Windows and remotely on Linux from Windows. Sequeler connects perfectly
> on the Linux box locally. Firewalls on both systems are properly configured.
>
> Attempts to connect with the following script fail on both systems.
>
>
> <html>
> <head>
> <body>
> <?php
>
> /*
> $host is set to one of these depending on the system:
> 127.0.0.1 locally on Linux
> localhost locally on Windows
> 192.168.2.55 remotely on Linux from the Windows box
> */
>
> $host = "127.0.0.1";
>
> /*
> these parameters are valid for both machines
> (obviously they're not the real ones!)
> */
> $usr = "me";
> $pw="me123456";
> $db="mydb";
>
> /* this is displayed correctly - shows that the parameters are ok */
> printf("Here: %s, %s, %s, %s<br>",$host,$usr,$pw,$db);
>
> $conn = mysqli_connect($host,$usr,$pw,$db); /* SCRIPT STOPS HERE */
>
> if ( !$conn ) {
> /* this is never displayed */
> die("Connect failed!");
> }
>
> if ( $result=mysqli_query($conn,"SELECT * FROM mytable") ) {
> $n=mysqli_num_rows($result);
> }
> mysqli_close($conn);
>
> printf("Found %d records",$n);
> ?>
>
> </body>
> </head>
> </html>
>
> Any ideas, anyone?
>
> Thanks in advance!
>
> PeterR.
>
>
> Virus-free. www.avg.com