Current location: Hot Scripts Forums » Programming Languages » PHP » [SOLVED] PHP connecting to a MySQL


PHP connecting to a MySQL

Closed Thread
  #1 (permalink)  
Old 03-09-10, 01:51 PM
Abrica Abrica is offline
Newbie Coder
 
Join Date: Feb 2010
Posts: 40
Thanks: 4
Thanked 0 Times in 0 Posts
PHP connecting to a MySQL

Hi !
I have downloaded a PHP login system that connects to a MySQL database of users on my site. I followed the installation instructions, but now it doesn't work and returns an error message at the top of the page. This is the admin login
It has two errors at the top relating to line 15 of 'dbc.php'
here is lines 14-16 of 'dbc.php':
Code:
$dbname = 'abricatr_accounts';
$link = mysql_connect("localhost","abricatr_web","mypassword") or die("Couldn't make connection.");
$db = mysql_select_db($dbname, $link) or die("Couldn't select database");
I know that localhost is correct, I made a user for the MySQL databse called 'web' and I have replaced my actual password with 'mypassword'. I can't figure out what's gone wrong. Any help would be greatly appreciated!

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
  #2 (permalink)  
Old 03-09-10, 03:54 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
It can't find this file:

Warning: include(/onlineuser/dbc.php)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
  #3 (permalink)  
Old 03-10-10, 11:54 AM
Abrica Abrica is offline
Newbie Coder
 
Join Date: Feb 2010
Posts: 40
Thanks: 4
Thanked 0 Times in 0 Posts
DBC.php

The file exists on http://abricatrading.com/onlineuser/dbc.php
You can't get the code of that, the full code of /onlineuser/dbc.php is:
Code:
<?php
/******************** MAIN SETTINGS - PHP LOGIN SCRIPT V2.1 **********************
Please complete wherever marked xxxxxxxxx
**********************************************************************************/

/************* MYSQL DATABASE SETTINGS *****************
1. Specify Database name in $dbname
2. MySQL host (localhost or remotehost)
3. MySQL user name with ALL previleges assigned.
4. MySQL password

Note: If you use cpanel, the name will be like account_database
*************************************************************/
$dbname = 'abricatr_accounts';
$link = mysql_connect("localhost","abricatr_web","mypassword") or die("Couldn't make connection.");
$db = mysql_select_db($dbname, $link) or die("Couldn't select database");

/*****************ADMIN SECTION PASSWORD***************************/
/****** SET A STRONG PASSWORD WITH ATLEAST 6-8 CHARS***************/
$admin_user = 'user';
$admin_pass = 'userpassword';

/**** PAGE PROTECT CODE  ********************************
This code protects pages to only logged in users. If users have not logged in then it will redirect to login page.
If you want to add a new page and want to login protect, COPY this from this to END marker.
Remember this code must be placed on very top of any html or php page.
********************************************************/
function page_protect() {
session_start();

//check for cookies

if(isset($_COOKIE['user_id']) && isset($_COOKIE['user_name'])){
      $_SESSION['user_id'] = $_COOKIE['user_id'];
      $_SESSION['user_name'] = $_COOKIE['user_name'];
   }


if (!isset($_SESSION['user_id']))
{
header("Location: login.php");
}
/*******************END********************************/
}


function filter($data) {
	$data = trim(htmlentities(strip_tags($data)));
	
	if (get_magic_quotes_gpc())
		$data = stripslashes($data);
	
	$data = mysql_real_escape_string($data);
	
	return $data;
}



function EncodeURL($url)
{
$new = strtolower(ereg_replace(' ','_',$url));
return($new);
}

function DecodeURL($url)
{
$new = ucwords(ereg_replace('_',' ',$url));
return($new);
}

function ChopStr($str, $len) 
{
    if (strlen($str) < $len)
        return $str;

    $str = substr($str,0,$len);
    if ($spc_pos = strrpos($str," "))
            $str = substr($str,0,$spc_pos);

    return $str . "...";
}	

function isEmail($email){
  return preg_match('/^\S+@[\w\d.-]{2,}\.[\w]{2,6}$/iU', $email) ? TRUE : FALSE;
}

function isUserID($username)
{
	if (preg_match('/^[a-z\d_]{5,20}$/i', $username)) {
		return true;
	} else {
		return false;
	}
 }	
 
function isURL($url) 
{
	if (preg_match('/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i', $url)) {
		return true;
	} else {
		return false;
	}
} 

function checkPwd($x,$y) 
{
if(empty($x) || empty($y) ) { return false; }
if (strlen($x) < 4 || strlen($y) < 4) { return false; }

if (strcmp($x,$y) != 0) {
 return false;
 } 
return true;
}

?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
  #4 (permalink)  
Old 03-10-10, 02:32 PM
Abrica Abrica is offline
Newbie Coder
 
Join Date: Feb 2010
Posts: 40
Thanks: 4
Thanked 0 Times in 0 Posts
Solved

Deleted everything and started again from scratch and seems to work now, thanks anyway!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Closed Thread

Bookmarks

Tags
php mysql phpmyadmin


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

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP or PHP which is better? nepala The Lounge 9 07-14-10 06:48 AM
WEB HOSTING - $4.99/MONTH For 1GB HD & 25GB BW! CPanel, PHP, MySQL & MORE! IncognitoNet General Advertisements 0 11-24-05 07:18 AM
RESELLER WEB HOSTING - $9.99/MONTH For 4GB HD & 30GB BW! CPanel, PHP, MySQL & MORE! IncognitoNet General Advertisements 0 07-14-05 11:56 AM
PHP multi-dimensional array sorting issue aqw PHP 2 06-25-05 12:09 AM
Complex mysql sorting pb (Get cat_list from cids &pcids with 1 query, willing to pay) aqw PHP 1 06-23-05 08:02 PM


All times are GMT -5. The time now is 12:35 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.