Skip to content Skip to sidebar Skip to footer

Insert Data Into Mysql Db With Php Script Doesnt Work

Hello developers out there, I am trying to insert data from my Android Application into my MySql Server (running on wamp) with php script. Thhose are my php scripts:

Solution 1:

The reason is the connection.

The correct syntax is

$con = mysqli_connect("localhost","my_user","my_password","my_db");

So, it must be

$connect= mysqli_connect(hostname,user,password,databaseName);

remove the empty parenthesis

Solution 2:

Can you access PhpMyAdmin using a browser? The error points out that the database was not accessible using your PHP application.

If you can't, make sure it is properly installed and is working.

If you can, make sure mysqli driver is installed. See this question to see if you have mysqli driver was installed and configured.

Solution 3:

Check your api first by running it on some online website and check if your db name is correct by simply inserting some data through a php script running on web and if problem not solve it might be problem in your connection of db.

Solution 4:

SOLUTION

I finally got what the problem was, if somebody else has this problem:

I was running another MySql Server I installed some time ago and forgot about it. So this one was running on my default port. I deinstalled this server and changed the port of my "real" server to the default port.

Anyways big thanks to everybody who tried to help me, which helped me get to the solution.

Post a Comment for "Insert Data Into Mysql Db With Php Script Doesnt Work"