Jump to content

[SOLVED] INSERT problem


R1der

Recommended Posts

Ok i have made a classifieds page but when you click "Post" it inserts the 'id' 'username' but when it comes to adding the 'text' part it INSERTS '0' and i cant understand why :S Can anyone help with this?

 

<?

session_start();

include("gameconfig.php");

$title = "Classifieds";

if(!$email || !$password){
error("field");
exit;
}

if($playerinfo[password] != $password){
error("password");
}else{
include("top.php");
$cost=1000*$playerinfo['level'];
echo "<center>Tribal Classifieds<br><br></center>";
echo "<center>It will cost you $cost gold to post a advertisement<br><br></center>";
echo "<center><form method=post action=classifieds.php?action=post>Advertise: <input name=post size=12> <INPUT TYPE=SUBMIT VALUE=Post></FORM></center>";
$select = mysql_query("select * from classifieds order by id DESC LIMIT 20");
while($lis = mysql_fetch_array($select))
if($playerinfo['status'] !="Member"){
echo "<center>[<a href=classifieds.php?step=delete&id=$lis[id]>D</a>] ";

echo "$lis[username]: $lis[text]</center><br>";
}else{
echo "$lis[username]: $lis[text]</center><br>";
}
if($action == "post")
{
$post = abs($post);
$post = str_replace("-","",$post);
$cost=1000*$playerinfo['level'];
if($playerinfo['gold'] > $cost){
mysql_query("UPDATE userdb set gold=gold-$cost WHERE id='$playerinfo[id]'");
mysql_query("INSERT INTO classifieds (id, username, text) VALUES ('', '$playerinfo[username]', '$post')") or die(mysql_error());
echo "<center>You sucessfully added your advertisement.</center>";
}else{
echo "<cener>You do not have enough gold to proceed</center>";
}
}
  if ($step == delete)
            {
            echo "News deleted. <a href=classifieds.php>Back</a>";
            $remove = mysql_query("delete from classifieds where id='$id'");
            }


include("bottom.php");
}
?>

 

Thanks.

 

Oh and also can you tell me if my code (test box) is secure enough from sql injections?

 

Thanks for your time

Link to comment
Share on other sites

But i dont want it to insert '0' lol

 

It's a advertisement thing so thay type something and it shows..

 

i.e

 

thay type..

 

'I am selling crystals'

 

and it should insert "I am selling crystals" but its not its inserting '0'

 

Get what i mean?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.