Jump to content


Staff Alumni
  • Posts

  • Joined

  • Last visited

Everything posted by mikesta707

  1. are you expecting the alert to happen when the if statement is true? if so maybe you should echo it so it actually gets written to the page an executed, rather than just storing it into a variable
  2. when you echo an array in PHP, all it does is echo the literal string 'Array' judging by the fact that its actually saying array, the code is probably working pretty well. if you want to print the array in a human readable format, use print_r like ginger robot suggested
  3. i see you are using print_r to generate the string as I expected here: $str = print_r($r, true) . PHP_EOL; Try using serialize (check out the link from my post above) to generate the string version of the arrays to store. Then you could simply go through the file line by line, using unserialize to regenerate the PHP data. Alternatively, you could use json_decode/encode but serialize would probably be the better choice as what your doing probably has nothing to do with json
  4. I think what he posted is the text file. OP do you have to store the information like that in the text file? if so parsing the file and turning the contents into seperate arrays will be somewhat difficult. not impossible, but time consuming. Perhaps the serialize() function would be better for storing the contents of whatever arrays into the file, and then you could use unserialize() to get the information from the text file back into a php array.
  5. Thats called pagination, and there are many wonderful tutorials on the internet for that sort of thing. You do have the right idea using $_GET with a pid. Here is a link to a tutorial on phpfreaks http://www.phpfreaks.com/tutorial/basic-pagination
  6. I love Dreamweaver, and have been using it for a while. NetBeans was really slow when I tried to use it, but I was developing Java applications in it so IDK how well it does with PHP. I like eclipse instead of Netbeans for Java stuff anyways, and Komodo is pretty cool. NP++ is all around good though, and what I use when I don't have a dedicated IDE for a certain language
  7. you can do this with javascript. You will have to create an event listener, and bind it to whatever key you want to. do a google search for javascript event listeners
  8. taken from http://forums.digitalpoint.com/showthread.php?t=53570
  9. pretty cool, but its case sensitive. You should either convert everything to capital letters, or lower case letters. I broke it by changing FREAKS to FREAkS
  10. i would have to see your code to give an exact answer, but whereever you assign the value of the post variable to a php variable, instead of doing $username = $_POST['username']; do $username = $_POST['username'] . "@wherever.com";
  11. hmm well to help I'd really have to see more code than what you provided. But this is pretty much an HTML/CSS problem, so you may have better luck if you take this to that forum
  12. Im not sure exactly what you want to do? Do you want to strip numbers from strings? or just strip the number two? or also search for creed as well as creed2? can you perhaps explain a little better or provide more examples
  13. what to add depends on what results you want to get. How do you want to change your search query
  14. $username = "mikesta707"; $atWhere = "@phpfreaks.com"; $wholeAddress = $username . $atWhere;
  15. you can just set the font size. <div class="additional_info ie6fix" id='twitterbox'> <?php echo $feed[0]; ?> <span style="font-size:large" ><?php echo $feed[1]; ?></span> <span style="font-size:small" ><?php echo $feed[2]; ?></span> </div>
  16. heading tags automatically go to the next line. if you want to be next to each other you will have to set their float style, or some other display style try <div class="additional_info ie6fix" id='twitterbox'> <?php echo $feed[0]; ?> <h2 style="float:left"><?php echo $feed[1]; ?></h2> <h4 style="float:left"><?php echo $feed[2]; ?></h4> </div> I'm a little rusty on my CSS though, so that might be wrong
  17. because you are supposed to surround associative array strings with single quotes. a string that isn't surrounded by quotes is assumed to be a constant. For example DEFINE("MY_CONST", "SOME VALUE"); //if i want to use this constant echo MY_CONST; PHP is smart enough to realize that if a constant doesn't exist, you probably meant a string, but if you have a case where you want to say the string MY_CONST, instead of his value, when you do this echo MY_CONST when you meant echo "MY_CONST"; you will run into problems in your case, saying $myARR[mykey]; is technically OK as long as you dont have a constant named mykey, but its best practice to avoid instances when this could be a problem by surrounding your array keys with single quotes. oh and you surround it with curly brackets, because thats how you output associative arrays without concatenating strings
  18. you could also do this echo "<a href='".$row['link']."'>".$row['title']."</a>";
  19. $HTTP_POST_VARS still work in php4 and 5 but they are deprecated. if you notice you use the variable $recipientemail here mail($recipientemail,"$subject","$message","From: $Name <$Email>"); but that var is set as the string "BLANK" here $recipientemail = "BLANK"; that probably has something to do with your email script not working. Is there an error? What does the error message say?
  20. Both of those are perfectly fine. your "proper" syntax is "arguably" no better than what he had. you dont use the backslash to allow " symbols. you use it to escape symbols. For example the new line character \n or the tab character \t. inside strings surrounded with double quotes you need to escape any double quotes that are inside the string. same for single quotes. you can also do this echo '<a href="syntax">'; as cags said
  21. you can't return multiple values like that in PHP. if you want to return multiple values, put them in an array, and use the list function, like function censor($string){ if($string){ $sweararray = array('Fuck', 'bloody', 'shit'); $replacearray = array('F**k', 'b****y', 's**t'); $smilearray = array(''); $smileyarray2 = array('<img src=\'http://localhost/images/P.png\' width=\'60\' height=\'60\' />'); $new_string = str_ireplace($sweararray, $replacearray, $string); $new_string2 = str_replace ($smilearray, $smileyarray2, $string); return array($new_string,$new_string2); } } list($words, $smiles) = censor($someString); however, since there is only one string being passed in, why would you want two strings being passed out? function censor($string){ if($string){ $sweararray = array('Fuck', 'bloody', 'shit'); $replacearray = array('F**k', 'b****y', 's**t'); $smilearray = array(''); $smileyarray2 = array('<img src=\'http://localhost/images/P.png\' width=\'60\' height=\'60\' />'); $new_string = str_ireplace($sweararray, $replacearray, $string); $new_string = str_replace ($smilearray, $smileyarray2, $new_string); return $new_string; } } btw It returns that because this return statement return $new_string && $new_string2; is returning a boolean statement. this look familiar if ($new_string && $new_string2){ it returns 1 because that boolean expression is true
  22. it does as it name implies. it strips slashes from a string. for example <?php $str = "Is your name O\'reilly?"; // Outputs: Is your name O'reilly? echo stripslashes($str); ?> btw, googlek, and php.net are your friends. if you want to eliminate all spaces (Ie " ") then you want to use string replace, like so $newString = str_replace(" ", "", "Hello My name is Mikey!"); //output: HelloMyNameisMikey!
  23. also note, you can alter the style of the normal submit button via CSS
  24. you can create an image submit button <INPUT TYPE="image" SRC="images/submit.gif" HEIGHT="30" WIDTH="173" BORDER="0" ALT="Submit Form"> and for a link you can have it submit onclick <a href="#" onclick="document.form.submit()">submit</a> where form is the name of your form
  25. hmm im not sure how that junk would affect the PHP, but if you fixed it awesome. make sure you click the topic solved button at the bottom of the post. woot for virtual beer. cheers
  • 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.