Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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.
Reply With Quote
  #2 (permalink)  
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
Reply With Quote
  #3 (permalink)  
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
Reply With Quote
  #4 (permalink)  
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.
Reply With Quote
  #5 (permalink)  
Old May 4th, 2009, 02:48 AM
Authorized User
Points: 359, Level: 6
Points: 359, Level: 6 Points: 359, Level: 6 Points: 359, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2006
Location: Belgrade, Serbia, Yugoslavia.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 10:58 AM.


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