SA-MP Forums Archive
Getting my UCP to connect to the Mysql - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Server (https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: Getting my UCP to connect to the Mysql (/showthread.php?tid=482001)



Getting my UCP to connect to the Mysql - stueycow - 18.12.2013

PHP код:
<?php
$con 
mysql_connect("localhost","username","password");
if(!
$con) die("Error connecting to database!");
$con mysql_select_db("database");
if(!
$con) die("Error selecting database!");
$string "SELECT * FROM `News` ORDER BY `ID` DESC";
$result mysql_query($string); 
if(!
$result)
{
    echo 
"Error reading news from MYSQL!";
    exit;
}
echo 
'<center><table width="80%"><tr><td>';
while(
$news mysql_fetch_array($result,MYSQL_ASSOC))

   echo 
'<center><br><br><br><span style="color:white"><strong><font size="5">'.$news['Title'].'</font></strong><br><br>'.$news['Text'].'</span></center><span style="color:white"><br><p align="right"><i>by '.$news['Admin'].' at '.$news['Time'].'</i></p></span><br>'

    echo 
"</td></tr></table></center>";
That is my code for my UCP as you can see it only has $con = mysql_connect("localhost","username","password") so it wont connect to the database, How can i add it so that it goes to the database i want it to?


Re: Getting my UCP to connect to the Mysql - Mauzen - 18.12.2013

Hm, maybe by inserting YOUR mysql username and password into mysql_connect, and your database into mysql_select_db?
Noone can tell you your password. How did you think someone could help you with that?
If you dont know these, ask your hoster.


Re: Getting my UCP to connect to the Mysql - stueycow - 18.12.2013

I know my username, host and password. My question is how do I make it select the right database as I have several on one account and there is not a place for me to type the database name in , so how do I make a php code to insert the database name so it can get the info FROM THE data base I want it to read from


Re: Getting my UCP to connect to the Mysql - InfiniTy. - 18.12.2013

Quote:
Originally Posted by stueycow
Посмотреть сообщение
I know my username, host and password. My question is how do I make it select the right database as I have several on one account and there is not a place for me to type the database name in , so how do I make a php code to insert the database name so it can get the info FROM THE data base I want it to read from
In case you missed it..

PHP код:
$con mysql_select_db("database"); 



Re: Getting my UCP to connect to the Mysql - stueycow - 19.12.2013

Did I realy not see that :/