riley200007 Posted August 7, 2007 Share Posted August 7, 2007 hey guys im trying to upload a database into company websites directory i have checked the server using phpinfo and php and mysql are both installed all i have put up there is a small access database on there with one test record im trying to connect to the damn thing and read the record but all i get is my_sql cannot connect to database, there is no user name or password on the database so i have taken the two varibles away from the mysql_connect(localhost,$user,$password); @mysql_select_db($database) or die( "Unable to select database"); this is the code i am using bar company details for obvious reasons <? $database="database.accdb"; mysql_connect(localhost); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM contacts"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Database Output</center></b><br><br>"; $i=0; while ($i < $num) { $first=mysql_result($result,$i,"first"); $last=mysql_result($result,$i,"last"); $phone=mysql_result($result,$i,"phone"); $mobile=mysql_result($result,$i,"mobile"); $fax=mysql_result($result,$i,"fax"); $email=mysql_result($result,$i,"email"); $web=mysql_result($result,$i,"web"); echo "<b>$first $last</b><br>Phone: $phone<br>Mobile: $mobile<br>Fax: $fax<br>E-mail: $email<br>Web: $web<br><hr><br>"; $i++; } ?> and this is what im getting Warning: mysql_connect(): Access denied for user 'root'@'localhost' (using password: NO) in /usr/local/psa/home/vhosts/(company address)/httpdocs/test.php on line 11 Unable to select database can any1 please help cheers Link to comment https://forums.phpfreaks.com/topic/63696-mysql-need-help-starting-off/ Share on other sites More sharing options...
effigy Posted August 7, 2007 Share Posted August 7, 2007 You're not passing enough parameters to mysql_connect, nor checking to see if it succeeded. See example 1385 here. Link to comment https://forums.phpfreaks.com/topic/63696-mysql-need-help-starting-off/#findComment-317521 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.