Recent Topics

1 Nov 02, 2005 09:33    

Hi I'm new at this stuff but I know one thing, that's something is wrong.. but I don't know how to fix it.

EDIT:
Some more info so you don't think I'm stupid.. :)
This is in my "_config.php" and it seems to work obviously, everything else works fine.

define( 'DB_USER', 'MyUserNameToMySQL ); // your MySQL username
define( 'DB_PASSWORD', '******' ); // ...and password
define( 'DB_NAME', 'TheDBName' ); // the name of the database
define( 'DB_HOST', '2**.97.*32.*1' ); // mySQL Server (typically 'localhost')

(phony usename, password and so on, but the right one in "_config.php")
my MySQL server isn't local
/EDIT

I have made a connection to mySql db and I'm connected, but when I send a query to db I'm getting this error:
---
MySQL error!

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)(Errno=2002)

Your query: Check URL against antispam balcklist

SELECT aspm_string
FROM evo_antispam
WHERE '' LIKE CONCAT('%',aspm_string,'%')
LIMIT 0, 1

---

The php code that I've been able to put together may not be right, because like I said before this i my first time ever contact with php and mySQL, but here it is:
---
<?php
if( !defined('DB_USER') ) die( 'Please, do not access this page directly.' );

$link = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';

mysql_select_db(DB_NAME,$link);
//do a query from db:
$sql = "SELECT evo_matches.opponents AS 'Motstånd', evo_matches.theDate AS 'Datum', CONCAT( evo_matches.ourScore, ' / ', evo_matches.oppScore ) AS 'Rundor', evo_maps.mapNamn AS 'Map'
FROM evo_matches
INNER JOIN evo_maps ON evo_matches.map = evo_maps.mapID
ORDER BY evo_matches.theDate DESC
LIMIT 0 , 50";
$result = mysql_query($sql);

echo $result;

mysql_close($link);
?>
---

This query works fine in the db query window:
---
SELECT evo_matches.opponents AS 'Motstånd', evo_matches.theDate AS 'Datum', CONCAT( evo_matches.ourScore, ' / ', evo_matches.oppScore ) AS 'Rundor', evo_maps.mapNamn AS 'Map'
FROM evo_matches
INNER JOIN evo_maps ON evo_matches.map = evo_maps.mapID
ORDER BY evo_matches.theDate DESC
LIMIT 0 , 50
---

So I would be grateful for any ideas or any suggestions..

btw, yes I've put some stuff in my db tables.. :)
this is what I get from that query:
---
Motstånd Datum Rundor Map
Klan Tattarna 2005-10-31 24 / 0 de_nuke
---

EDIT:
got an second error:
---
MySQL error!

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)(Errno=2002)

Your query:

INSERT INTO evo_hitlog( visitTime, visitURL, hit_ignore, referingURL, baseDomain,
hit_blog_ID, hit_remote_addr, hit_user_agent )
VALUES( FROM_UNIXTIME(1130951881), '', 'invalid',
'', '', 1,
'', '')
---

It's weird because I haven't changed any code.. just reloaded the page

so please help me someone..
/EDIT

1. Are you sure you have typed the correct user/password? YES!
2. Are you sure that you have typed the correct hostname? yes
3. Are you sure that the database server is running? YES!

2 Nov 02, 2005 20:31

OMG

sorry for all brain waste..

mysql_close($link); <-- that one at the end was the devil..

I thougt it could be a security flaw to have an open connection to the DB so why don't close the link..

But it seems to close ALL connections to the DB, so now it works alot better :)

If I'm thinking in the wrong way now so please tell me..

otherwhise this thread could be erased..


Form is loading...