Jump to content

premiso

Members
  • Posts

    6,951
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by premiso

  1. premiso

    id

    Somewhere you are either calling mysql_close or you are not calling mysql_select_db It is hard to say which without more code, but I am sure you can look through and make sure that the select_db is being ran and that there are no premature calls to mysql_close
  2. premiso

    id

    Change this and see what error comes up: $result=mysql_query($query) or trigger_error("Query Failed: " . mysql_error());
  3. Let me try and redeem myself, if only a little bit: $FullString = preg_replace('~\.sideAds#tripleCalc h3{.*}~sU', "Now Im Gone", $FullString); Should work, as I stated before that the ( ) were needed, they were not. I am unsure of this, but they would only be needed if you wanted to reference the portion that matched the regex in the "replace with" portion. The $ how you had it in this peice of code: $FullString = preg_replace('~^\.sideAds#tripleCalc h3{.*}$~s', "Now Im Gone", $FullString); Was causing it to match the final } because the $ indicated the end of the string and since we made the . ignore linebreaks with the s modifier, it was matching clear to the end. I still think you needed the U modifier, to make the matches un-greedy. The s modifier causes the regex to match new line characters as well, as the . generally does not match the newline character. Using the s overrides this functionality and allows it to match new line characters. If I had explained this poorly, or wrong please correct me Sally Hopefully I did not do too much damage to the OP's theory / usage of Regex by my poor mis-interpretations.
  4. Well if when you get a chance you can explain yourself, I would appreciate it. Maybe next time I won't be such a retard with my explanations
  5. What does needing to process first have to do? Surely you are not displaying data while you are processing are you? If so you probably should not. You would do well to read the following: http://www.phpfreaks.com/forums/index.php/topic,37442.0.html http://www.slunked.com/blog/php/2010/01/how-to-fix-header-already-sent-error-in-php
  6. You can clear it with a header redirect. A meta refresh will just duplicate the data from what I know. So instead of doing the refresh, just do a header redirect. If you need to keep data without processing it store data in session
  7. You would use $_GET['page'] to access the data. For a more indepth answer this may help (Look at the GET Section namely) http://www.tizag.com/phpT/postget.php
  8. Using an incrementor and the modulus operator to determine if there is a remainder. IE: for ($i=0; $i<8; $i++) { if ($i % 3 == 0) { echo 'Third Row<br />'; }else { echo 'Other rows!'; } } Should give you a starting point for how your logic needs to be with modulus.
  9. It is an associative array, meaning it is not number indexed. You have to call it by 'd': If($valueArray['d'] == 0){ echo 'hi'; } If you want it to be both you can do this, however, the associative should be enough: $i=0; foreach ($valueArray as $val) { $valueArray[$i++] = $val; } Will give you a numbered index as well as the associative. So yea either or I guess.
  10. Sorry, my mind is a little slow at the moment. $FullString = preg_replace('~(\.sideAds#tripleCalc h3{.*})~sU', "Now Im Gone", $FullString); It was because you needed to match the pattern with the ( ) in order to replace with preg_replace. The preg_match did not require this because we did not want to get the variable out of it in a match. We just wanted to see if that variable was in the string.
  11. It was how I used print_r. Change it to this to remove the 1. parse_str($return, $valueArray); echo "<pre>", print_r($valueArray, true), "</pre>"; As the true will make it not return a true/false value. print_r for more information.
  12. $FullString = preg_replace('~^\.sideAds#tripleCalc h3{.*}$~sU', "Now Im Gone", $FullString); If it being greedy is the case adding a simple U like done above should alleviate the problem.
  13. Post the code you tried it with. EDIT: An amendment to my first post: curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // allows for transfer to be put into a string Try that and it should work. Sorry about that.
  14. Since it is a query string, parse_str should suit you well. As for it returning one because you do not have the returntransfer set in the curl_setopt. So it is displaying the contents to the browser, there is no need to echo in this case. To fix it add this before you run the exec: curl_setopt($ch, CURL_RETURNTRANSFER, true); // allows for transfer to be put into a string Then change your echo to: $return = curl_exec($ch); Then add the parse string logic: parse_str($return, $valueArray); echo "<pre>", print_r($valueArray), "</pre>"; Should do you right.
  15. Given that you have 10 fields in the database you can get this data out via an array. Somewhat psuedo code here is how it would work: while ($row = mysql_fetch_assoc($result)) { for($i=1;$i<9;$i++) { $experience = $row['experience' . $i]; if(!empty($experience) { $experience = explode(",",$experience); echo "<tr><td>&nbs;</td>"; foreach($experience as $exp) { echo "<td class='fields'>".ucwords(str_replace('_',' ',$exp))."</td>"; } echo "</tr>"; } } } And it should work, given that you have valid queries and are fetching the data properly. Without seeing the full script, I just have to make guesses so yea.
  16. I am at a loss, copying what you had but removing that extra } I did a php -l file.php check on it and it returned no Syntax errors. Not sure what else I can do to test it, but if I cannot see the error I am hard put to fixing it.
  17. The error is here: if (isset($_GET['search'])) { $searchTerms = trim($_GET['search']); $searchTerms = strip_tags($searchTerms); // remove any html/javascript. } Change it to: if (isset($_GET['search'])) { $searchTerms = trim($_GET['search']); $searchTerms = strip_tags($searchTerms); // remove any html/javascript. // this brace was an extra which caused an error // }
  18. How are your variable names being populated? Manually or from GET/POST, if from GET/POST that means you either extracted the array of have register_globals on, both of which are not good practice. That and you can easily manipulate / use them in an array better then you can as a variable. Incase that is the case here is an example: for($i=1;$i<9;$i++) { if(!empty($_POST['experience' . $i])) { $experience = explode(",",$_POST['experience' . $i); echo "<tr><td>&nbs;</td>"; foreach($experience as $exp) { echo "<td class='fields'>".ucwords(str_replace('_',' ',$exp))."</td>"; } echo "</tr>"; } } If register_globals are not on and the original data is not in array but is defined this would work: for($i=1;$i<9;$i++) { $experience = ${$experience . $i}; if(!empty($experience) { $experience = explode(",",$experience); echo "<tr><td>&nbs;</td>"; foreach($experience as $exp) { echo "<td class='fields'>".ucwords(str_replace('_',' ',$exp))."</td>"; } echo "</tr>"; } } Both untested, but hopefully gives you a working theory.
  19. $level = (empty($row['Level'])) ? $row['level'] : 0; If you want to test if the level is = 0 or null then you would change the empty logic. But empty checks if $row['level'] is 0 or "" etc. So it is still valid. It does not check null variables though. If it can be null use is_null.
  20. The error is not in the code you posted. That could just be where it thought it was. Post your full script inside of the php tags if you want assistance to fix it.
  21. I would just use a Wordpress blog, there are plenty of plugins for the rating etc that you can find.
  22. http://www.google.com/search?ie=UTF-8&oe=UTF-8&sourceid=navclient&gfns=1&q=php+ad+clicking+scripts May help you in your findings on different scripts people created to do what you want. Using them as an example should give you a rough idea how it needs to be done.
  23. str_split will convert a string to an array of the characters in it.
  24. Just to correct your line of thinking: if (preg_match('~^\A.*[;]$~U', $string, $matches)) { Should work. The ^ says the first character of the searched string must be A and the $ says it must end with the character preceding it. Start of string End of string. I am unsure of the ; is a special character in regex, but yes putting it inside the brackets will work just fine. I added the U after it to be un-greedy as if there are multiple ; in the line it will match to the last one. If you want that then simple remove the U.
  25. With basic pagination: http://www.phpfreaks.com/tutorial/basic-pagination
×
×
  • 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.