• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

PHP MySQL inserts, Reward offered for solution...

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!
 
Solution

<form action="<?=$PHP_SELF;?>" method="post">

If you have register_globals turned off (which you should), that won't work. Try

<form action="<?=$_SERVER["PHP_SELF"];?>" method="post">

Tyler
 
You're the big winner. Many thanks, I needed that. You finally saw - or at least helped where others ignored or simply did not know... I appreciate that.

PM me and I will arrange your renumeration.

Many thanks again!
 
I cannot screw around with half answers anymore.
I assume this is related to your other post. If it is, then if you had posted the script in question in the first place, then you would have gotten better answers.

Those who try and help others on this forum do the best they can with the information posted. If you give partial info, then you may only get partial answers...

This is a common problem with many of the posts I've seen and tried to help out with in the last few months.

It's like calling a help desk and saying 'it doesn't work, fix it.'

And money is not the object of helping, at least not to me.
 
Actually I was not referring to the previous thread here necessarily... I have sought help in three different forums, and from one offline resource... All got me very close to the 'final answer' but obviously, still just a step away...

I apoligize if you thought this was intended solely to that previous post and was a dig against you... It was not.

I simply got fed up and posted this as a result of such frustration - time is money, my site(s) and I am happy to give a little back for definitive answers...

I appreicate EVERYONE'S time in this community.

Best,
 
No problem, when it gets to be really late, sometimes I get touchy. I realized it afterwards and should have deleted that post but forgot.

A lot of it stems from trying too hard to help find an answer when the info posted is sparse, combined with not wanting to 'ignore' those posts.

Frustration of my own making...

I fully understand how frustrating it is when a server has a problem, that's one reason I try to help out even with the 'my qmail won't send, what could it be' type questions from others.....

Please forgive my last post. Thanks.
 
No worries man! I totally understand. I hope that we may liazze again soon... I get punchy late too... Cheers!
 
Back
Top