
July 20th, 2004
08:48 PM
All that I can think of right now is manual.
<?php
$array = array('1', '2', ...);
if (!(inarray($id, $array))) {
adsadasdas;
}
?>

July 20th, 2004
08:51 PM
PHP g00n
Status: Offline!
Here We Go
<?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);
?>
___________________

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

July 20th, 2004
08:53 PM
in the $result part do I need my other field names?

July 20th, 2004
08:57 PM
<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?

July 20th, 2004
09:03 PM
Originally posted by Fitzo
Here We Go
<?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.

July 20th, 2004
09:06 PM
Can someone just help me *cries and dies*

July 20th, 2004
09:58 PM
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
$news_mail = $row['mail']
?>

July 20th, 2004
10:26 PM
Neversidian
Status: Offline!
Basically, all you need is something like this.
<?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
$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!"

July 21st, 2004
03:24 PM
Omg, thankyou stevie, that worked, well I know it's going to work
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?
<input name="date" type="hidden" id="date" value="<?php date("M/j/y A"); ?>">
I just keep trying to change it *dies*

July 21st, 2004
05:01 PM
what could you possibly want to know about me?
Status: Offline!
I think you want an "echo" in front of the call to date.