Connection SQL - PHP


#1

Hi, I am looking for a connection to a database on a php page but I have as code :

Fatal error: Uncaught Error: Call to undefined function mysql_select_db() in /storage/h15/176/1406176/public_html/index.php:63 Stack trace: #0 {main} thrown in /storage/h15/176/1406176/public_html/index.php on line 63

An idea please, it is quite urgent

thx


#2

Try visiting 000webhost.com then general settings and change PHP version to what you think the script uses.


#3

The mouline page for ten years with her,
I only need the address of the bass

My script so ca could help :

<?php //connexion a my SQL $connexion = mysqli_connect("000webhost.com", "id_info", "mdp"); //connexion a la BDD $base = mysql_select_db('id_info', $connexion); $posts="SELECT * FROM info ORDER BY id DESC"; $res=mysql_query($posts); while($post = mysql_fetch_array($res, MYSQL_BOTH)) { echo ''; echo ''; echo ''; echo ''; echo ''; echo '
'.$post["Date"].'
'.$post["Text"].'
'.$post["Lien"].'
'; echo '

___________________________________________________________________

'; } ?>

#4

localhost should be used not 000webhost.com
:smiley:


#5

Even in localhost or with 127.0.0.1 cella does not work

It puts me a message more

Warning: mysqli_connect(): (HY000/2002): Connection refused in /storage/h15/176/1406176/public_html/index.php on line 60

Fatal error: Uncaught Error: Call to undefined function mysql_select_db() in /storage/h15/176/1406176/public_html/index.php:63 Stack trace: #0 {main} thrown in /storage/h15/176/1406176/public_html/index.php on line 63


#6

Check with your script and use “mysqli” function.


#7

I put my script above but I only have the mysqli variable in the connection line.

I remade my script:

<?php //ini_set('display_errors','off'); //connexion a my SQL $connexion = mysqli_connect("127.0.0.1", "id_info", "mdp"); //connexion a la BDD $base = mysql_select_db('id_info', $connexion); $posts="SELECT * FROM info ORDER BY id DESC"; $res=mysql_query($posts); while($post = mysql_fetch_array($res, MYSQL_BOTH)) { echo ''; echo ''; echo ''; echo ''; echo ''; echo '
'.$post["Date"].'
'.$post["Text"].'
'.$post["Lien"].'
'; echo '

___________________________________________________________________

'; } ?>

#8

Not only in the connection line…but in other lines too.
either use “mysql” completely or use “mysqli” completely.
Dont mix both functions.

if you want to use “mysql” then php version should be 5.4 or less.
if you want to use “mysqli” then php version should be 5.5 or above.


#9

If you need any help in this PM me :slight_smile:


#10

What username/database name are you using?
You need to copy exact values from Manage Database page on 000webhost.com

Username will be like id123456_username and database name the same id123456_databasename
And obviously your password.


#11

I take the name of my database and user of the page in question after even to install my forum in phpbb3 it does not find me the connection to the BDD that I mete 127.0.0.1 or something else


#12

@MrOwned [quote=“MrOwned, post:11, topic:60683, full:true”]
I take the name of my database and user of the page in question after even to install my forum in phpbb3 it does not find me the connection to the BDD that I mete 127.0.0.1 or something else
[/quote]

Sry i didn’t get you…can you rephrase it??


#13

I am having a very similar problem.
When I try to get some sql data with a query I get the following error:
shell_exec() has been disabled for security reasons
Here is the php:

<?php $db = new mysqli('localhost', 'my id', 'my password', `my table name`); $query="SELECT `Column Name` FROM `my table name` WHERE `index` = 'something special'"; $results=$db->query($query); echo $results; var_dump ($results); ?>

#14

I solved my issue.
I forgot to include the autogen prefix for my db name.
I renamed the db in my mysqli() and it worked properly.


#15