Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mysql_connecti issue

Status
Not open for further replies.

svar

Programmer
Aug 12, 2001
349
0
0
GR
Looks like I am doing something wrong here:
mysql -u root -p
Enter password: (my_mysql_passwd)
Welcome to the MySQL monitor. Commands end with ; or \g.

mysql>
mysql> USE MYDB;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> SHOW TABLES;
.... shows all tables in MYDB


So in php I assume
$dbuser='root';
$dbpass='my_mysql_passwd';
$dbname='MYDB';

$link = mysqli_connect('localhost',"$dbuser","$dbpass","$dbname") or die("Some error occurred during conne
ction to the $dbname database " . mysqli_error($link));


produces nothing
same for

$link = mysqli_connect("localhost","$dbuser","$dbpass","$dbname");
if (mysqli_connect_errno($link))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

Any idea what is wrong ?
 
Are sure PHP us running?

Is your php code between php tags?

If you place the following in a blank php file and try to load it with your browser does it show something?

Code:
<?php
phpinfo();
?>

How are you attempting to run your PHP code?





----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Yes, it is. phpinfo works fine.
I look for systax errors by
php myphpscript.php

and test via the browser
localhost/my_php_test_app/test.php


it does echo diagnostics (not shown in the piece I posted), but nothing after $link=

Looks like it's clearly a mysql connect thing and trying to figure out what I am doing wrong
 
Add this to the start of the script and post back the exact output.

PHP:
ini_set('display_errors', true);
error_reporting(E_ALL);
 
I agree. Sounds like your PHP setup does not have display_errors turned on.For development scenarios its better to keep it on, and error_reporting to E_ALL in your PHP.ini.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Thanks, I got this to work
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top