简体   繁体   中英

I can't access my database in localhost using xampp

i use Xampp and its not work on port 80 so i've changed it to 8080 and now apache and mysql works fine. my problem is that when im try to access to a database that i already created on phpmyadmin it wont work!

i use this code:

<?php
$requesturi = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$pos = strpos($requesturi, "uni");

$hostname_excal = "localhost:8080";
$database_excal = "my_database";
$username_excal = "root";
$password_excal = "123456";

$excal = mysql_pconnect($hostname_excal, $username_excal, $password_excal) or trigger_error(mysql_error(),E_USER_ERROR); 
?>

i try localhost for hostname and it doesnt work either.

i test this in my online host and its works fine . but i need this to work on localhost so i can present this in a meeting.

help me please.

Did you changed the standart password? Xampp uses "" as initial password.

Try this:

$hostname_excal = "localhost";
$database_excal = "my_database";
$username_excal = "root";
$password_excal = "";

It looks like you have miss spelled the php function it should be:

mysql_connect

you have

mysql_pconnect

also I strongly recooment you do not use mysql at all, it is varnible to injections, try learing mysli or pdo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM