Jump to content

Recommended Posts

Posted

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.

Posted (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 by TCH-Lisa
Posted
Lets pretend

TCH 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

Posted

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.

Posted

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.

Posted

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");

Posted

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

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...