Jump to content

Connecting to mysql setup


dgow13

Recommended Posts

I am watching some of the videos of PHP and MySQL: Connecting. I have been watching video part 3 for over an hours now, typing in everything just as he does on the screen, multiple times, without the same success. I am placing the code below if someone would like to help.

 

<head>
	<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
	<title>Untitled 1</title>

		<?php

			$my_connection = mysql_connect('localhost', 'root', '');

			if (!$my_connection) {
				die('Could not connect: ' . mysql_error());
			}

			echo 'Connection successful' . '<br><br>';

			mysql_close($my_connection);

		?>							

</head>

<body>
	Welcome to my MySQL database connection test page.
</body>

Link to comment
Share on other sites

I opened up a new php page to follow along with the tutorial. I then installed wamp (tried to follow the video instructions but what he did and what my options were while instralling it, were not the same).

 

wamp says all the services are running but when you hover over the icon it says it is off line.

 

When I open up the page in the localhost it says: "Welcome to my MySQL database connection test page."

 

Whwn I open it up online, after uploading it, it says: Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: NO) in /home/mychild/public_html/database.php on line 10

Could not connect: Access denied for user 'root'@'localhost' (using password: NO)

 

I checked my database for privileges and root, localhost are there.

Link to comment
Share on other sites

I hate to say it, but I'm really not sure. When I test it on my machine, everything works as it should. As far as I can tell, there is nothing wrong with the code. It sounds like WAMP is running properly, and it seems like you are putting your files in the right place...

 

One other option would be to try XAMPP instead of WAMP: http://www.apachefriends.org/en/xampp-windows.html

Link to comment
Share on other sites

I hate to say it, but I'm really not sure. When I test it on my machine, everything works as it should. As far as I can tell, there is nothing wrong with the code. It sounds like WAMP is running properly, and it seems like you are putting your files in the right place...

 

One other option would be to try XAMPP instead of WAMP: http://www.apachefriends.org/en/xampp-windows.html

 

When you open up your wampserver home page do you have files in the "Your Project" area? I do not.

 

I created a new site called php demo. I installed the code and tried to open up the localhost. I get a window that pops up saying: "you need to select a version of PHP in the application option dialog. I click on it and I have no idea what to choose. I am about ready to call it quits. things shouldn't be this hard for me to understand.

Link to comment
Share on other sites

When you open up your wampserver home page do you have files in the "Your Project" area? I do not.

No, by default it shouldn't install any files. You would need to create your files wherever you installed WAMP to. In my case, C/wamp/www.

 

I created a new site called php demo. I installed the code and tried to open up the localhost. I get a window that pops up saying: "you need to select a version of PHP in the application option dialog. I click on it and I have no idea what to choose.

Just select the most recent version with the highest version number. Mine is 5.3.0, though I installed it a little while ago so the most recent version may have a higher version number. (I'm not sure why you are getting this dialog though -- I don't believe I have ever been asked that.)

Link to comment
Share on other sites

No, by default it shouldn't install any files. You would need to create your files wherever you installed WAMP to. In my case, C/wamp/www.

 

 

Just select the most recent version with the highest version number. Mine is 5.3.0, though I installed it a little while ago so the most recent version may have a higher version number. (I'm not sure why you are getting this dialog though -- I don't believe I have ever been asked that.)

 

I always have the websites and files in my "My Websites" folders whether they're html of php.

 

The problem with selecting a version of PHP... it doesn't give me any options at all. Also, when I click ok without choosing anything it connects me to Microsoft Expression Development Server, localhost 5595. Then when I click on the phpmyadmin I get an error message and I am locked out. It isn't even the same phpmyadmin where i have all my databases at.

Link to comment
Share on other sites

I always have the websites and files in my "My Websites" folders whether they're html of php.

That could be a potential issue if you are trying to use WAMP. If you use WAMP, it expects your files to be in the specific www folder that WAMP creates.

 

My impression is that maybe you are having a conflict between WAMP and the server that comes installed with Expression Web? I'm not sure how much I can help you with this, unfortunately, since I haven't ever used Expression Web and am pretty happy with my current web dev software. You may want to look here: http://expression.microsoft.com/en-us/ee662148.aspx or do some Google searches regarding how to use the default server that comes with EW.

Link to comment
Share on other sites

A little bit more research seemed to indicate that the server that comes installed with Expression web is very basic, and doesn't include MySQL. It is still possible that the two are conflicting somehow though. Have you tried uninstalling WAMP, redownloading a new copy from the website and redoing the install process just in case?

 

... it's for this exact reason that I prefer to work with a simple text editor rather than a full dev environment for most things. Fewer headaches.

Link to comment
Share on other sites

That could be a potential issue if you are trying to use WAMP. If you use WAMP, it expects your files to be in the specific www folder that WAMP creates.

 

My impression is that maybe you are having a conflict between WAMP and the server that comes installed with Expression Web? I'm not sure how much I can help you with this, unfortunately, since I haven't ever used Expression Web and am pretty happy with my current web dev software. You may want to look here: http://expression.microsoft.com/en-us/ee662148.aspx or do some Google searches regarding how to use the default server that comes with EW.

 

I googled and also searched EW and was able to locate in EW site settings that i needed to change the php view path to: C:\wamp\bin\php\php5.3.0\php-cgi.exe. They do not tell you this. You're on your own.

 

After reconfiguring settings in EW I saved my file, clicked to view page in localhost and got this message:

Connection successful

 

Welcome to MySQL database testing page.

 

I had to use the password after "localhost','root','password' for it to work. I changed 'root' to 'roota' as he did in the video and got the correct error message.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
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.

Loading...
×
×
  • Create New...