Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

136 users online



News id="bla"

News id="bla"

Currently viewing this thread: 1 (0 members and 1 guests)


Page 2 out of 3
Zeratul

Zeratul

kage
Status: Offline!

All that I can think of right now is manual.

PHP:

<?php
$array 
= array('1''2', ...);
if (!(
inarray($id$array))) {
adsadasdas;
}
?>

Fitzo

Fitzo

PHP g00n
Status: Offline!

Here We Go

PHP:



<?php

if($_GET['id'] { 

$_GET['id'] = (int) $_GET['id'];

$id $_GET['id'];

}

$link mysql_connect("localhost","sdbz_game","hide"); 
         
mysql_select_db("sdbz_gamedb",$link);
 
    
$result mysql_query("SELECT * FROM news WHERE id={$id} limit 10") or die (mysql_error());

$num mysql_num_rows($result);

if(
$num != "1") { 

echo 
'Sorry this news item could not be found in our database';

}
else {

while(
$row mysql_fetch_array($result)) { 

// echo all table info

}
}
mysql_close($link);
?>

___________________

http://www.edenstar.net/images/siggy.gif

Last edited by Fitzo, July 20th, 2004 08:55 PM (Edited 1 times)

X-plozive

X-plozive

Status: Offline!

in the $result part do I need my other field names?

X-plozive

X-plozive

Status: Offline!
PHP:


<html>
<head>
<title>News</title>
<link rel="stylesheet" type="text/css" href="forum.css" />
</head>
<body>
</body>
</html>

<?php
$link 
mysql_connect("localhost","sdbz_game","hide"); 
    
mysql_select_db("sdbz_gamedb",$link); 
    
$result mysql_query("SELECT * FROM news WHERE id='$id' limit 10") or die (mysql_error());

$num mysql_num_rows($result);

if(
$num != "1") { 

echo 
'Sorry this news item could not be found in our database';

}
else {

while(
$row mysql_fetch_array($result)) { 

        
$news_topic $row['topic']; 
        
$news_name $row['name']; 
        
$news_post $row['post']; 
        
$news_mail $row['mail']

  echo 
"<b>$news_topic</b><br /><br />$news_post<br /><br />Posted by: <a href='mailto:$news_mail'>$news_name</a><br /><br />";

}
}
mysql_close($link);
?>

I get an unexpected T_ECHO on line 32...but why?

Zeratul

Zeratul

kage
Status: Offline!
Quote:

Originally posted by Fitzo
Here We Go

PHP:



<?php

if($_GET['id'] { 

$_GET['id'] = (int) $_GET['id'];

$id $_GET['id'];

}

$link mysql_connect("localhost","sdbz_game","hide"); 
         
mysql_select_db("sdbz_gamedb",$link);
 
    
$result mysql_query("SELECT * FROM news WHERE id={$id} limit 10") or die (mysql_error());

$num mysql_num_rows($result);

if(
$num != "1") { 

echo 
'Sorry this news item could not be found in our database';

}
else {

while(
$row mysql_fetch_array($result)) { 

// echo all table info

}
}
mysql_close($link);
?>

I would prefer mysql_pconnect() and no mysql_close()
And what's the first if then else statement? It doesn't make any sense at all, and the syntaxes are inputted incorrectly.

X-plozive

X-plozive

Status: Offline!

Can someone just help me *cries and dies*

sabrina

sabrina

what could you possibly want to know about me?
Status: Offline!

The error in the code you posted is a missing ; at the end of this line:

PHP:

<?php
$news_mail 
$row['mail']
?>

Stevie

Stevie

Neversidian
Status: Offline!

Basically, all you need is something like this.

PHP:


<?php
$link 
mysql_connect("localhost","root","rootpass") or die(mysql_error());
mysql_select_db("test");

    
$query "SELECT `id`,`title`,`date`,`archive_date` FROM `blog` ORDER BY `id` DESC LIMIT 25;";
    
$result mysql_query($query) or die(mysql_error());
    if(
$result)
    {
        if(
mysql_num_rows($result) == "0")
        {
            echo 
"There are currently no posts.";
        }
        else
        {
            while(
$_ROW mysql_fetch_assoc($result))
            {
                echo 
'<a href="http://'.$_SERVER['HTTP_HOST'].'/page.php?id='.$_ROW['id'].'/">'.$_ROW['title'].'</a> Posted '.$_ROW['archive_date'];
            }
        }
    }
?>

and then the "page.php" where it will be loaded.

PHP:

<?php
    
    $id 
$_GET['id'];
    
    
$link mysql_connect("localhost","root","rootpass") or die(mysql_error());
    
mysql_select_db("test");
    
    
$query "SELECT `id`,`title`,`date`,`month_year`,`entry` FROM `blog` WHERE `id`='$id'";
    
$result mysql_query($query) or die(mysql_error());
    
    if(
mysql_num_rows($result) == "0")
    {
        echo 
"The entry <strong>#".$_GET['id']."</strong> does not exist.";
    }
    else
    {
        while(
$_ROW mysql_fetch_assoc($result))
        {
            echo 
stripslashes($_ROW['title']).'</strong><br />'.$_ROW['date'].'<br /><br />';                    
            echo 
'<br />'.stripslashes($_ROW['entry']);                
        }
    }
?>

Hope this is of help.

___________________

"Hey, **** YOU!"

X-plozive

X-plozive

Status: Offline!

Omg, thankyou stevie, that worked, well I know it's going to work Tongue I've tried the first part of the code now to the other page. I was never going to have a date part but now Im adding it to my script...

Can someone please tell me what's wrong with this?

PHP:


<input name="date" type="hidden" id="date" value="<?php date("M/j/y A"); ?>">


I just keep trying to change it *dies*

sabrina

sabrina

what could you possibly want to know about me?
Status: Offline!

I think you want an "echo" in front of the call to date.

Page 2 out of 3
Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0125 seconds.