NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Script not working

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 05-13-2006, 12:46 AM THREAD STARTER               #1 (permalink)
Senior Member
 
Xyzer's Avatar
Join Date: Aug 2005
Location: United Kindom
Posts: 1,502
Xyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to all
 


Tsunami Relief AIDS/HIV

Script not working


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 Code:

<?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>
????: NamePros.com http://www.namepros.com/programming/196824-script-not-working.html

<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 {

????: NamePros.com http://www.namepros.com/showthread.php?t=196824
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>
Xyzer is offline  
Old 05-13-2006, 01:35 AM   #2 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
What is your problem exactly? What isn't working? Anyway..i've corrected a couple things that _could_ cause it to not work:
PHP Code:
<?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'] != '')
????: NamePros.com http://www.namepros.com/showthread.php?t=196824
????: NamePros.com http://www.namepros.com/showthread.php?t=196824
{
  
//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>
Eric is offline  
Old 05-13-2006, 01:44 AM THREAD STARTER               #3 (permalink)
Senior Member
 
Xyzer's Avatar
Join Date: Aug 2005
Location: United Kindom
Posts: 1,502
Xyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to all
 


Tsunami Relief AIDS/HIV
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£
Xyzer is offline  
Old 05-13-2006, 10:57 AM   #4 (permalink)
NamePros Member
Join Date: Apr 2006
Location: Central PA
Posts: 101
NonProphet is on a distinguished road
 



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
NonProphet is offline  
Old 05-13-2006, 11:00 AM THREAD STARTER               #5 (permalink)
Senior Member
 
Xyzer's Avatar
Join Date: Aug 2005
Location: United Kindom
Posts: 1,502
Xyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to all
 


Tsunami Relief AIDS/HIV
Thanks, does anyone know how to solve the other bit with it coming up again?
Xyzer is offline  
Old 05-13-2006, 11:01 AM   #6 (permalink)
NamePros Member
Join Date: Apr 2006
Location: Central PA
Posts: 101
NonProphet is on a distinguished road
 



If it automatically refreshes it should get rid of that problem...
NonProphet is offline  
Old 05-13-2006, 11:03 AM THREAD STARTER               #7 (permalink)
Senior Member
 
Xyzer's Avatar
Join Date: Aug 2005
Location: United Kindom
Posts: 1,502
Xyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to all
 


Tsunami Relief AIDS/HIV
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?
Xyzer is offline  
Old 05-13-2006, 03:39 PM   #8 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
Join Date: Feb 2006
Posts: 2,796
Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future
 


Autism Autism Autism Autism Autism Autism Autism
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">

Add that.. I think it'll work. :X
Dan is offline  
Old 05-13-2006, 03:41 PM THREAD STARTER               #9 (permalink)
Senior Member
 
Xyzer's Avatar
Join Date: Aug 2005
Location: United Kindom
Posts: 1,502
Xyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to all
 


Tsunami Relief AIDS/HIV
where do i put that?
Xyzer is offline  
Old 05-13-2006, 03:53 PM   #10 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
Join Date: Feb 2006
Posts: 2,796
Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future
 


Autism Autism Autism Autism Autism Autism Autism
Anywhere inbetween <head> and </head>
Dan is offline  
Old 05-13-2006, 04:01 PM THREAD STARTER               #11 (permalink)
Senior Member
 
Xyzer's Avatar
Join Date: Aug 2005
Location: United Kindom
Posts: 1,502
Xyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to all
 


Tsunami Relief AIDS/HIV
Thanks dan, all works now.
Xyzer is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 08:49 PM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger