MySQL Forums
Forum List  »  Newbie

localhost php sqli
Posted by: Stan Kruger
Date: November 25, 2022 03:45PM

Running windows 10, php 8.1.13, newest community mysql, localhost:8000 on mozilla firefox.

I'm new to web development, I'm trying to use mysql with php to maintain a user database for a website. I test my development on a php localhost run from the windows command prompt (php -S localhost:8000 -t <dir> ) and then enter localhost:8000 as the URL in firefox. I've gotten php code to run fine on localhost in this manner.

After downloading mysql, I'm able to successfully use procedural mysqli database instructions through php on the windows php shell. I've created a mysql database with php, added simple entries with php, and then later retrieved them through php, so php is playing nicely with mysql.

So php is playing nicely with mozilla/localhost, and php shell is playing nicely with mysql, but when I try to combine the two processes (manipulate mysql database through a php server run as localhost) I just get a blank, white screen on firefox with no errors in the console or the terminal window.

The problem seems to happen almost immediately (this exact code executes fine (returns "success!") from the php shell window):

echo "test1";
$conn = mysqli_connect("localhost", $username, $password);
echo "test2";
if (!$conn) 
{
echo "no connection";
}
else
{
echo "success!"
}
mysqli_close($conn);
echo "test3";


$conn appears to be declared OK. If I comment out the if statement then both test1, test2, and test3 echoes are visible, and I can close $conn. It's only when I actually try to DO anything with the connection (even this if statement) that the white screen appears.

Advice? Do I need to initialize the mysql server or something when run in this manner? Thanks!

Options: ReplyQuote


Subject
Written By
Posted
localhost php sqli
November 25, 2022 03:45PM
November 25, 2022 03:49PM
November 25, 2022 07:13PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.