Jump to content

PHP7, MySQL8, Apache2.4


eljaydee

Recommended Posts

I have been at this for several hours..

<?php
$conn = mysqli_connect(localhost, root, mypw, mydb) or die(mysqli_error($conn));

?>

I keep getting:  Parse error: syntax error, unexpected '?>', expecting ',' or ')' in C:\Apache24\htdocs\mysql_connect.php on line 4

I have tried copy and paste of mysqli_connect from several different web pages, nothing works. PHP is installed correctly, I have a db in MySQL, and Apache is installed with no errors.

what the...

Edited by eljaydee
typo
Link to comment
Share on other sites

Please use the formatter (<>) and PHP. Copying and pasting code is never a good idea. You need to understand what the code is doing to adapt it to your specific application. Since you did not post all your code I can only guess that this is what you should use:

$conn = mysqli_connect("localhost","root","mypw","mydb") or die(mysqli_error($conn)); 

The arguments to connect need to be strings or string variables.

Link to comment
Share on other sites

5 hours ago, gw1500se said:

<?php 

$conn = mysqli_connect("localhost","root","6543212Xx!","lm") or die(mysqli_error($conn)); 

?>

Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in C:\Apache24\htdocs\mysql_connect.php:2 Stack trace: #0 {main} thrown in C:\Apache24\htdocs\mysql_connect.php on line 2

Link to comment
Share on other sites

11 hours ago, Barand said:

Check your php.ini file. Ensure mysqli extension is enabled.

Also, phpinfo() will tell you - if it is you will have a mysqli section.

yes, i enabled extension mysqli and have error notifications on... still can't get anything to work: i cannot understand why it is saying $conn=mysqli_connect() is undefined...

 

Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in C:\Apache24\htdocs\mysql_connect.php:2 Stack trace: #0 {main} thrown in C:\Apache24\htdocs\mysql_connect.php on line 2

Link to comment
Share on other sites

It shows what is in the mysql_connect.php file: 

<?php
$conn = mysqli_connect("localhost"," root", "123456" ,"myDB");
?>

Now I get this:

This page isn’t working

localhost is currently unable to handle this request.

HTTP ERROR 500
Link to comment
Share on other sites

This is copied right outta my php.ini file:

;extension=bz2
;extension=curl
;extension=fileinfo
;extension=gd2
;extension=gettext
;extension=gmp
;extension=intl
;extension=imap
;extension=interbase
;extension=ldap
;extension=mbstring
;extension=exif      ; Must be after mbstring as it depends on it
extension=mysqli
;extension=oci8_12c  ; Use with Oracle Database 12c Instant Client
;extension=odbc
;extension=openssl
;extension=pdo_firebird
;extension=pdo_mysql
;extension=pdo_oci
;extension=pdo_odbc
;extension=pdo_pgsql
;extension=pdo_sqlite
;extension=pgsql
;extension=shmop

I added the suggested line: extension=php_mysqli.dll

After restarting my computer I am now back to:

Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in C:\Apache24\htdocs\mysqli_connect.php:2 Stack trace: #0 {main} thrown in C:\Apache24\htdocs\mysqli_connect.php on line 2

========================================================================================

 

 

It shows what is in the mysql_connect.php file: 

<?php
$conn = mysqli_connect("localhost"," root", "123456" ,"myDB");
?>

Now I get this:

This page isn’t working

localhost is currently unable to handle this request.

HTTP ERROR 500
Link to comment
Share on other sites

i just restarted before replying to you, still get:

Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in C:\Apache24\htdocs\mysqli_connect.php:2 Stack trace: #0 {main} thrown in C:\Apache24\htdocs\mysqli_connect.php on line 2

this is supposed to be really easy and so far i have found nothing that will resolve this matter...starting to get pretty frustrated...

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.