unable to use php with mysql

goldengoose9999

New Member
Messages
4
Reaction score
0
Points
1
Hi all, i have an INFINITYFREE plan. I am trying to practice php-mysql on X10HOSTING. I apologize for my php-mysql ignorance. I am not able to run a minimal php sample page towards my mysql database. I have searched on x10hosting php mysql for hints, but i have found nothing useful. Obviously, with php pages without mysql connection is all ok. I have created a database, a table inside it with PHPMYADMIN, inserted some records with PHPMYADMIN, but my sample php pages cannot work with the database. For example, the CONNECT goes wrong, but without messages, and i cannot do problem determination.
Please, may you give me some basic php-mysql samples, or hints, in order to practice?
Thanks in advance.
 

goldengoose9999

New Member
Messages
4
Reaction score
0
Points
1
Hi, i tried also this code, copied from this thread:
https://community.x10hosting.com/community/threads/mysql_connect-error.140618/
but i get HTTP ERROR 500.
Please, may you help me?
Thanks in advance
----------------------------------------------------------------------------
<?php
// THIS IS A TEST PHP SCRIPT TO TEST CONNECTING TO YOUR MySQL DATABASE
// DO NOT INCORPORATE INTO YOUR SITE UNTIL YOU HANDLE ERRORS AND 'PASSWORD' TYPE DATA in THE APPROPRIATE WAY
//
// was tested on servers skyy, and bour at x10hosting
//
// Make sure any PHP files have permissions set to 0644 (NOT 0666 or 0777) and subdirectories set to 0755
//
// There is a possibility your .htaccess file can cause problems
// some .htaccess directives that work on other sites do not work on x10Hosting 'free' sites
// cPanel's "IP Deny Manager" on x10Hosting 'free' sites makes the wrong code
//
// Some say x10hosting server boru is haunted.
//

$serverName = "localhost"; // MySQL server name
$user_name = "dzifmwrx_prova02"; // MySQL user name _ do not forget the underscore
$password = "prova02"; // MySQL password
$db_name = "dzifmwrx_prova02"; // MySQL Database name - do not forget the underscore
$tableName = "provatab1"; // MySQL Table name

// try get "MySQL link identifier"
$dbConn = mysql_connect($serverName, $user_name, $password) or die("Cannot connect to server<br />\n MySQL error ==>" . mysql_errno() . "<== : ==>" . mysql_error() . "<== <br />\n");
print "Connected to MySQL server successfully<br />\n";

// try connect to database
mysql_select_db($db_name, $dbConn) or die("Cannot connect to database<br />\n MySQL error ==>" . mysql_errno($dbConn) . "<== : ==>" . mysql_error($dbConn) . "<== <br />\n");
print "Connected to database successfully<br />\n";

// try to get info from table
$query = 'SELECT * FROM ' . $tableName . ' LIMIT 0, 1';
$result = mysql_query($query, $dbConn) or die("Cannot select anything from table<br />\n MySQL error ==>" . mysql_errno($dbConn) . "<== : ==>" . mysql_error($dbConn) . "<== <br />\n");

print "I connected to your server, connected to your database, and received info from your table<br />\n";
?>
 
Top