MySQL online connection

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Guest
Hello all, Greetings from Scotland.

Please forgive my ignorance, I am very new to PHP, but realise the advantages. I have been given some web space, and I discovered that it was using PHP, MySQL, so I am having to learn it.

I am currently creating a site with PHP, MySQL and Apache. I have a test area online, and I can get the PHP script to work, including the database navigation, but I cannot get the database data to show on the PHP pages. I know it is something I am doing wrong in the connections file. I have spent so much time on it that it is beginning to drive me nuts.

If anyone lives in the Central Belt o Scotland, I would very much appreciate any help. I have the site on a laptop, and can travel if necessary.

Thanks,

James
 
I cant provide that much help because you really didnt explain the problem. Basically, once you get the connection, you select your database, run a query against it, and use mysql_fetch_array or similar function to obtain the results. Here is a good place to start with the basics:
http://hotwired.lycos.com/webmonkey/programming/php/tutorials/tutorial4.html and of course, the PHP site: http://www.php.net/manual/en/ref.mysql.php. Best of luck with those. If you have any other problems, try showing some example code or being more specific, and I would be more than willing to attempt to help.

Will
 
Dear James,
How said my friend Wizard, RTFM!

It is very nice that you want to learn PHP and MySQL. I hope my links will help you...

http://www.php.net here you can find online documentaion, but you can download all documentation in one file (Soory but I forgot a link to the file)
http://www.mysql.org documentation...
http://www.apache.org - APache web server...

If you are allredy called on this sites and dowloaded documentation. please rad its.



For reaply on your question...
It is just simple code? for your learning...

Code:
<?
$user="pejone";
$host=""flashsoft.com.ua;
$pass="asdgWERaf@#$AFSD";

#dbname="flashsoft";

$link=mysql_connect($host, $user, $pass);

mysql_select_db($dbname, $link);

$query=mysql_query("SELECT * FROM `table`", $link);
 
for ($i=0; $i<mysql_num_rows($query); $i++)
{
$data=mysql_fetch_array($query);
$echo($data['somes']);
}
?>

regards...
 
Pejone: Not meaning to be picky, I thought perhaps this would be a more suitable alternative to your loop as it's neater and more efficient

Code:
$query = mysql_query("SELECT * FROM `table`", $link);
while ($data = mysql_fetch_array($query)) print $data['somes'];

It's essentially the same code, just smaller and neater. :D
 
Back
Top