Web Hosting Vodahost    

Home Take The Royal Tour! Order Now Features Prices
Go Back   Web Hosting > VodaHost Web Hosting Support > mySQL & PHP

Notices

mySQL & PHP Discussions, information and help with mySQL and PHP.

Closed Thread
 
Thread Tools
  #1  
Old 06-27-2008, 08:18 AM
Sergeant
 
Join Date: Jun 2008
Posts: 25
Default MYSQL Connections

I am unable to connect to my database. I have put the following code in a html box in my form page but it is not working. I am getting the error message HTTP 404. The code that I am using to connect to my database is as follows;

<?php
$db_host= "localhost";
$db_username = "YYYY_XXXXX";//where YYYY is my CP username and XXXXX is my database username
$db_password = "ZZZZZ"
$dbname ="YYYY_StudyKitchenData";
$conn = mysql_connect($db_host,$db_username,$db_password);
mysql_select_db($dbname);
close($conn);
?>


Please help!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #2  
Old 06-27-2008, 09:27 AM
navaldesign's Avatar
General & Forum Moderator
 
Join Date: Oct 2005
Location: Italy
Posts: 10,047
Default Re: MYSQL Connection Problem - Please help

404 error message has nothing to do with the database connection. Probably you have mistyped the page URL or you are trying to see a html page whilst it is php or viceversa.

A link would be usefull to see what your problem is.
__________________
Navaldesign
Logger Lite: Low Cost, Customizable, multifeatured Login script
Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #3  
Old 06-28-2008, 06:52 AM
Sergeant
 
Join Date: Jun 2008
Posts: 25
Default Re: MYSQL Connection Problem - Please help

Navaldesign, thanks for taking the time to look into my problem. Earlier when I was saving the page as *.bvp or *.php, I was getting the HTTP 404 error message. After reading your post, I saved the page as *.html and I did not get the error message but still the echo statements are not printing on the screen so I am not sure if the script is getting executed or not.

I embedded the script by going into View -->Page HTML ---> Inside body tag.

The link is http://www.studykitchen.com/test4.html

Also just for my knowledge, shouldn't I be saving the page as .bvp or .php instead of .html if I have embedded php code in the page?

Regards
Skipper
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #4  
Old 06-28-2008, 07:01 AM
navaldesign's Avatar
General & Forum Moderator
 
Join Date: Oct 2005
Location: Italy
Posts: 10,047
Default Re: MYSQL Connection Problem - Please help

The page is always saved simply as "pagename" WITHOUT any extension. The extension is generated by BV when it publishes the page. If the page contains php code, you need to publish it as php page. This is done setting, in Page Properties, the page extension ( when published) to be php instead of the standard html.

Now, your test4 page is html, so it can never execute the php code embedded in the page.

A further issue: your code (which i can see because the page is html, and not php):

<?php
echo("Success 1");
$db_host= "localhost";
$db_username = "tuwipwa_?????????";
$db_password = "Krishna 1965"
$dbname ="tuwipwa_Study???????????";
echo("Success 2");
$conn = mysql_connect($db_host,$db_username,$db_password);
mysql_select_db($dbname);
echo("Success 3");
close($conn);
echo("Success 4");
?>

will do nothing (when executed). I mean, it opens a DB connection and then it closes it, without doing anything at all.
The only output will be those echoes "Success 1" ..... to "Success 4" but nothing more.

Usually, after you open the connection, you query a specific table in the database, to retrieve some info (or add, or edit) and display it in your page. In this case you do nothing of the above.
__________________
Navaldesign
Logger Lite: Low Cost, Customizable, multifeatured Login script
Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #5  
Old 06-28-2008, 07:18 AM
Sergeant
 
Join Date: Jun 2008
Posts: 25
Default Re: MYSQL Connection Problem - Please help

Navaldesign thanks once again and sorry to bug you yet once more. I saved the page by changing the setting in page properties, as suggested by you, so it executed but this time it gave a syntax error:

Parse error: syntax error, unexpected T_VARIABLE in /home/tuwipwa/public_html/test5.php on line 13

I used the same code as I had used earlier and removed a blank line so if you refer to my earlier code the error will be in line 14.

The echo statements didn't print, probably because of the syntax error.

Well I understand, I have not written any queries so the page won't do anything else besides printing the echo statements but before going further I wanted to check the connection because normally this is the biggest issue I generally have but in BlueVoda it appears much simpler than in many other web hosting packages.

Please let me know what is causing the syntax error.

Thanks
Skipper
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #6  
Old 06-28-2008, 07:31 AM
navaldesign's Avatar
General & Forum Moderator
 
Join Date: Oct 2005
Location: Italy
Posts: 10,047
Default Re: MYSQL Connection Problem - Please help

in test5.php i only see a message about access denied to the user. It is not enough creating user and pas, you ned to ADD this user to the specific database (in CP, MySQL section). Did you ?
__________________
Navaldesign
Logger Lite: Low Cost, Customizable, multifeatured Login script
Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #7  
Old 06-28-2008, 07:40 AM
navaldesign's Avatar
General & Forum Moderator
 
Join Date: Oct 2005
Location: Italy
Posts: 10,047
Default Re: MYSQL Connection Problem - Please help

And, you do have a mistake in your code in the second part. Replace your code with this:

<?php
echo("Success 1");
$db_host= "localhost";
$db_username = "tuwipwa_?????????";
$db_password = "Krishna 1965";
$dbname ="tuwipwa_Study???????????";
$db = mysql_connect($db_host, $db_user, $db_password);
if ($db == FALSE){
$error = "Could not connect to the Database Server. Please check user details. Error = ". mysql_error();
exit($error);
}
echo "Completed DB connection";
mysql_select_db($db_name, $db);
if (!mysql_select_db($db_name, $db)) {
$error = "Could not select Database. Please check user details. Error = ". mysql_error();
exit($error);
}
echo "Completed DB selection";
// Your query here
mysql_close($db);
?>

The problem you were getting was the missing ";" in the $db_username = .......... line
__________________
Navaldesign
Logger Lite: Low Cost, Customizable, multifeatured Login script
Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #8  
Old 06-28-2008, 07:44 AM
Sergeant
 
Join Date: Jun 2008
Posts: 25
Default Re: MYSQL Connection Problem - Please help

Yes, I did. Now the page is not showing any access denial message but still it is not printing the echo statements which it should. What am I doing wrong? I am already feeling pretty stupid
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #9  
Old 06-28-2008, 07:54 AM
navaldesign's Avatar
General & Forum Moderator
 
Join Date: Oct 2005
Location: Italy
Posts: 10,047
Default Re: MYSQL Connection Problem - Please help

Your messages (success 1 etc) displays ok. BUt it is in WHITE color. So you can't see it.
Look at the page code to see it.
__________________
Navaldesign
Logger Lite: Low Cost, Customizable, multifeatured Login script
Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #10  
Old 06-28-2008, 08:02 AM
Sergeant
 
Join Date: Jun 2008
Posts: 25
Default Re: MYSQL Connection Problem - Please help

Navaldesign, a big THANK YOU to you!! We are getting closer. I used your code snippet and got the following error message:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'tuwipwa'@'localhost' (using password: YES) in /home/tuwipwa/public_html/test8.php on line 14
Could not connect to the Database Server. Please check user details. Error = Access denied for user 'tuwipwa'@'localhost' (using password: YES)

As you suggested, I checked andI do have the user added to the database. So what else could possibly prevent denial of access ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #11  
Old 06-28-2008, 08:34 AM
navaldesign's Avatar
General & Forum Moderator
 
Join Date: Oct 2005
Location: Italy
Posts: 10,047
Default Re: MYSQL Connection Problem - Please help

Sorry, my mistake. In my code it is $db_user, in yours it is $db_username. Also you had $dbname, i had $db_name . Edit the connection details lines:

$db_host= "localhost";
$db_user = "tuwipwa_?????????";
$db_password = "Krishna 1965";
$db_name ="tuwipwa_Study???????????";
__________________
Navaldesign
Logger Lite: Low Cost, Customizable, multifeatured Login script
Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #12  
Old 06-28-2008, 07:13 PM
Sergeant
 
Join Date: Jun 2008
Posts: 25
Default Re: MYSQL Connection Problem - Please help

Thank you, General. I salute to your expertise and for guiding me through this problem. I think its working now. Thanks again!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #13  
Old 06-29-2008, 06:49 AM
Sergeant
 
Join Date: Jun 2008
Posts: 25
Default Re: MYSQL Connection Problem - Please help

Navaldesign, the last code you gave is executing fine but the echo statements are still not visible in the browser. What setting do I need to change to make the echo statements visible in the browser?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #14  
Old 06-29-2008, 07:52 AM
navaldesign's Avatar
General & Forum Moderator
 
Join Date: Oct 2005
Location: Italy
Posts: 10,047
Default Re: MYSQL Connection Problem - Please help

Remove the code from the body of the page. Place it either in a html box (this way you can control also the position where the echo statements will appear) or in the Start of page (the text will appear on the very top).
__________________
Navaldesign
Logger Lite: Low Cost, Customizable, multifeatured Login script
Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT +1. The time now is 01:55 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC7
2005-2009 VodaHost Web Hosting Your Perfect Web Host - All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203