connection to database doesn't work while using normal mysql codes !
-
hello there ,
I have something that I just notice ..
I know that wordpress uses the codes located in ‘wp-config.php‘ file , to connect to a specific database ,,
the codes for specifying the host , database , user and password :
define(‘DB_NAME’, ‘db’);
define(‘DB_USER’, ‘user’);
define(‘DB_PASSWORD’, ‘pass’);
define(‘DB_HOST’, ‘localhost’);But I just notice something ,that when I use some mysql codes in a wordpress site it doesn’t work because there is no connection to any server or any database .
for example in single.php , Im using this code :$myrows = mysql_query("SELECT * FROM wp_slides_plugin WHERE slide_name='Main' ORDER BY position ASC"); // order by while($row= mysql_fetch_array($myrows)){ $url[]=$row['url']; $title[]=$row['title']; $link[]=$row['link']; }It doesnt work unless I connect the site with the database I use , so I have to add the line :
mysql_query("use db", mysql_connect('localhost','user','pass') );so ,I have to connect to the database twice , its not enough to use the wordpress codes for connection !!
do I have to add mysql connection line every time I want to use mysql ?
or there is some way to fix this problem ?Note: This problem starts when I start using ‘MySQL “Improved” extension‘ in order to use MySQLi on easyapache . everything was working normally with wordpress sites before enable ‘MySQL “Improved” extension‘ .
and as you can see , after enable that choice , all my wordpress sites stop reading the connection codes of wordpress while using mysql codes .Please help me if you can ..
The topic ‘connection to database doesn't work while using normal mysql codes !’ is closed to new replies.