Web Hosting Forums

Results 1 to 4 of 4

This is a discussion on Cannot connect to DB vai php. Aletia support no help! in the Hosting Talk & Chit-chat forum
Below is the code I'm using (w/ pwd changed) to connect to my Database w/php. Code: <?php $linkID = mysql_connect("localhost", "artistic_all", "myPwdHere"); if ($linkID != ...

  1. #1
    Loyal Client
    Join Date
    Apr 2002
    Posts
    8

    Cannot connect to DB vai php. Aletia support no help!

    Below is the code I'm using (w/ pwd changed) to connect to my Database w/php.
    Code:
    <?php
    $linkID = mysql_connect("localhost", "artistic_all", "myPwdHere");
    if ($linkID != FALSE) {
    	mysql_select_db("artistic_photos", $linkID);
    	$resultID = mysql_query("SELECT * FROM pics", $linkID);
    	if($resultID) {
    		$row = mysql_fetch_assoc($resultID);
    		$pName= $row['photoName'];
    		$pID= $row['photoID'];
    		$pWords = $row['keywords'];
    	}
    
    
    	else {
    		print "No Results";
    	}
    }
    else {
    	print "Bad Connection";
    }
    mysql_close($linkID);
    ?>
    When this executes, I get the "No results" portion to print out. This would seem to indicate that it is not connected to the DB. Aletia support won't give me the proper connection string to use, so I'm trying here. Anybody got any idea what's wrong with the above code?

  2. #2
    Loyal Client
    Join Date
    Apr 2002
    Posts
    8
    Never mind, just read the other thread.

  3. #3
    young and idealistic clio's Avatar
    Join Date
    Oct 2002
    Location
    Tübingen, Germany
    Posts
    2,140
    just fyi, if you go into cpanel > mySQL they actually give you code, but it looks like you use php.

    and second of all, it's always USERNAME_DBNAME
    for the database name and database user is USERNAME_DBUSERNAME where USERNAME is your aletia account username.
    - Julie
    Student / Web Developer

  4. #4
    Ras
    Ras is offline
    Loyal Client
    Join Date
    Feb 2002
    Posts
    48

    Re: Cannot connect to DB vai php. Aletia support no help!

    Originally posted by bcarl314
    Code:
    <?php
    $linkID = mysql_connect("localhost", "artistic_all", "myPwdHere");
    if ($linkID != FALSE) {
    You can just do
    PHP Code:
    if(!$linkID){ 
    Instead there, just a side note.
    rastabeenz

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •