mysql database error
Posted by: manasdas (---.254.63.217.dynamic.ttnet.com.tr)
Date: October 31, 2014 09:17PM

I am using this code to connect mysql;

$connect=mysql_connect("localhost:3306","root",""winking smiley or die("ERROR CODE 1"winking smiley;

but when i tried it, an error said me to make it

$connect=mysqli_connect("localhost:3306","root",""winking smiley or die("ERROR CODE 1"winking smiley;

anyway it worked. But now, i can not connect to database

i'm using this code

mysql_select_db("members",$connect) or die ("ERROR CODE 2"winking smiley;

but it says

Warning: mysql_select_db() expects parameter 2 to be resource, object given in D:\Programs\wamp\www\db.db.db.php on line 3

so, what should i do?

Options: ReplyQuote
Re: mysql database error
Posted by: RiggsFolly (---.dynamic.dsl.as9105.com)
Date: October 31, 2014 09:48PM

A connection should look like this

$link = mysql_connect('localhost', 'root', '');
if (!$link) {
    die('Not connected : ' . mysql_error());
}

// make members the current db
$db_selected = mysql_select_db('members', $link);
if (!$db_selected) {
    die ('Can\'t use foo : ' . mysql_error());
}

Copied almost word for word from the PHP MANUAL


If all else fails, the manual is as good a place as any to look for help

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-



Edited 1 time(s). Last edit at 10/31/2014 10:09PM by RiggsFolly.

Options: ReplyQuote


Sorry, only registered users may post in this forum.