Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
Old 04-17-2005, 02:16 PM database trouble
pushedtomb's Avatar
Super Talker

Posts: 100
Name: Nathen
Location: Casnewydd, De Cymru, UK
Trades: 0
Can anyone c something wrong with this coding? As im getting Resource id#6 when i load it on my site, http://www.pushedtomb.co.uk/news.php , ne ideas?


PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>..::Pushedtomb.co.uk::..</title>
<link href="css/css.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
<style type="text/css">
<!--
.style4 {color: #D0E0F0}
-->
</style>
</head>
<body>
<div align="center">
<table width="100%" border="1" bordercolor="#FFFFFF">
  <tr>
    <th align="center" valign="top" class="border" scope="col"><marquee>
      <img src="images/3dtext_2555.gif" width="512" height="47">
      </marquee></th>
  </tr>
</table>
<div align="left">
<table width="15%" height="75%" border="1" bordercolor="#FFFFFF">
</table>
<?php //navigation
include('nav.php');
?>
<td width="83%" align="center" valign="top" class="bgblend" scope="col" aname="site"><p>
    <?php include('Connections/news.php');
 @
mysql_select_db('links') or die('Unable to find database');
 
$sql mysql_query('SELECT * '
        
' FROM `news` '
        
' WHERE 1 '
        
' ORDER BY `id` ASC LIMIT 0, 30');
  echo 
$sql;?>
  </p></td>
</tr>
</table>
</body>
</html>
<p>
  <?php //footer
include('footer.php');
?>
__________________

Please login or register to view this content. Registration is FREE


Quote:
- "I've often wondered how MS can say that other software "isn't compatible" with MS when MS stuff isn't even compatible with other MS stuff" - quote from Daily Thing.com
pushedtomb is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-17-2005, 03:08 PM
leavethisplace's Avatar
Ultra Talker

Posts: 297
Trades: 0
Quote:
sql = mysql_query('SELECT * '
. ' FROM `news` '
. ' WHERE 1 '
. ' ORDER BY `id` ASC LIMIT 0, 30');
echo $sql;?>
Pretty sure it's this bit, try doing the query a bit like this, it's taken from my actual news publishing program

PHP Code:
$query "SELECT id, date, topic, content, archive, createdby
          FROM News WHERE id = '
$ID'";
    
$result mysql_query($query)
        or die(
"Query failed: " mysql_error());

    while ( 
$row mysql_fetch_array($result) ) {
        
                                   
argument or presented variables
        
    

You can't echo a sql query because it return it in an array, so use the while loop to go through each result (or "row") and extract the information from each cell using $row['cell_name'];

Hope that makes sense and helps
__________________
A lie gets halfway around the world before the truth has a chance to get its pants on. - Sir Winston Churchill

Please visit my sites:
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
leavethisplace is offline
Reply With Quote
View Public Profile
 
Old 04-17-2005, 03:35 PM
pushedtomb's Avatar
Super Talker

Posts: 100
Name: Nathen
Location: Casnewydd, De Cymru, UK
Trades: 0
im still getting an error.
PHP Code:
<?php include('Connections/news.php');
    @
mysql_select_db('links') or die('Unable to find database');
 
$query "SELECT id, name, url, FROM News WHERE id = '$ID'"
    
$result mysql_query($query
        or die(
"Query failed: " mysql_error()); 

    while ( 
$row mysql_fetch_array($result) )?>
check that page agen
__________________

Please login or register to view this content. Registration is FREE


Quote:
- "I've often wondered how MS can say that other software "isn't compatible" with MS when MS stuff isn't even compatible with other MS stuff" - quote from Daily Thing.com
pushedtomb is offline
Reply With Quote
View Public Profile
 
Old 04-17-2005, 03:39 PM
leavethisplace's Avatar
Ultra Talker

Posts: 297
Trades: 0
$query = "SELECT id, name, url, FROM news WHERE id = '$ID'";

Hang on you've changed your code now, do you want to display all news or a specific item of news? if all news, if because you had FROM News, SQL is CaSe SenSiTive! So make sure your news table actually has a capital N or not.

If you want to get all the news, use this:

$query = "SELECT id, name, url, FROM News WHERE 1 ORDER BY id";
__________________
A lie gets halfway around the world before the truth has a chance to get its pants on. - Sir Winston Churchill

Please visit my sites:
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
leavethisplace is offline
Reply With Quote
View Public Profile
 
Old 04-17-2005, 03:51 PM
pushedtomb's Avatar
Super Talker

Posts: 100
Name: Nathen
Location: Casnewydd, De Cymru, UK
Trades: 0
ok.. start agen.. Table name i want to access is news. with colums id name url. name contains Music, Rugby, Football, Lotto, then under url music.php, rugby.php, football.php, lotto.php. and i want to display them as links on news.php
__________________

Please login or register to view this content. Registration is FREE


Quote:
- "I've often wondered how MS can say that other software "isn't compatible" with MS when MS stuff isn't even compatible with other MS stuff" - quote from Daily Thing.com
pushedtomb is offline
Reply With Quote
View Public Profile
 
Old 04-17-2005, 03:54 PM
leavethisplace's Avatar
Ultra Talker

Posts: 297
Trades: 0
ok cool, well i sent u a PM, but check this out:

$query = "SELECT id, name, url, FROM News WHERE id = '$ID'"; is wrong, take out the comma before FROM and after url. Thats a SQL error you're getting.

The while loop will allow you to construct a generic template to place all the information you need, using $row['name']; and $row['url']

That any more help?
__________________
A lie gets halfway around the world before the truth has a chance to get its pants on. - Sir Winston Churchill

Please visit my sites:
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
leavethisplace is offline
Reply With Quote
View Public Profile
 
Old 04-17-2005, 03:55 PM
pushedtomb's Avatar
Super Talker

Posts: 100
Name: Nathen
Location: Casnewydd, De Cymru, UK
Trades: 0
yup cheers.. will pm u if i have more trouble
__________________

Please login or register to view this content. Registration is FREE


Quote:
- "I've often wondered how MS can say that other software "isn't compatible" with MS when MS stuff isn't even compatible with other MS stuff" - quote from Daily Thing.com
pushedtomb is offline
Reply With Quote
View Public Profile
 
Old 04-17-2005, 03:56 PM
leavethisplace's Avatar
Ultra Talker

Posts: 297
Trades: 0
Cool beans, my sigs gone all funny.
__________________
A lie gets halfway around the world before the truth has a chance to get its pants on. - Sir Winston Churchill

Please visit my sites:
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
leavethisplace is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to database trouble
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.63507 seconds with 12 queries