Jump to content

Confussed


ericburnard

Recommended Posts

Hey i havnt used php or any language for a good few years now, ive decided to get back into it again. Ive set up a sql database and tried to work out the php code to get the entries out of the table (code below) but im just getting these messages -

 

http://ericburnard.freehostia.com/db.php

 

<?php
$link = mysql_connect('mysql2.freehostia.com', '*******', '*********');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';

$link or die ("Problem connecting to DataBase"); 
$query = "SELECT * FROM `Blog`"; 
$result = mysql_select_db($query); 

if ($result) { 
echo "Found these entries in the database:<br><p></p>"; 

while ($r = mysql_fetch_array($result)) { 

$date = $r["date"]; 
$subject = $r["subject"]; 
$blog = $r["blog"]; 
$id = $r["id"]; 

echo "<tr> 
<td>$id</td> 
<td>$date</td> 
<td>$subject</td> 
<td>$blog</td> 
</tr>"; 
} 
echo "</table>"; 

} else { 
echo "No data."; 
} 

?> 


 

 

What am i doing wrong???

 

Cheers

xxxxx

Link to comment
https://forums.phpfreaks.com/topic/80768-confussed/
Share on other sites

Dude don worry I wil help u in this case......... ;)

 

First thing u have not selected database properly

second u have not used mysql function correctly

here it is

 

mysql_select_db('samples', $link); **********

$link or die ("Problem connecting to DataBase");

$query = "SELECT * FROM `Blog`";

$result = mysql_query($query); **********

 

only the ********** thing you have to change in your code thats it.

 

and open table na

echo"<table>"; **********

while ($r = mysql_fetch_array($result)) {

 

if u still face problem feel free to mail me @ [email protected]

 

by the way u r welcome na........

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/80768-confussed/#findComment-411740
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.