1

Right now I'm doing a feedback system for my FYP. While I'm at it, I got this sudden error. I've installed php and xampp just to inform.

This is what the page error says:

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

I've tried checking other tutorials/guides and reviewing my code a couple times but I'm still clueless. What's even more frustrating is I need to fully complete this FYP work before due date that is in the next few days.

<?php
$server_name="localhost";
$username="apiz";
$password="";
$database_name="osfs";

$conn=mysqli_connect($server_name,$username,$password,$database_name);

Line 7 would refer to the last line here.

I'm currently stuck at this so if anyone could lend a hand or teach me on this, I'd really appreciate it.

Thank you. - Coding noob who doesn't want to fail his FYP

YN27
  • 33
  • 6
  • 1
    Use `$conn = new mysqli(params)` instead `mysqli_connect`. Here is some reference https://www.w3schools.com/php/func_mysqli_connect.asp – Marty1452 Dec 04 '21 at 13:42
  • @KenLee I don't think so. For sure, I have php_mysqli.dll in ext file folder – YN27 Dec 04 '21 at 13:43
  • @Marty1452 I've used the line code you gave but then the page said I have no mysqli class in my php file. How do I define the class if I may ask? – YN27 Dec 04 '21 at 13:55
  • @KenLee I've referred to the link and tested it just now. It displays this text which I don't understand much. function connect(){ $link=mysql_connect("DB_HOST","DB_USER","DB_PWD") or die("连接失败Error:".mysql_error().":".mysql_error()); mysql_select_db(DB_DBNAME); return $link; } – YN27 Dec 04 '21 at 13:58
  • 1
    1. Did you go the XAMPP control panel and check whether the mysql service has been started ? 2. Please use mysqli_, not mysql_ (you original connect code should be ok already) – Ken Lee Dec 04 '21 at 14:01
  • @KenLee Yes I've went to the XAMPP control panel and started mysql service. Then test the php file again. After that, I got an error that says something about mysqli class isn't found "Uncaught Error: Class "mysqli" not found in C:\xampp\htdocs\osfs\signup.php:7" – YN27 Dec 04 '21 at 14:07
  • @KenLee I've changed my code at line 7 to '$conn = new mysqli(params) according to the other person's comment just to notify – YN27 Dec 04 '21 at 14:09
  • If you use **new**, you are using class. (you are creating an object of the class using "new"). Please run a PHP script with the content `phpinfo();` and see whether mysqli is already installed and enabled. – Ken Lee Dec 04 '21 at 14:10
  • Did you fix your problem ? Actually XAMPP should come with MySQL, and the latest version of XAMPP should support both MySQLi and PDO. So unless you have serious problem in your initial installation, otherwise after your XAMPP installation if you have started Mysql service then you should be able to use both function (or class) of Mysqli . – Ken Lee Dec 04 '21 at 14:41
  • @KenLee I'm sorry for replying late. I'm getting sleepy/tired right now. It's getting close to midnight where I'm from. I hope it's okay if we continue after I wake up next morning. Again, I'm sorry for burdening you. I'll get back to you on what you said next morning. I'm signing out now. Next morning after waking up, I'll be back here. – YN27 Dec 04 '21 at 14:51
  • @KenLee I've checked the table like what you asked me to. From the 1st table, it says that my Virtual Directory Support, Thread Safety Zend Signal Handling, Zend Multibyte Support, DTrace Support are disabled. Meanwhile, Zend Memory Manager & IPv6 Support is enabled – YN27 Dec 05 '21 at 01:48
  • @KenLee For mysqlnd table, collecting memory statisctics is disabled & API extensions are of no value – YN27 Dec 05 '21 at 01:49

0 Answers0