Dakota Posted April 23, 2004 Posted April 23, 2004 I’m missing something here. I still cannot connect. I have tried an example from here, as well as the one in another book , but there has to be a point I am over looking. I have a simple database (names and addresses) I created through the 2 programs in Cpanel (Manage Mysql & Phpmyadmin). I learn by example. Could someone show what code I need to use to display the 1 record in my database. Screw security for now. Can I put everything in my Public/HTML folder until I get the hang of it? Lets pretend TCH login ID = johndoe Domain name = johndoe.com Database name= johndoe_test Table name = customers Field names = first and last Thanks for at least looking at my post. Quote
LisaJill Posted April 23, 2004 Posted April 23, 2004 (edited) Moved for organization. Also, it might help to show what the current code you are trying is (you can replace the sensitive details) and the error, if any. Edited April 23, 2004 by TCH-Lisa Quote
TCH-Rob Posted April 23, 2004 Posted April 23, 2004 Lets pretendTCH login ID = johndoe Domain name = johndoe.com Database name= johndoe_test Table name = customers Field names = first and last Dont forget Database login = johndoe_login Quote
flashram Posted April 24, 2004 Posted April 24, 2004 Just as a matter of interest, try using your cpanel username and password as the login and see if you can connect to mysql database that way. I had similar problems last night when setting up a photo web gallery PHP script and had similar problems and just as a matter of trying I did try my username and password for the cpanel login for the particular website I was installing it to, again after setting up another database, but deleted that one and used the one already in there. If that all makes sense to you. Quote
pat@total Posted April 28, 2004 Posted April 28, 2004 Dakota - I just set up my first MySQL database and was having the same problem. I did as Peter suggested and it worked. Of course, using your cpanel log-in is not the final answer. Here's what I found. It's fundamental and probably available in the documentation but as you said, some of us learn by doing. You set up users in the MySQL maintenance section (second section). What I discovered is that you then need to go into the top section and select that user and select add user to database. Now it works as it should. Hope this helps. Quote
TCH-Don Posted April 28, 2004 Posted April 28, 2004 Also in MySql after you add a user to the database, it shows sample connect strings PHP $dbh=mysql_connect ("localhost", "cpanelname_dbname", "") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("cpanelname_dbname"); Quote
roadmap Posted May 3, 2004 Posted May 3, 2004 Here is the error I'm getting; Warning: main(contentdb.php): failed to open stream: No such file or directory in /home/john_doe/public_html/quiz.php on line 208 Warning: main(): Failed opening 'contentdb.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/john_doe/public_html/quiz.php on line 208 Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/john_doe/public_html/quiz.php on line 210 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/john_doe/public_html/quiz.php on line 218 Quote
LisaJill Posted May 3, 2004 Posted May 3, 2004 Do you see the file "contentdb.php" in your public_html folder? Quote
roadmap Posted May 3, 2004 Posted May 3, 2004 Now the only message I'm getting is: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/john_doe/public_html/quiz.php on line 218 Quote
DarqFlare Posted May 3, 2004 Posted May 3, 2004 Can you post the query that is giving you that error, on line 218? Quote
DarqFlare Posted May 4, 2004 Posted May 4, 2004 Go to the line #218 in quiz.php and tell us what it says... lol Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.