Jump to content

kenrbnsn

Staff Alumni
  • Posts

    8,234
  • Joined

  • Last visited

Everything posted by kenrbnsn

  1. Parameters passed to functions are enclosed in parentheses "( )", not curly brackets "{ }". Ken
  2. This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=335169.0
  3. You're overwriting the $key & $val in your second foreach loop, they need to be different variables than your outer loop: <?php $json = '{ "Name001" : { "ID" : "001", "description" : "bleh", "ZipLocation" : "something1.zip" }, "Name002" : { "ID" : "002", "description" : "bleh", "ZipLocation" : "something2.zip" } }'; $json_ary = json_decode($json,true); foreach($json_ary as $key => $val) { echo "$key<br>\n"; foreach ($val as $key2 => $val2) { echo "... $key2 => $val2<br>\n"; } } ?> Ken
  4. If you have sent any output to the browser before doing the header() function, you will get that error. Ken
  5. That would send the same email to all the recipients. I don't think everyone wants to see the same username/password. Ken
  6. There's a built-in function for that: nl2br Ken
  7. Double quotes vs single quotes aren't important here and the ":" is just a noise character to the date() function and will be put into the final string unchanged. If the OP wants a colon between the time and the am/pm designation, that's the OP's prerogative. Ken
  8. You're not locking the directory from running scripts, you're locking a browser from getting a directory list. The hackers didn't have to get a list to see what was there, since they put the file there. If you don't want people to run scripts in a directory from a web browser, that directory needs to be outside the web root. What is the protection on the games directory. If it's 777, that means it's open to the world and the hackers could have gotten there from a different host on the share host. Ken
  9. shuffle takes an array as an argument. It randomizes the content in place, so you want something like: <?php $variable = array(1,5,10,15,20); shuffle($variable); echo '<pre>' . print_r($variable,true) . '</pre>'; //see what's in the shuffled array ?> Ken
  10. A better way is (IMHO) <?php $q = "SELECT I.ITEM_ID AS ID,I.DESCR AS DESCR,W.QUANTITY AS QUANT,W.PRICE AS PRICE FROM ITEM I JOIN WANTS_TO_BUY W ON I.ITEM_ID=W.ITEM_ID JOIN USER U ON U.USERNAME=W.USERNAME WHERE U.USERNAME='%id'"; $rs = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error()); $row = mysql_fetch_assoc($rs); ?> Ken
  11. If you had done some error checking on the query like this, <?php $q = "UPDATE gallery SET cut = '$cut', color = '$color', carats = '$carats', clarity = '$clarity', size = '$size', metal = '$metal', other = '$other', total = '$total', certificate = '$certificate', value = '$value', image = '$angle1', name = '$name', item_no = '$item_no', type = '$type', image2 = '$angle2', desc = '$desc' WHERE id = '$_GET[id]'"; $rs = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error()); ?> You would have gotten an error on the query because "desc" is a reservered word in MySQL. You need to either rename the field or put backticks ` around the word: <?php $q = "UPDATE gallery SET cut = '$cut', color = '$color', carats = '$carats', clarity = '$clarity', size = '$size', metal = '$metal', other = '$other', total = '$total', certificate = '$certificate', value = '$value', image = '$angle1', name = '$name', item_no = '$item_no', type = '$type', image2 = '$angle2', `desc` = '$desc' WHERE id = '$_GET[id]'"; $rs = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error()); ?> Ken
  12. Why do you think it's not working? Errors? Since you don't check to make sure the query is working... Also, never trust user input. You don't validate any input. At the very least process all string data through mysql_real_escape_string Ken
  13. Nothing is wrong with those statements as they stand. Why do you think there is a problem? Ken
  14. This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=334919.0
  15. It's not a small problem. You don't know what the scammers are doing with the data they are collecting. They could be keylogging everything that is typed, they could also be sending out spam from your site. That happened to me a few years ago and got my domain blacklisted. It took months to get the domain off the blacklists. Ken
  16. I realize you've marked this as "solved", but there is a much easier way of generating the string to be written. Use a temporary array and the implode function which would transform your code <?php while($row = mysql_fetch_array($result)) { for($i = 0; $i <= ($numcolumns - 1); $i++) { if($i < ($numcolumns - 1)) { $string = $row[$i] . ","; echo $string; fwrite($fh, $string); } else { $string = $row[$i]; echo $string; fwrite($fh, $string); } } $string = "\n"; echo "<br />"; fwrite($fh, $string); } ?> into <?php while($row = mysql_fetch_array($result)) { $tmp = array(); for($i = 0; $i <= ($numcolumns - 1); $i++) { $tmp[] = $row[$i]; } echo implode(',',$tmp) . "<br />\n"; fwrite($fh, implode(',',$tmp). "\n"); } ?> Much simpler and less error prone. Ken
  17. Can't tell you without seeing your code. Please post it between tags. Ken
  18. If you're not using SSH & SFTP for login and file transfer, start using them immediately, preferable using keys, not passwords. You host should disable in bound telnet & ftp. Your server may have been "rooted", i.e. when the first breakin occurred, a rogue program was installed which allows the scammers to get in and change your code whenever they want. The whole file system needs to be scanned for these rogue programs -- they can be very difficult to find. If your current host doesn't want to deal with your problem (it's their problem too), move to another host. BTW, when posting code in this forum, please put the code between tags. Ken
  19. When I put that URL into a web browser, I get an error message from YouTube: "Incorrect parameters, please try again." When a video is displayed on YouTube there is a menu item you can click that will give you the code needed for embedding the video in your page. Use it. For example, I picked one video at random from that page and this is the code for sharing it: <object width="560" height="349"><param name="movie" value="http://www.youtube.com/v/VcRABREWPbE?version=3&hl=en_US&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/VcRABREWPbE?version=3&hl=en_US&rel=0" type="application/x-shockwave-flash" width="560" height="349" allowscriptaccess="always" allowfullscreen="true"></embed></object> Ken
  20. This topic has been moved to PHP Freelancing. http://www.phpfreaks.com/forums/index.php?topic=334867.0
  21. Try this code and see which message makes it through and what the From line reads: <?php $from = array('nobody@example.com','nobody@yourdomain.com'); foreach ($from as $f) { mail('youremail@address.here','Test from 2','Again, nothing here',"From: Just Testing <$f>","-f $f"); } ?> Ken
  22. The PHP code doesn't have to be in a separate file. It can be in the same file, but once the part of the script that gets invoked via AJAX executes, an exit() must be executed. I do that all the time. Ken
  23. If you put PHP script into a HTML file, that file needs to have a ".php" extension (unless your server is set up to process .html files with PHP) Ken
  24. Since you're using Javascript to add new lines to your form, can you post that function? It may have something to do with your problem. Ken
×
×
  • 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.