Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
|
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 22nd, 2009, 08:38 PM
Registered User
 
Join Date: Mar 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Question Need Help for mysql connection

Code:
$conn = mysql_connect(SQL_HOST,SQL_USER,SQL_PASS)
or die('Could not connect to the database; ' . mysql_error());
mysql_select_db('posts', $conn)
  or die('Could not select the database; ' . mysql_error());
when I run this code I get:

Code:
Could not select the database; Access denied for user ''@'localhost' to database 'posts'
No matter what the constants' values are.
 
Old March 22nd, 2009, 11:57 PM
Authorized User
 
Join Date: Feb 2009
Posts: 16
Thanks: 0
Thanked 1 Time in 1 Post
Default

Can you echo it out and see what is the values coming for
SQL_HOST,
SQL_USER,
SQL_PASS

So that we can ensure the values are not null

If it comes correctly please check the permission for SQL_USER to access the 'posts' Database

Regards
Anees
 
Old April 3rd, 2009, 07:59 PM
Registered User
 
Join Date: Mar 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I get all non-null text from the constants
and now get in using mysqli_*() commands

the privileges were not a problem since i can do lots of stuff with a phpmyadmin that uses mysql_*() commands

Last edited by PHP65; April 3rd, 2009 at 08:01 PM.. Reason: typo
 
Old April 3rd, 2009, 08:03 PM
Registered User
 
Join Date: Mar 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

anyway, it shouldn't accept any values for the password and then stop when it goes to select the database.
 
Old May 4th, 2009, 02:48 AM
Authorized User
 
Join Date: Jul 2006
Posts: 73
Thanks: 11
Thanked 1 Time in 1 Post
Default

Hi PHP65
You go on: Beginning-PHP-6-Apache-MYSQL-6-DevelopmentCd-0470391146 and get code from this book.
Great luck





Similar Threads
Thread Thread Starter Forum Replies Last Post
C# and mySQL Connection naifwonder C# 5 March 8th, 2008 01:52 PM
DataSource connection with mysql joychand Struts 0 April 24th, 2007 10:19 AM
making an mysql connection Zoe-Alyssa Dreamweaver (all versions) 0 May 19th, 2006 02:16 PM
MySQL Database Connection jayteee Dreamweaver (all versions) 0 December 11th, 2004 11:27 PM
Mysql connection catab C# 4 December 7th, 2003 11:25 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.