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
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 @ shivarules@gmail.com

 

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

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.