Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > connecting to mysql db through php

connecting to mysql db through php
Thread Tools
Fresh-Faced Recruit
Join Date: Nov 2004
Location: perth australia
Status: Offline
Reply With Quote
Feb 27, 2005, 09:15 AM
 
hi
im having probs connecting to my db using php running as localhost using dreamweaver, i think its something to do with the server path to mysql which is set up when defining your site, dreamweaver assumes its in the same folder as your site but it isnt and i dont know what path to put , i know its in /usr/local/mysql/bin but that path isnt accepted by dreamweaver and i dont think i have access to it as a user only as root, also the php code connect if i write it myself , i had it all running on my old win pc no prob i think coz apache php and mysql are all located in the same folder heres a snippet of code
<?php
$host="localhost";
$username="root";
$pass="jlkj99";
$database="hayesdec";
$tablename="login";
$connection=mysql_connect($host,$username,$pass);
if(!$connection){
echo"no con";
}
$result=mysql_select_db($database)
if($result){
echo"yippee";
}
$query="SELECT * from" .$tablename";
$result= mysql_query($query);
if(!$result){
echo"no result";
}

while ($row=mysql_fetch_array($result))
{
echo row["username"];
echo row["password"];
}

?>
     
CKr
Junior Member
Join Date: Jan 2004
Status: Offline
Reply With Quote
Feb 28, 2005, 10:37 PM
 
I'm not sure of your specific problem but I hope your not trying to connect to your SQL server with the root user.

First of all is MySQL set up properly on your server? I would make sure of this before trying to debug a bunk connection from a PHP script.

Also Dreamweaver doesn't care where MySQL is. If it is (MySQL) set up properly mysql_connect() would be able to connect to the server locally.

Sorry I can't be of much help but I don't know the specifics of your setup to be able to give you much more advice. I'm sure someone else here will have some more insight for you.
     
   
Thread Tools
Forum Links
Forum 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 On
Top
Privacy Policy
All times are GMT -5. The time now is 09:12 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2