E
EnigmaBurn
Guest
I got a problem and I need it fixed now. I cannot screw around with half answers anymore. I will give $50 USD to whoever figures and gives me a definative solution. First person to the solution gets it.
Plesk 7.5, Linux, MySQL, PHP script attempting to insert news into DB. PHP sucessfully pulls information from the DB so connection is seemingly working. However, it is not inserting the information and it is not throwing any errors.
This is the script:
<html>
<head>
<title> ASG Newsfeed Admin</title>
</head>
<body>
<?php
if (isset($_GET['addnews'])): // If the user wants to add a headline
?>
<form action="<?=$PHP_SELF?>" method="post">
<p>Headline:<br />
<input name="headline" length="100"></input><br />
<p>URL:<br />
<input name="url" length="100"></input><br />
<p>Section:<br />
<SELECT id="Select1" size="1" name="section">
<OPTION selected>
<OPTION value="Asian Health">
Asian Health<OPTION value="China">
China<OPTION value="Central Asia">
Central Asia<OPTION value="Korea">
Korea<OPTION value="Japan"> Japan<OPTION value="Middle East">
Middle East<OPTION value="South Asia">
South Asia<OPTION value="Southeast Asia">
Southeast Asia
</OPTION> </SELECT><br />
<p>Description:<br />
<textarea name="desctext" rows="10" cols="40" wrap></textarea><br />
<input type="submit" name="submitnews" value="SUBMIT" /></p>
</form>
<?php
else: // Default page display
// Connect to the database server
$dbcnx = @mysql_connect("localhost", "USER", "PASS");
if (!$dbcnx) {
echo( "<p>Unable to connect to the " .
"database server at this time.</p>" );
exit();
}
// Select the newsfeed database
if (! @mysql_select_db("rssnews") ) {
echo( "<p>Unable to locate the newsfeed " .
"database at this time.</p>" );
exit();
}
// If a headline has been submitted,
// add it to the database.
if ($_POST['submitnews'] == "SUBMIT") {
$sql = "INSERT INTO RSSnews SET
f_title='".$_POST['headline']."',
f_desc='".$_POST['desctext']."',
f_url='".$_POST['url']."',
f_section='".$_POST['section']."',
f_date=NOW()";
if (@mysql_query($sql)) {
echo("<p>Your headline has been added.</p>");
} else {
echo("<p>Error adding headline: " .
mysql_error() . "</p>");
}
}
echo("<p><b> Headlines currently displaying: </b></p>");
// Request all the headlines
$result = @mysql_query("SELECT * FROM RSSnews ORDER BY f_id DESC, f_date DESC LIMIT 6");
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
// Display the text of each item in a paragraph
while ( $row = mysql_fetch_array($result) ) {
echo("<p>" . $row["f_title"] . "</p>");
}
// When clicked, this link will load this page
// with the headline submission form displayed.
echo("<p><a href='$PHP_SELF?addnews=1'>Add a headline</a></p>");
endif;
?>
</body>
</html></CODE>
Finally, I don't care how stupid or simple the solution is that I may have overlooked - you give it to me, I give you $50... I am sick of screwing around this.
Thanks!
Plesk 7.5, Linux, MySQL, PHP script attempting to insert news into DB. PHP sucessfully pulls information from the DB so connection is seemingly working. However, it is not inserting the information and it is not throwing any errors.
This is the script:
<html>
<head>
<title> ASG Newsfeed Admin</title>
</head>
<body>
<?php
if (isset($_GET['addnews'])): // If the user wants to add a headline
?>
<form action="<?=$PHP_SELF?>" method="post">
<p>Headline:<br />
<input name="headline" length="100"></input><br />
<p>URL:<br />
<input name="url" length="100"></input><br />
<p>Section:<br />
<SELECT id="Select1" size="1" name="section">
<OPTION selected>
<OPTION value="Asian Health">
Asian Health<OPTION value="China">
China<OPTION value="Central Asia">
Central Asia<OPTION value="Korea">
Korea<OPTION value="Japan"> Japan<OPTION value="Middle East">
Middle East<OPTION value="South Asia">
South Asia<OPTION value="Southeast Asia">
Southeast Asia
</OPTION> </SELECT><br />
<p>Description:<br />
<textarea name="desctext" rows="10" cols="40" wrap></textarea><br />
<input type="submit" name="submitnews" value="SUBMIT" /></p>
</form>
<?php
else: // Default page display
// Connect to the database server
$dbcnx = @mysql_connect("localhost", "USER", "PASS");
if (!$dbcnx) {
echo( "<p>Unable to connect to the " .
"database server at this time.</p>" );
exit();
}
// Select the newsfeed database
if (! @mysql_select_db("rssnews") ) {
echo( "<p>Unable to locate the newsfeed " .
"database at this time.</p>" );
exit();
}
// If a headline has been submitted,
// add it to the database.
if ($_POST['submitnews'] == "SUBMIT") {
$sql = "INSERT INTO RSSnews SET
f_title='".$_POST['headline']."',
f_desc='".$_POST['desctext']."',
f_url='".$_POST['url']."',
f_section='".$_POST['section']."',
f_date=NOW()";
if (@mysql_query($sql)) {
echo("<p>Your headline has been added.</p>");
} else {
echo("<p>Error adding headline: " .
mysql_error() . "</p>");
}
}
echo("<p><b> Headlines currently displaying: </b></p>");
// Request all the headlines
$result = @mysql_query("SELECT * FROM RSSnews ORDER BY f_id DESC, f_date DESC LIMIT 6");
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
// Display the text of each item in a paragraph
while ( $row = mysql_fetch_array($result) ) {
echo("<p>" . $row["f_title"] . "</p>");
}
// When clicked, this link will load this page
// with the headline submission form displayed.
echo("<p><a href='$PHP_SELF?addnews=1'>Add a headline</a></p>");
endif;
?>
</body>
</html></CODE>
Finally, I don't care how stupid or simple the solution is that I may have overlooked - you give it to me, I give you $50... I am sick of screwing around this.
Thanks!