Jump to content

chriscloyd

Members
  • Posts

    488
  • Joined

  • Last visited

Everything posted by chriscloyd

  1. top of the page you need to start the session session_start(); then you can simply call the session by doing $_session['ldapname']
  2. this is my script <?php session_start(); mysql_connect('localhost','******','******') or die('Could not connect to the server'); mysql_select_db('******') or die('Could not select database'); $uploaddir = 'images/users/'; $rand = rand(0,8790); $uploadfile = $uploaddir . $_SESSION['username'] . $rand . basename($_FILES['userfile']['name']); if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { $update = mysql_query("UPDATE users SET user_image = '".$uploadfile."' WHERE username = '".$_SESSION['username']."'"); if ($update) { header ("Location: ../index.php?page=actcreated"); } } else { echo "Possible file upload attack!\n"; } ?> this is the result when i run the script Warning: move_uploaded_file(images/users/haqshot2426haq.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/ccloyd/public_html/process/uploadfile.php on line 8 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpER2301' to 'images/users/haqshot2426haq.jpg' in /home/ccloyd/public_html/process/uploadfile.php on line 8 Possible file upload attack! Here is some more debugging info:Array ( [userfile] => Array ( [name] => haq.jpg [type] => image/jpeg [tmp_name] => /tmp/phpER2301 [error] => 0 => 29004 ) )
  3. just upload it and change the image name thats all really
  4. i want to upload a file and change the name can anyone help me?
  5. i got this error Warning: preg_replace() [function.preg-replace]: Parameter mismatch, pattern is a string while replacement in an array. in /usr/home/www5965/public_html/jarred/sendchat.php on line 10
  6. I made a chat room with php and now im trying to make a bad word filter cna someone help me? not to code but to lead me in the right direction heres the script i have now thats not working <?php session_start(); mysql_connect('localhost','******','*****'); mysql_select_db('*****'); function filterBadWords($str){ // words to filter $badwords=array( "fuck", "bitch", "ass", "a s s", "f u c k", "cunt", "pussy"); // replace filtered words with $replacements=array( "&#()*@", "@^%(*!", "*&@&^@&@#" ); for($i=0;$i < sizeof($badwords);$i++){ srand((double)microtime()*1000000); $rand_key = (rand()%sizeof($replacements)); $str=eregi_replace($badwords[$i], $replacements[$rand_key], $str); } return $str; } if (isset($_SESSION['thewayofthejew'])) { $time = date('n/j/y g:i:s A'); $message = strip_tags($_POST['message']); filterBadWords($message); mysql_query("INSERT INTO chat (`user`, `message`, `time`) VALUES ('".$_SESSION['thewayofthejew']."', '".$str."', '".$time."')"); header("Location: index.php?page=chat"); } ?>
  7. i have this code and its supposed to refresh every 20 milliseconds but it doesn't can someone help me i got it from the tutorial <script type="text/javascript"> function createRequestObject() { var req; if(window.XMLHttpRequest){ // Firefox, Safari, Opera... req = new XMLHttpRequest(); } else if(window.ActiveXObject) { // Internet Explorer 5+ req = new ActiveXObject("Microsoft.XMLHTTP"); } else { // There is an error creating the object, // just as an old browser is being used. alert('There was a problem creating the XMLHttpRequest object'); } return req; } // Make the XMLHttpRequest object var http = createRequestObject(); function sendRequest(act) { // Open PHP script for requests http.open('get', 'getchat.php?act='+act); http.onreadystatechange = handleResponse; http.send(null); } function handleResponse() { if(http.readyState == 4 && http.status == 200){ // Text returned FROM PHP script var response = http.responseText; if(response) { // UPDATE ajaxTest content document.getElementById("countPosts").innerHTML = response; setTimeout(countPosts,1); } } } sendRequest('countPosts'); </script>
  8. chriscloyd

    hey

    hey im new to this one but im on a lot on the php one Im making my own chat i have the mysql data base ready just need help with making it refresh my mysql query every 20 mililseconds
  9. what does output buffering do?
  10. Alright heres my problem. I'm making a web based game that requires turns to play. Theres an option where people can cash out. The code belows tries to stop if the user uses more turns then they have. Each user starts out with 100 turns. heres my code can anyone help me. Its not stopping if i use over 100 turns <?php //cash echo 'Use some of your turns to produce more resources and to make your population grow. The more food you have the more people you attract to your territory.<br /><br />'; ?> <form action="index.php?page=cash" method="post"> <table width="100%" border="0" cellspacing="5" cellpadding="0"> <tr> <td width="14%">Turns</td> <td width="86%"><label> <input name="turns" type="text" id="turns" size="2"> </label></td> </tr> <tr> <td> </td> <td><label> <input type="submit" name="Submit" value="Cash Out!"> </label></td> </tr> </table> </form> <?php if(isset($_POST['turns'])) { $turns = $_POST['turns']; $check_turns = mysql_query("SELECT * FROM other WHERE userid = '".$_SESSION['firefightid']."'"); if ($check_turns) { $numallowed = mysql_fetch_array($check_turns); if ($turns > $numallowed) { $random_turn = rand(1,$numallowed['turns']); echo 'You do not have that many turns to cash out with. Try a lower number. Lets say '.$random_turn.', but thats just what I think.'; } else { $i = 0; while ($i < $turns) { /*//quires $get_other = mysql_query("SELECT * FROM other WHERE userid = '".$_SESSION['firefightid']."'"); $get_resources = mysql_query("SELECT * FROM resources WHERE userid = '".$_SESSION['firefightid']."'"); $get_units = mysql_query("SELECT * FROM units WHERE userid = '".$_SESSION['firefightid']."'"); $units = mysql_fetch_array($get_units); $resources = mysql_fetch_array($get_resources); $other = mysql_fetch_array($get_other); //delete turn from mysql table $i++; $old_turns = $other['turns']; $new_turns = $old_turns - 1; mysql_query("UPDATE other SET turns = '$new_turns' WHERE userid = '".$_SESSION['firefightid']."'"); //production time //first la (Light Armor) //each barracks can hold 50 soldiers //so first check to see if soldiers % 50 is lower than baracks $total_units = ($units['lightarmor'] + $units['heavyarmor']) % 50; if ($total_units <= $units['barracks']) { if ($other['prla'] == 100) { $prla = 1.0; } else { $prla = '.'.$other['prla']; } $rand = rand(3,7); $numOfbarracks = (($units['barracks'] * $prla) + (ceil($units['lightarmor']) % 3)) * $rand; echo $numOfbarracks.'<br />'; } else { $new_la = 'You dont have enough barracks to produce anymore Light Armor Units'; }*/ } } } } ?>
  11. mod rewrite url heres my problem i have a turned based game im making i need it to work like this i have the link www.linkhere.com?index.php?page=attack heres the mod rewrite i did and it does not work RewriteEngine On RewriteRule ^(.*)$ /index.php?page=$1 anyone help?
  12. ya do something along the lines with switch statements like this <?php echo '<a href="index.php?page=test1>Link 1</a> - '; echo '<a href="index.php?page=test2>Link 2</a> - '; echo '<a href="index.php?page=test3>Link 3</a> - '; switch($_GET['page']) { case "test1": include("file1.php"); break; case "test2": include("file2.php"); break; case "test3": include("file3.php"); break; } ?>
  13. mod rewrite url do this open .htaccess in notepad put this in it RewriteEngine On RewriteRule ^(.*) view.php?id=$1
  14. how do i secure my php form fields
  15. just did that now it changes it back to this http://www.chaoslegionclan.net/CEGL-Work/ag/files/roster_images.php?game=1 http://www.chaoslegionclan.net/CEGL-Work/ag/files/roster_images.php?game=1
  16. <?php $game_id = $_GET['game']; $i = 0; $get_game = mysql_query("SELECT * FROM games WHERE game_id = '".$game_id."'") or die(mysql_error()); $game = mysql_fetch_array($get_game); echo '<table width="100%" border="0" cellspacing="3" cellpadding="0">'; echo '<tr>'; echo '<td align="center" colspan="3">'.$game['gamename'].'</td>'; echo '</tr>'; echo '<tr>'; $get_roster = mysql_query("SELECT * FROM rosters WHERE game_id = '".$game_id."'") or die(mysql_error()); while($roster = mysql_fetch_array($get_roster)) { $get_user = mysql_query("SELECT * FROM users WHERE user_id = '".$roster['user_id']."'"); $user = mysql_fetch_array($get_user); echo '<td align="center"><img src="'.$user['picture'].'" height="65px" width="65px"></td>'; if ($i % 3) { echo '</tr><tr>'; } $i++; } echo '</tr>'; echo '</table>'; ?> http://www.chaoslegionclan.net/CEGL-Work/ag/files/roster_images.php?game=1 http://www.chaoslegionclan.net/CEGL-Work/ag/files/roster_images.php?game=1 http://www.chaoslegionclan.net/CEGL-Work/ag/files/roster_images.php?game=1 http://www.chaoslegionclan.net/CEGL-Work/ag/files/roster_images.php?game=1 http://www.chaoslegionclan.net/CEGL-Work/ag/files/roster_images.php?game=1
  17. tried that too now shows two on each row <?php $game_id = $_GET['game']; $i = 0; $get_game = mysql_query("SELECT * FROM games WHERE game_id = '".$game_id."'") or die(mysql_error()); $game = mysql_fetch_array($get_game); echo '<table width="100%" border="0" cellspacing="3" cellpadding="0">'; echo '<tr>'; echo '<td align="center" colspan="3">'.$game['gamename'].'</td>'; echo '</tr>'; echo '<tr>'; $get_roster = mysql_query("SELECT * FROM rosters WHERE game_id = '".$game_id."'") or die(mysql_error()); while($roster = mysql_fetch_array($get_roster)) { $get_user = mysql_query("SELECT * FROM users WHERE user_id = '".$roster['user_id']."'"); $user = mysql_fetch_array($get_user); echo '<td><img src="'.$user['picture'].'" height="65px" width="65px"></td>'; if ($i % 3) { echo '</tr><tr>'; } $i++; } echo '</table>'; ?> http://chaoslegionclan.net/CEGL-Work/ag/files/roster_images.php?game=1
  18. heres what im trying right now and its not working <?php $game_id = $_GET['game']; $i = 0; echo '<table width="100%" border="0" cellspacing="3" cellpadding="0">'; $get_roster = mysql_query("SELECT * FROM rosters WHERE game_id = '".$game_id."'") or die(mysql_error()); while($roster = mysql_fetch_array($get_roster)) { $i++; $get_user = mysql_query("SELECT * FROM users WHERE user_id = '".$roster['user_id']."'"); $user = mysql_fetch_array($get_user); if ($i % 3) { echo '<tr>'; } echo '<td><img src="'.$user['picture'].'"></td>'; if ($i % 3) { echo '</tr>'; } } echo '</table>'; ?> http://chaoslegionclan.net/CEGL-Work/ag/files/roster_images.php?game=1 its showing it on three separate lines
  19. well how would i put there name into an array here would i do this <?php $game_id = $_GET['game']; $names = array(); $get_roster = mysql_query("SELECT * FROM rosters WHERE game_id = '".$game_id."'") or die(mysql_error()); while($roster = mysql_fetch_array($get_roster)) { $i = 0; $names[] = $roster['displayname']; foreach($names as $name) { if($i % 3 == 0) { echo "<tr>"; } echo "<td>".$name."</td>"; if($i % 3 == 0) { echo "</tr>"; } $i++; } //Just to make sure we are closing the last <tr> if(($i-1) % 3 != 0) echo "</tr>"; } ?> i tried that and it didnt work
  20. I think that makes perfect sense now lol
  21. well heres an example go to www.team3d.com and look on the right side where it has the pics of the members Okay let me try to explain better. I have 9 users on my clan roster. I need to show all their pics and i dont want to show all in one row or all on separate rows i wanna show them in rows of three once it hits three create a new row and display three more then once it hits six new row and display three more
  22. Heres my dilemma. I have a script that is going to make a roster image that shows all the members on the team and I need to do rows of three. So I have 9 images And i need to do three columns and then when it gets to the third image to make a new row how would i Do this?
×
×
  • 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.