R1der
-
Posts
104 -
Joined
-
Last visited
Never
Posts posted by R1der
-
-
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
-
Dont worry about it, Ill just remove that bit of coding as its fine when i remove that anyways
Thanks for your time and your help
-
I am affraid i cant do that.
By doing that people will steal the coding
-
No because it goes like this
print "text
text
text
text
text
text
text
text
";
-
global $ir,$c,$h,$gangdata; $pq=mysql_query("SELECT * FROM users WHERE userid={$gangdata['gangPRESIDENT']}",$c); $ldr=mysql_fetch_array($pq); $vpq=mysql_query("SELECT * FROM users WHERE userid={$gangdata['gangVICEPRES']}",$c); $coldr=mysql_fetch_array($vpq); print "<h3><u>{$gangdata['gangNAME']} Gang</u></h3><hr />
-
if($gangdata['gangPIC']) //line 62 { print "<img src='{$gangdata['gangPIC']}' alt='Gang Picture' width='468' height='60' /><hr />"; } else { print "<b>No Gang Picture</b><hr />"; }
I get this error
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /****/******/*******/******.php on line 62
It all worked fine till i added that, i could'nt spot a problem with it and its prob something simple.
Thanks for your time
-
Thx for the reply but i tried $user before i changed it to $users
-
yes the variables seem to work fine
-
ok i am having a problem with this bit of codeing (No errors)
[code]<? if($user['wilderness'] == 1 && $ir['posX'] == $users['posX'] && $ir['posY'] == $user['posY']){
print "{$user['username']}";}?>[/code]
ok i have tried everything i can think of to get this to work,
Basicly i want it to show the username of all users who is in the same place as them on like a coordinate map kinda thing. But i cant get it to show the users even tho there are users in the same location as them.
This is how it shows
You are currently at (0,0)
North
West East
South
You are see:
*****(here is where it should show the users)*****
Hope this makes sence -
yes i am still getting the error and no i did'nt cut any of the code out.
Also that is a good point about random lol -
[code]while( $youdata > 0 && $odata > 0)
{
$opponents_health -= random(5,10);
}
[/code] -
No because i fixed that and still get the same error
-
But i am sure even if it was that. it would'nt cause this error
-
i get this error from this code. Can anyone help with this?
Parse error: syntax error, unexpected ')' in /****/******/*****/****.php on line 2
[code]while($youdata > 0 && $odata >)
{
$opponents_health -= random(5,10);
}[/code]
Thx -
lol kk,
Can anyone suggest another way i can do this?
i want away my users can get there password if thay forget it. -
Ok stop confusing me lol
Can this be done or not? :P -
Ah damn!
Thx anyways for the reply -
ok i got a forgot password page what it does is thay type in there username and then it emails them there password.
but the password is md5 in the database can you help me make it so it send them there password decrypted?
[code$body = "Hello {$b['username']}! Your password for www.********.com is {$b['userpass']}. If you have any other problems please mail *****@********.com";
[/code
This si the part that needs help this part of the code is the body of the email you get with there password in it
Thx -
There are 5
i have just fixed it
i removed "
from
(''$pet
Thanks for all your help
-
$sql = "INSERT INTO pets_owned VALUES(''$pet, $userid, 1, 1, 1)";
$result = mysql_query($sql, $c);
if (!$result){
echo "Couldn't execute $sql:" . mysql_error();
}
I think i posted the wrong code b4
-
[code]$sql = "INSERT INTO pets_owned VALUES('' $pet, $userid, 1, 1, 1)";
$result = mysql_query($sql, $c);
if (!$result){
echo "Couldn't execute $sql:" . mysql_error();
}
[/code] -
ok come across another problem lol.
when trying to buy a pet i get this
Couldn't execute INSERT INTO pets_owned VALUES('' 1, 1, 1, 1, 1):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 '1, 1, 1, 1, 1)' at line 1
the first 1 being the pet id second being the userid third , forth and fifth being strength,agility,guard
Anyone have any ideas? let me know if ya wanna see code -
Ok i fixed it now
Thx for your help :) -
ok its working now strange lol.
i get this now
Couldn't execute INSERT INTO pets_owned VALUES('', 1, 1, 1, 1, 1):Column count doesn't match value count at row 1You bought a Greyhound / Poodle!
[SOLVED] INSERT problem
in PHP Coding Help
Posted
Erm the update query works fine how it is..
Why would that have anything to do with the INSERT query?