Getting my UCP to connect to the Mysql
#1

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?
Reply
#2

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.
Reply
#3

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
Reply
#4

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"); 
Reply
#5

Did I realy not see that :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)