Dynadot .com transfer sale, only $10.12 with coupon code DYNA12, available while supplies last, ends October 31, 2026.

Script not working

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
Spacemail by SpaceshipSpacemail by Spaceship
Watch

Xyzer

VIP Member
Impact
12
I am making myself a tutorial management script for a tutorial site like good-tutorials. im sure everything works except the accept script, so if you know whats wrong please say, i will donate you some rep.



Thanks

Steven

Code:

PHP:
<?php

error_reporting(E_ALL ^ E_NOTICE);

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title>Untitled Document</title>

</head>



<body>

<?php

mysql_connect("localhost", "root", "");

mysql_select_db("tutorials");

$query = "SELECT url, id FROM tutorials WHERE status = 'no'";

$result = @mysql_query($query);

$num = mysql_num_rows ($result);



if ($num > 0) {

echo '<table>';

while ($row = mysql_fetch_array($result)) {

$id = $row[1];

echo "<tr>

<td></td>

<td>$row[1]</td><form action=edit.php method=post>

<td><input type=hidden value=$row[1] name=ID> </td>

<td><select name=action><option value=Delete>Delete<option value=Approve>Approve</select><input type=submit value=Submit name=submit></td></form>

</tr>";

}



echo '</table>'; 

} else {

echo "The query didnt find any results.";

}

if ($_POST['ID'] && $_POST['submit'] && $_POST['action']) {

$id2 = $_POST['ID'];

if ($_POST['action'] == Delete) {

$query2 = "DELETE FROM tutorials WHERE id='".$id2."' LIMIT 1"; 

$result2 = @mysql_query($query2);

} else {

$query3 = "UPDATE tutorials SET status='yes' WHERE id='".$id2."' LIMIT 1"; 

$result3 = @mysql_query($query3);

}



}

?>

</body>

</html>
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
What is your problem exactly? What isn't working? Anyway..i've corrected a couple things that _could_ cause it to not work:
PHP:
<?php

error_reporting(E_ALL ^ E_NOTICE);

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>

<?php

$db = mysql_connect("localhost", "root", "");
mysql_select_db("tutorials", $db);

$query = "SELECT url, id FROM tutorials WHERE status = 'no'";

$result = @mysql_query($query);

$num = mysql_num_rows($result);

if($num > 0)
{
  echo '<table>';

  while($row = mysql_fetch_array($result))
  {
    $id = $row[1];
    echo "<tr>
    <td></td>
    <td>$row[1]</td>
    <form action=edit.php method=post>
    <td><input type=hidden value=$row[1] name=ID> </td>
    <td>
    <select name=action>
      <option value=Delete>Delete</option>
      <option value=Approve>Approve</option>
    </select>
    <input type=submit value=Submit name=submit></td>
    </form>
    </tr>";
  }
  echo '</table>';
}
else
{
  echo "The query didnt find any results.";
}

if(isset($_POST['submit']) && $_POST['submit'] != '')
{
  //never trust user input ;)
  //even setting values yourself, select, etc..it can be injected
  $action = trim(strip_tags($_POST['action']));
  $id2 = intval($_POST['ID']);
  
  if(!empty($id) && !empty($action))
  {
    if($action == 'Delete')
    {
      $query2 = "DELETE FROM tutorials WHERE id='".$id2."' LIMIT 1";
      $result2 = @mysql_query($query2);
    }
    else
    {
      $query3 = "UPDATE tutorials SET status='yes' WHERE id='".$id2."' LIMIT 1";
      $result3 = @mysql_query($query3);
    }
  }
  else
  {
    //hmm, that shouldn't happen
  }
}
?>

</body>
</html>
 
0
Close
Thanks, i only have one other problem, how can i make it so after i click submit and it does it, it refreshes the page so that that option will go becuase it does when i manually refresh.

ok, another problem is that when i click delete or approve and refresh it comes up again with a different id and its only in the database once. Please help for NP£
 
0
Close
Code:
echo '<meta http-equiv="Refresh" content="0; url=WEBSITE.php">';

Put that at the bottom of each if statement and it will automatically refresh for you
 
0
Close
Thanks, does anyone know how to solve the other bit with it coming up again?
 
0
Close
If it automatically refreshes it should get rid of that problem...
 
0
Close
oh ok, ill try it and get back to you.

right now the only problem is if theres several waiting to be moderated i accept one, it refreshes and the rest disapear until i refresh a few time, What can be causing this?
 
0
Close
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">

Add that.. I think it'll work. :X
 
0
Close
where do i put that?
 
0
Close
Anywhere inbetween <head> and </head>
 
0
Close
Thanks dan, all works now.
 
0
Close
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Member card: see how many threads a member started
The member card now shows a Threads number, right after Posts. The member card is the box that opens when you point at a name. Profile...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back