开发者

Can't get PHP working with MySQL (using Linux)

开发者 https://www.devze.com 2023-01-31 13:24 出处:网络
Alright, when I compile this bit of code to test: <?php require(\'index.inc\'); $page = new buildpage();

Alright, when I compile this bit of code to test:

<?php

   require('index.inc');
   $page = new buildpage();
   $page->buildHeader();


   $dbase = $mysqli_connect('localhost', 'root', 'password');


<?php
   $page->buildFooter();
?>

I'm getting:

PHP Notice:  Undefined variable: mysqli_connect in

/home/tim/Doc开发者_如何学运维uments/Web/index2.php on line 9 PHP Stack trace: PHP 1. {main}() /home/tim/Documents/Web/index2.php:0 PHP Fatal error: Function name must be a string in /home/tim/Documents/Web/index2.php on line 9 PHP Stack trace: PHP 1. {main}() /home/tim/Documents/Webindex2.php:0

I located my mysql.so file and set it accordingly in my php.ini, but for some reason the mysql extension doesn't seem to be working... unless there's something wrong with my code.


That's because mysqli_connect is a function and not a variable. Remove the $ sign.

$dbase = mysqli_connect('localhost', 'root', 'password');


Yeah, remove the $. If you're trying to squelch potential error messages, use @.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号