-
Posts
1,842 -
Joined
-
Last visited
Posts posted by marcus
-
-
Where are you defining $id?
-
You aren't selecting anything from the database, you're only updating it.
[code]
<?php
//connection stuff here
$query = "SELECT * FROM business_info WHERE id =idnumhere";
$result = mysql_query($query);
$res2 = mysql_fetch_assoc($result);
$busname = $res2[BusinessName];
//other values
echo "$busname";
//will echo the business name of the id specified
?>
[/code] -
And with textareas, you can't make the value of it text. You want to do
[code]
<textarea><?=$textarea?></textarea>
[/code] -
[code]</tr>[/code]
that is line 252 -
try using double quotes instead of single quotes while defining your host,user,pass and dbname
-
changing the table really wont work...
-
-
I'm making a comment system, and obviously I am making an admin panel for it, so an admin can delete/edit the comments. Well, I got up to the step where it would echo off the comments but now, when the form submits it will just go back to the normal screen, that shows which action you want to proceed with.
[code]
<? include('../header.php'); ?>
<?php
if($_COOKIE[admin]){
$action = $_GET[act];
$act = $_POST[act];
if($action == delete){
$NFin = "SELECT id,title 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]
edit: updated code, still not working
2ndedit: updated code, still not working -
He has that...
-
Ok, so I am making a commenting system, and most good comment systems have a swear filter.
So I have my array of "bad" words, and I wanted to input the array into a str_replace() function.
[code]
$arra = array("words,words,words");
$mess = str_replace($arra,"<img src=images/swear.gif>",$mess);
[/code] -
Yep, thanks! Found it.
-
Project: Comment System.
Problem: Will not post comment, had some errors before but fixed, now I just get a mysql_error().
Code:
[code]
<? ob_start(); ?>
<? include('header.php'); ?>
<?php
$id = $_GET[id];
$act = $_POST[action];
include('smiley.func.php');
if(!$id && !$act){
echo "Sorry, you did not specify an ID";
}else
if($act == add){
$name = $_POST[name];
$mess = $_POST[message];
$neid = $_POST[id];
$time = $_POST[time];
$date = $_POST[date];
if(empty($name) || empty($mess)){
echo "Please fill in all the fields";
}else {
smileys();
$cam = "SELECT camount FROM `news` WHERE id =$neid";
$car = mysql_query($cam) or die(mysql_error());
$cas = mysql_fetch_assoc($car);
$amc = $cas[camount];
$nac = "$amc + 1";
$adC = "INSERT INTO `comments` (`poster`,`message`,`time`,`date`,`newsid`) VALUES('$name','$message','$time','$date','$neid')";
$adR = mysql_query($adC) or die(mysql_error());
$upCa= "UPDATE `news` SET camount =$nac WHERE id =$neid";
$upCr= mysql_query($upCa) or die(mysql_error());
echo "Your comment has been successfully added, <a href=comments.php?id=$neid>click here</a> to return to the comments";
};
}else {
//check if news id exists
$cheID = "SELECT * FROM `news` WHERE id =$id";
$cheRes = mysql_query($cheID);
$cheNum = mysql_numrows($cheRes);
$cheAsc = mysql_fetch_assoc($cheRes);
$comAlv = $cheAsc[comments];
if($cheNum > 0){
//will echo comments if they exist
$com = "SELECT * FROM `comments` WHERE newsid =$id";
$res = mysql_query($com);
$cnm = mysql_numrows($res);
if($comAlv == 2){
echo "Comments have been disabled for this news article";
}else
if($cnm == 0){
echo "No comments for this news article you can add one below";
}else if($cnm > 0 && $comAlv == 1){
while ($row1 = mysql_fetch_assoc($res, MYSQL_BOTH)){
print "<table border=0 cellspacing=2 cellpadding=1>";
print "<tr><td align=left>Posted by $row1[poster] on $row1[date] at $row1[time]";
print "<tr><td colspan=2 align=left valign=top>$row1[message]";
}
mysql_free_result($res);
}
}else {
echo "The ID specified does not exist";
};
if($comAlv == 1){
//echo out comment add table
echo "<br><br>";
echo "<table border=0 cellspacing=2 cellpadding=2>";
echo "<form action=$_SERVER[PHP_SELF] name=add method=post>";
echo "<tr><td colspan=2 align=right><h3>Add A Comment";
echo "<tr><td>Name:<td><input type=text name=name>";
echo "<tr><td>Smileys:<td><a href=".'javascript:openwindow()'.">Open</a>";
echo "<tr><td>Message:<td><textarea name=message rows=4 cols=17></textarea>";
echo "<tr><td colspan=2 align=left><input type=hidden name=action value=add><input type=hidden name=newsid value=$id>";
echo "<input type=submit value='Add Comment'>";
echo "</form></table>";
}
};
?>
<? require('footer.php'); ?>
<? ob_end_flush(); ?>
[/code]
mysql_error():
[code]
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
[/code] -
Just a question to all: is anybody else experiencing issues with making topics?
-
Yeah, you'll have to change by seconds, not by just 2.
-
yep, that's exactly what i did, thanks anyway
-
I am making a news sytem, and on the index it would echo the news. Now, I have two rows in the news table right now, but it's only showing one of them and then i get an error:
[code]
Warning: mysql_fetch_array(): 7 is not a valid MySQL result resource in /home/neoblob/public_html/cms/index.php on line 20
[/code]
[code]
<? include('header.php'); ?>
<?php
$page = $_GET[page];
$fetch = "SELECT * FROM news ORDER BY `id` DESC";
$fet1 = mysql_query($fetch) or die(mysql_error());
$num = mysql_num_rows($fet1);
if(!$page){
$page = 1;
};
if($news == 0){
echo "news not enabled";
}else {
if($num == 0){
echo "No news";
}else {
while ($fet2 = mysql_fetch_array($fet1, MYSQL_BOTH)){
if(!$camount){
$camount = 0;
};
echo "
<table border=0 cellspacing=2 cellpadding=2>
<tr><td colspan=2 align=right>
<h3>$fet2[title]</h3>
<tr><td colspan=2 align=left>
Posted on: $fet2[date] at $fet2[time] by $fet2[poster]
<tr><td colspan=2 align=left>
$fet2[body]
<tr><td align=left>
Category: $fet2[category]<td align=right>";
if($fet2[comments] == 1){
echo "<a href=comments.php?id=$fet2[id]>$fet2[camount] Comments</a>
</table><br><br>";
};
mysql_free_result($fet1);
};
};
};
?>
<? require('footer.php'); ?>
[/code] -
Hmm.
[code]
$sql = "SELECT * FROM events";
$res = mysql_query($sql);
$num = mysql_numrows($res);
if($num == 0){
echo "none";
}else {
echo "some";
};
[/code] -
Could you show me your whole code?
-
What you have is if $numrows DOESNT equal 0 it will display the message.
-
You should do this:
[code]
if($numrows == 0){
echo "error message";
}else {
//stuff
};
[/code] -
You can easily use str_replace
[code]
$email = str_replace(" ","+",$email);
[/code]
which will take the space from the variable and replace it with the plus (+) sign -
Your best solution would actually using a different row for each one.
Or you can create a table for each IP, but that would be ever worse, haha. I understand what you're saying, and your first theory with over 90,000 rows, yes that would be alot, like only 30-60mb of SQL usage. -
Then when showing what page that user is on you can easily use fetch assoc or fetch array and echo off last page and link it http://site.com/$lastpage
If they were on index.php the link would be site.com/index.php -
just update their row with what page they are in the last page column using $_SERVER[REQUEST_URI]
ffmpeg
in Miscellaneous
Posted