You are not logged in.
I am new to LAMP and PHP so be easy on me. I am trying to setup a LAMP stack I get this error when running the php script:
[vagrant@arch http]$ php index.php
PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /srv/http/index.php:3
Stack trace:
#0 {main}
thrown in /srv/http/index.php on line 3This is the script
<?php
mysql_connect('127.0.0.1', 'root', '');
?>More information:
[vagrant@arch http]$ php -m
[PHP Modules]
Core
ctype
curl
date
dom
fileinfo
filter
hash
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
Reflection
session
SimpleXML
SPL
standard
tokenizer
xml
xmlreader
xmlwriter
zip
zlib
[Zend Modules]I have installed the packages php, apache, php-apache, mariadb, and configured them according to the MariaDB, php, Apache wiki pages. The system is up-to-date and has been restarted.
Any help would be greatly appreciated
Last edited by orange_lizzard (2022-06-21 08:41:22)
Offline
Probably deprecated.
https://www.php.net/manual/en/function. … onnect.php
Follow Arch first:
https://wiki.archlinux.org/title/PHP#MySQL/MariaDB
Last edited by Maniaxx (2022-06-21 08:41:55)
sys2064
Offline
yep. I guess I should find a more up-to-date tutorial. Thanks a ton.
Offline
You are calling `mysql_connect`. That function belonged to a module that has been completely removed 7 years ago. To access databases PHP offers PDO, with the “pdo_mysql” module providing the backend for MySQL and MariaDB. There is also mysqli, but that extension has uses with very specific circumstances — when you must interface with MySQL client API more or less directly for specific, precisely defined features.
Since circumstances suggest you are just starting programming in PHP: whatever source you learn from and even suggested going near the `mysql_*` family of functions, stop using it instantly. It’s garbage. Not merely outdated: teaching that module was a horrible idea even before it has been removed from PHP.
Also, please consider changing the subject: you swapped “MariaDB” and “PHP”. That will confuse other people searching for help. :D
Last edited by mpan (2022-06-21 08:41:55)
Paperclips in avatars?
NIST on password policies (PDF) — see §3.1.1.2
Sometimes I seem a bit harsh — don’t get offended too easily!
Offline
thanks mpan, will do. Yep trash tutorial off YouTube. Funny thing is it's only like 2 years old. I thought it would be an okay jumping off point but yeah total trash. Can you recommend any guides to php for someone just starting out?
Offline
Unfortunately I myself can’t. Too long since I had a need for one.
But I see that the official documentation has a PDO tutorial: connecting, prepared statements and transactions. Statements which take no parameters are done using query method (Ctrl+F “example”). In general most answers at Stack Overflow are at least of decent value and those should teach you how to handle basic use cases.
Paperclips in avatars?
NIST on password policies (PDF) — see §3.1.1.2
Sometimes I seem a bit harsh — don’t get offended too easily!
Offline