-
Posts
1,842 -
Joined
-
Last visited
Posts posted by marcus
-
-
It's an else if.
[code]
}else
if($act == dels1){
[/code] -
You also want to make sure your password field in your database is atleast 32 characters (varchar(255))
-
No problem.
-
[code]
<?php
$page = $_GET['page'];
if($page == contact){
echo "contact page";
}else {
echo "homepage";
//or you can redirect it
//header("Location: index.php?page=home");
};
?>
[/code] -
Yeah, unlink would be much easier. You can do something like
[code]
<?php
$filename = $_POST[filename];
if(file_exists($filename)){
$unlink = unlink($filename);
if($unlink){
echo "File deleted";
}else {
echo "File not deleted";
}
}else {
echo "File does not exist";
};
?>
[/code] -
You can use [url=http://us3.php.net/manual/en/function.ftp-delete.php]ftp_delete[/url]
-
Fourth time with no help, again, I will try to post this.
Problem: Comments will not delete.
Situation: Administrative comment deletion. Administrators can delete comments, the comments will not delete.
Code:
[code]
<? include('../header.php'); ?>
<?php
if($_COOKIE[admin]){
$action = $_GET[act];
$act = $_POST[act];
if($action == delete){
$NFin = "SELECT * FROM `news` WHERE `comments` =1";
$NFgo = mysql_query($NFin);
$NFnu = mysql_numrows($NFgo);
if($NFnu == 0){
echo "No active news";
}else {
echo "<table border=0 cellspacing=2 cellpadding=1>";
echo "<form name=delcomfnews action='".$_SERVER[PHP_SELF]."' method=post>";
echo "<tr><td colspan=2 align=right><h3>Delete Comments - Step 1</h3>";
echo "<tr><td>";
echo "<select name=delcomnews>";
while ($row1 = mysql_fetch_array($NFgo, MYSQL_BOTH)){
echo "<option value=$row1[id]>$row1[title]</option>";
};
mysql_free_result($NFgo);
echo "<td><input type=hidden name=act value=dels1><input type=submit value='Show Comments'>";
echo "</form>";
echo "</table>";
};
}else
if($act == dels1){
$NFid = $_POST[delcomnews];
$NFin = "SELECT * FROM `comments` WHERE newsid ='$NFid'";
$NFgo = mysql_query($NFin) or die(mysql_error());
$NFnu = mysql_numrows($NFgo);
if($NFnu == 0){
echo "There are no comments for news ID #$NFid";
}else {
echo "<table border=0 cellspacing=2 cellpadding=1>";
echo "<tr><td colspan=2 align=right><h3>Delete Comments - Step 2</h3>";
while ($row1 = mysql_fetch_array($NFgo, MYSQL_BOTH)){
echo "<tr><td>Posted by: $row1[poster]<td>($row1[ip])";
echo "<tr><td colspan=2 align=left>$row1[message]";
echo "<form name=delcom action='".$_SERVER[PHP_SELF]."' method=post>";
echo "<input type=hidden name=act value=delcomgo>";
echo "<tr><td colspan=2 align=right><input type=hidden name=newid value=$NFid><input type=hidden name=comid value=$row1[id]><input type=submit value='Delect Comment #"."$row1[id]"."'>";
echo "</form>";
}
mysql_free_result($NFgo);
echo "</table>";
}
if($act == delcomgo){
$comid = $_POST[comid];
$newid = $_POST[newid];
$DELcom = "DELETE FROM `comments` WHERE id =$comid";
$DELsql = mysql_query($DELcom) or die(mysql_error());
$sql1 = "SELECT camount FROM `news` WHERE id =$newid";
$sql2 = mysql_query($sql1);
$sql3 = mysql_fetch_assoc($sql2);
$sql4 = $sql3[camount];
$sql5 = "$sql4 - 1";
$sql6 = "UPDATE `news` SET camount ='$sql5' WHERE id=$newid";
$sql7 = mysql_query($sql6);
echo "Comment ID #$comid has been deleted!";
};
}else if(!$act || !$action){
echo "<table border=0 cellspacing=3 cellpadding=2>";
echo "<tr><td colspan=2 align=right><h3>Comment Admin</h3>";
echo "<tr><td colspan=2 align=left><a href=comments.php?act=edit>Edit Comments</a>";
echo "<tr><td colspan=2 align=left><a href=comments.php?act=delete>Delete Comments</a>";
echo "</table>";
};
}else {
echo "Bad auth";
};
?>
<? require('../footer.php'); ?>
[/code] -
What query isn't executing?
-
also, you already have $id defined as 0, select 0 from your db won't do anything
-
change
[code]
$sql = "SELECT * FROM DATA_ITEMS WHERE id = '$id";
[/code]
to:
[code]
$sql = "SELECT * FROM DATA_ITEMS WHERE id = $id";
[/code] -
did you turn the mysql on?
-
This is about my third time actually trying to get help from these boards for ONE problem.
I am making a commenting/news system. I have an admin panel which allows the administrator to delete/edit the comments (so far only delete). Well, I have the code appearing to work by looking at it (I think), but when trying to delete the comments, it will just go back to the comment administrative index.
code:
[code]
<?php include('../header.php'); ?>
<?php
if($_COOKIE[admin]){
$action = $_GET[act];
$act = $_POST[act];
if($action == delete){
$NFin = "SELECT * FROM `news` WHERE `comments` =1";
$NFgo = mysql_query($NFin);
$NFnu = mysql_numrows($NFgo);
if($NFnu == 0){
echo "No active news";
}else {
echo "<table border=0 cellspacing=2 cellpadding=1>";
echo "<form name=delcomfnews action='".$_SERVER[PHP_SELF]."' method=post>";
echo "<tr><td colspan=2 align=right><h3>Delete Comments - Step 1</h3>";
echo "<tr><td>";
echo "<select name=delcomnews>";
while ($row1 = mysql_fetch_array($NFgo, MYSQL_BOTH)){
echo "<option value=$row1[id]>$row1[title]</option>";
};
mysql_free_result($NFgo);
echo "<td><input type=hidden name=act value=dels1><input type=submit value='Show Comments'>";
echo "</form>";
echo "</table>";
};
}else
if($act == dels1){
$NFid = $_POST[delcomnews];
$NFin = "SELECT * FROM `comments` WHERE newsid ='$NFid'";
$NFgo = mysql_query($NFin) or die(mysql_error());
$NFnu = mysql_numrows($NFgo);
if($NFnu == 0){
echo "There are no comments for news ID #$NFid";
}else {
echo "<table border=0 cellspacing=2 cellpadding=1>";
echo "<tr><td colspan=2 align=right><h3>Delete Comments - Step 2</h3>";
while ($row1 = mysql_fetch_array($NFgo, MYSQL_BOTH)){
echo "<tr><td>Posted by: $row1[poster]<td>($row1[ip])";
echo "<tr><td colspan=2 align=left>$row1[message]";
echo "<form name=delcom action='".$_SERVER[PHP_SELF]."' method=post>";
echo "<input type=hidden name=act value=delcomgo>";
echo "<tr><td colspan=2 align=right><input type=hidden name=newid value=$NFid><input type=hidden name=comid value=$row1[id]><input type=submit value='Delect Comment #"."$row1[id]"."'>";
echo "</form>";
}
mysql_free_result($NFgo);
echo "</table>";
}
if($act == delcomgo){
$comid = $_POST[comid];
$newid = $_POST[newid];
$DELcom = "DELETE FROM `comments` WHERE id =$comid";
$DELsql = mysql_query($DELcom) or die(mysql_error());
$sql1 = "SELECT camount FROM `news` WHERE id =$newid";
$sql2 = mysql_query($sql1);
$sql3 = mysql_fetch_assoc($sql2);
$sql4 = $sql3[camount];
$sql5 = "$sql4 - 1";
$sql6 = "UPDATE `news` SET camount ='$sql5' WHERE id=$newid";
$sql7 = mysql_query($sql6);
echo "Comment ID #$comid has been deleted!";
};
}else if(!$act || !$action){
echo "<table border=0 cellspacing=3 cellpadding=2>";
echo "<tr><td colspan=2 align=right><h3>Comment Admin</h3>";
echo "<tr><td colspan=2 align=left><a href=comments.php?act=edit>Edit Comments</a>";
echo "<tr><td colspan=2 align=left><a href=comments.php?act=delete>Delete Comments</a>";
echo "</table>";
};
}else {
echo "Bad auth";
};
?>
<?php require('../footer.php'); ?>
[/code] -
[code]
function FormCheck()
{
$data = mysql_query("SELECT * FROM test WHERE name =$_POST['name']");
$password = $_POST['password'];
$password_encrypt = md5($password);
$info = mysql_fetch_array( $data );
if (empty($_POST['name']))
{
echo '<center><font color="red">Please enter your name.<br></font></center>';
}
if (empty ($_POST['password']))
{
echo '<center><font color="red">Please enter you password.<br></font></center>';
}
if (isset($_POST['name'] && $_POST['password'] && $_POST['name'] != $info['name'] || $password_encrypt != $info['password'])
{
echo "<center><font color='red'>Sorry your information doesn't match the one that is stored on the database.<br><br></font></center>";
}else {
session_start();
$_SESSION['name'] = $info['name'];
header ('Location: home.php');
}
}
[/code]
try that -
you can't use a variable inside a variable that isn't predefined.
you can do
[code]
<?php
$num = "firstnumber";
$math = "($num / number) * 8)";
echo $math;
?>
[/code] -
I fixed that error, haha.
-
No you do not.
He wants the time to be saved one the time the page is refreshed. -
That didn't change anything :)
-
Well, if you want the search query to be visible in the browser you can use get
site.com/search.php?search=searched
vs. POST
which will post the data and the search query will not be visible
site.com/search.php -
I'm just making a login for my friend using sessions, but I can't seem to get the sessions to register
[code]
<?php ob_start();
<?php
session_start();
$sql = "SELECT * FROM account
WHERE name='$_POST[name]'
AND pass='$_POST[pass]'";
$result = mysql_query($sql);
$num = mysql_num_rows($result);
if ($num > 0) {
$id = mysql_fetch_assoc($result); // ### USER AND PASSWORD ARE CORRECT
$_SESSION[auth] = "yes";
$_SESSION[name] = "$_POST[name]";
$_SESSION[id] = "$id[id]";
header("Location: ?content=news");
}else{ // ### USER OR PASSWORD IS INCORRECT
header("Location: ?content=failed");
}
?>
<?php ob_end_flush(); ?>
[/code] -
that would be the entire list
-
You can do that
by updating the rows
[code]
$sql = "UPDATE users SET `level` =1, `points` =250";
$res = mysql_query($sql) or die(mysql_error());
[/code] -
You could just do
[code]
$sql = "UPDATE `users` SET `field1` =0, `field2` =0";
$res = mysql_query($sql) or die(mysql_error());
[/code] -
Ah yes, I remember that from a topic reply you posted.
-
do this:
[code]
<?php
$question = "hello world";
?>
<input type=hidden name=question value="<?=$question?>">
[/code]
Help needed
in PHP Coding Help
Posted