[PHP-DB] PHP MySQL news display probs

2003-07-15 Thread phpuser
Dear All,

I have created a simple news system and am having a problem in that all the code 
compiles so I think it is correct and the news headlines display but when you point to 
the link to read the article (for example http://localhost/news/user/story.php?id=2) 
nothing displays, it returns that there is nothing in the database and prints out the 
arm of the else statement, no records.

I am convinced that I need to enable something somewhere in the php.ini file but may 
be wrong. Any help would be really really appreciated.

This is the code which displays the news headlines which displays them OK:









 






Reuters Inc : Press 
Releases





 0)
{
// iterate through resultset
// print article titles
while($row = mysql_fetch_object($result))
{
?>
slug; ?>

timestamp); ?>


No press releases currently available







Everything here is copyright © 








This is the code to Display the corresponding article, its driving me nuts!

/ story.php - display contents of selected press release
?>








 






Reuters Inc : Press 
Releases






slug; ?>

content); ?>

This press release was published on timestamp); ?>. For more information, please contact contact; ?>


That press release could not be located in our database.






Everything here is copyright © 






Thanks Again
PHPUSER


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] PHP MySQL news sys prob again

2003-07-18 Thread phpuser
Thanks for the help before the '".$_GET['id']."'"; certainly fixed all the problems 
regarding the display of  stories and I have ammended my othe files similarly but I am 
having I think syntax problems with the add and edit parts. I'm sure its just a case 
of using the GET part again but am having some difficulty.

Thanks in Advance.

Code below

This is the correction made so far which displays stories, deletes and displays 
stories in the edit dialog
//$query = "SELECT slug, content, contact, timestamp FROM news WHERE id = '$id'";
$query = "SELECT slug, content, contact, timestamp FROM news WHERE id = 
'".$_GET['id']."'";


This is the add part:
// add.php - add a new press release
?>








 






Megalomaniacs Inc : 
Administration : Press Releases : Add










Slug



Content



Contact person







Update successful. Go back to the 
main menu.";

// close database connection
mysql_close($connection);
}
else
{
// errors found
// print as list
echo "The following errors were encountered: ";
echo "";
for ($x=0; $x$errorList[$x]";
}
echo "";
}
}
?>







This is the Edit part where the Update statement doesn't work although it retrieves 
the record in the editable formats.

// edit.php - edit a press release
?>








 






Megalomaniacs Inc : 
Administration : Press Releases : Edit






 0)
{
// turn it into an object
$row = mysql_fetch_object($result);

// print form with values pre-filled
?>




Slug



Content
content; 
?>


Contact person







That press release could not be located in our 
database.";
}
}
// form submitted
// start processing it
else
{
// set up error list array
$errorList = array();
$count = 0;

// validate text input fields
if (!$slug) { $errorList[$count] = "Invalid entry: Slug"; $count++; }

if (!$content) { $errorList[$count] = "Invalid entry: Content"; $count++; }

// set default value for contact person
if (!$contact) { $contact = $def_contact; }

// check for errors
// if none found...
if (sizeof($errorList) == 0)
{
// open database connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to 
connect!");

// select database
mysql_select_db($db) or die ("Unable to select database!");

// generate and execute query
//$query = "SELECT slug, content, contact, timestamp FROM news WHERE 
id = '".$_GET['id']."'";
$query = "UPDATE news SET slug = '$slug', content = '$content', 
contact = '$contact', timestamp = NOW() WHERE id = '$id'";
$result = mysql_query($query) or die ("Error in query: $query. " . 
mysql_error());

// print result
echo "Update successful. Go back to the 
main menu.";

// close database connection
mysql_close($connection);
}
else
{
// errors occurred
// print as list
echo "The following errors were encountered: ";
echo "";
for ($x=0; $x$errorList[$x]";
}
echo "";
}
}
?>





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php