| | |
cannot connect to mysql server
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Dec 2008
Posts: 1
Reputation:
Solved Threads: 0
hallo ppl,
i also have the same problem,
my php connection with MySQL is not working, and couldnt connect to server is displayed y my PHP
should i alter PHP's php.ini to access mysql?
is there any restriction that i have to store the Mysql directly in my C drive... if so i have currently installed in C:\Program Files\MySQL\MySQL Server 4.1
how can i change?
thanks in advance
this is what i did
Browse to http://localhost/test_insert_sql.php, then http://localhost/test_select_sql.php. Every time you view test_insert_sql.php, it adds a line to the database; viewable from test_select_sql.php. Now, even if you reset you computer the data is still stored in the database.
i also have the same problem,
my php connection with MySQL is not working, and couldnt connect to server is displayed y my PHP
should i alter PHP's php.ini to access mysql?
is there any restriction that i have to store the Mysql directly in my C drive... if so i have currently installed in C:\Program Files\MySQL\MySQL Server 4.1
how can i change?
thanks in advance
this is what i did
php Syntax (Toggle Plain Text)
<?php // Connect to the database $dbhost = 'localhost'; $dbusername = 'testuser'; $dbpasswd = 'testpassword'; $database_name = 'simple'; $connection = mysql_connect("$dbhost","$dbusername","$dbpasswd") or die ('Couldn\'t connect to server.'); $db = mysql_select_db("$database_name", $connection) or die('Couldn\'t select database.'); // Generate SQL code to store data on database. $insert_sql = 'INSERT INTO simple_table (text) VALUES (\'test text, 1,2,3\')'; // Execute SQL code. mysql_query( $insert_sql ) or die ( 'It Didn\’t Work: ' . mysql_error() ); // Tell User we are done. echo 'Code Inserted'; ?> Create a new file called "test_select_mysql.php" and enter the following code into it: <?php // Connect to the database $dbhost = 'localhost'; $dbusername = 'testuser'; $dbpasswd = 'testpassword'; $database_name = 'simple'; $connection = mysql_connect("$dbhost","$dbusername","$dbpasswd") or die ('Couldn\'t connect to server.'); $db = mysql_select_db("$database_name", $connection) or die('Couldn\'t select database.'); // Generate code to retrieve data from database. $select_sql = 'SELECT text FROM simple_table'; // Retrieve code from database. $result = mysql_query( $select_sql ) or die ( 'It Didn\’t Work: ' . mysql_error() ); // Display results to user. while ( $row = mysql_fetch_object ( $result ) ) { echo $row->text . ‘<br>’; } ?>
Browse to http://localhost/test_insert_sql.php, then http://localhost/test_select_sql.php. Every time you view test_insert_sql.php, it adds a line to the database; viewable from test_select_sql.php. Now, even if you reset you computer the data is still stored in the database.
Last edited by peter_budo; Jan 6th, 2009 at 1:59 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
•
•
Join Date: Jan 2009
Posts: 4
Reputation:
Solved Threads: 1
hi!
Just write according to my code.I think that will work.
Just write according to my code.I think that will work.
php Syntax (Toggle Plain Text)
<?php $host="localhost"; $user="root" //It may different $pass="" //If u use password that write between " " $database="test" //you can also use any any created database name. @mysql_connect($host,$user,$pass) or die("Sorry ,User name Or Password problem); @mysql_select_db($database); //What's you want to do write in here. //More comple Email me: <EMAIL SNIPPED> ?>
Last edited by peter_budo; Jan 6th, 2009 at 2:00 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
![]() |
Similar Threads
- how do I connect to MySQL server which is firewall protected? (Python)
- Can't connect to MySQL server on 'localhost' (10061) (PHP)
- need help with iptable and mySQL server (Linux Servers and Apache)
- ERROR 2002: Can't connect to local MySQL server (MySQL)
- setting up MyODBC to connect to MySQL, need help.... (MySQL)
- Can't connect to local MySQL server (MySQL)
Other Threads in the PHP Forum
- Previous Thread: difference between IE and Firefox
- Next Thread: Foreign Key is different than primary key
| Thread Tools | Search this Thread |
5.2.10 action apache api array beginner beneath binary broken cakephp checkbox class classes cms code cron curl database date destroy display dynamic echo echo$_get[x]changingitintovariable... email encode error fcc file files folder form forms function functions google header howtowriteathesis href htaccess html image images include insert ip javascript joomla limit link local login mail memberships menu mlm mod_rewrite multiple multipletables mysql mysqlquery neutrality oop open passwords paypal pdf php provider query radio random record remote rss script search server sessions sockets source space sql strip_tags syntax system table template thesishelp tutorial update upload url validator variable video voteup web window.onbeforeunload=closeme; youtube





