Sql & php

Hi there :slight_smile:

I’m making JSON API with custom SQL and PHP script.
It works perfectly on my PC (LocalHost)
Now I want to make same thing but here on InfinityFree.
Where can i add my php script which will connect to DB and steam SQL data?

also here is my simple PHP script I’m running locally:

<?php
$connect = mysqli_connect("localhost", "root", "", "db");
$sql = "SELECT * FROM news";
$result = mysqli_query($connect, $sql);
$json_array = array();
while ($row = mysqli_fetch_assoc($result)) {
    $json_array[] = $row;
}
echo json_encode($json_array);
?>  

as you can see here:
connect = mysqli_connect(“localhost”, “root”, “”, “mev”);

I have to replace localhost with server name I guess?!? (sql305.epizy.com)
and root has to be replaced too or it can work without “root”?

Thanks in advance.

Yes, replace server name with the SQL server name you are provided with. Also, use the correct password. Is root a database?

1 Like

yes,you must fill all these database credentials with your own,itu must be specific
something like this :
connect = mysqli_connect(“sql305.epizy.com”, “epiz_737182”, “vJsjwkaja”, “epiz_737182_mev”);

2 Likes

Thanks for the answer mate, can you guide me with this question too? -

> Where can i add my php script which will connect to DB and steam SQL data?

Wow thanks mate for clear instructions! By the way can you please explain to me where i add php for my SQL, i simply can not find that option… :frowning:

You write it into a .php file.

1 Like

Alright, I swear this is my last question! :heart:

I’ve made .php file inside: File Manager → htdocs → PhpProject → mev.php

Here is the screenshot:

Imgur

Filled up random SQL data inside table:

Imgur

Now last step is to stream data like I was streaming locally from my pc

So how do I achieve that? I tried with 185.27.134.9/PhpProject/mev.php but it seems it does not work properly. Please help me with this if you know since my knowledge of PHP is zero, and I have to connect JSON data with my android app. (I’m on the last year of college and this here is my final graduation project :slight_smile: )

:heart: Much thanks @Fury_Phoenix :heart:

What is your domain name with extension, you may need to use that

Please don’t take a screenshot of your password and share it on a public forum.

I’ve reset your password now. Please update the password in your code accordingly or change it again if you want, just please don’t use this password again.

5 Likes

Please don’t take a screenshot of your password and share it on a public forum.

I’ve reset your password now. Please update the password in your code accordingly or change it again if you want, just please don’t use this password again

Yes, never do that

2 Likes

Main domain name: 4ulf7uiq.epizy.com

im so sorry, and thanks for heads up :slight_smile:

1 Like

It should be Buying and selling domains by experts | Hire a broker today! | Sedo

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.