Jump to content

MadLittleMods

Members
  • Posts

    46
  • Joined

  • Last visited

Everything posted by MadLittleMods

  1. So I am wanting to replace GET variable values in a url and if the variable does not exist, then add it to the url. I am not good with javascript but I do know how to use jQuery quite well and the basics of javascript. I do know how to write regex but not how to use the javascript syntax of regex and what functions to use it with. Here is what I have so far and it does have an error on line 3: See it on jsfiddle(or below): http://jsfiddle.net/MadLittleMods/C93mD/ function addParameter(url, param, value) { var pattern = new RegExp(param + '=(.*?);', 'gi'); return url.replace(pattern, param + '=' + value + ';'); alert(url); }
  2. Since i can't just edit my existing post so my thread doesn't bump... The script does work i just didn't wait long enough for all the pages to load. Before my script spit out info as it went but now it does it all in one chunk which I was not used to.
  3. Well after my friend said "it's becuase you are defining creators inside the loop", I knew exactly what I needed to do. I was using $creators outside of its scope in the while. So i just made a variable called $done in the bigger scope and that worked great. Here is the code that works but if you remove the $done = 0 at the end then it doesn't work. How can you put a curl in a while loop and make it work? I did this about 10 days ago but now it just doesn't work.. <?php echo 'started up<br>'; $done = 1; do { echo 'doing...<br>'; $url_to_curl = "http://visualpulse.net/forums/index.php"; // create a new curl resource $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, $url_to_curl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // grab URL, and return output $output = curl_exec($ch); // close curl resource, and free up system resources curl_close($ch); // echo $output; echo 'just curled<br>'; // echo $output; echo '<br><br>done curling: '.$url_to_curl.'<br><br>'; // find the people preg_match_all('/<a class="subject board_title_in_info_div" href="(.*?)" name="(.*?)">(.*?)<\/a>/', $output, $creators); //print_r($creators); foreach ($creators[3] as $key => $creator) { echo $creator.'<br>'; } $done = 0; } while($done); ?>
  4. Well usually I can solve my problems after some grueling hours but this one just has me stumped. A similar script worked just 10 days ago on my server. I had just tried it today and it isnt working and that is why i made a more streamlined version hoping it would work but it did the same exact thing. I removed all the pregs and changed it to a more broad site that I know works with cURL. I made it a simpler script just for debugging and even this doesn't work. I noticed my host updated the cPanel and I think my php version is different and is now 5.2.15 All this script does is nothing i visit and the loading wheel just spins up on the tab and nothing is outputted. Here is my updated script: <?php echo 'started up<br>'; do { echo 'doing...<br>'; $url_to_curl = "http://visualpulse.net/forums/index.php"; // create a new curl resource $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, $url_to_curl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // grab URL, and return output $output = curl_exec($ch); // close curl resource, and free up system resources curl_close($ch); // echo $output; echo 'just curled<br>'; // echo $output; echo '<br><br>done curling: '.$url_to_curl.'<br><br>'; // find the people preg_match_all('/<a class="subject board_title_in_info_div" href="(.*?)" name="(.*?)">(.*?)<\/a>/', $output, $creators); //print_r($creators); foreach ($creators[3] as $key => $creator) { echo $creator.'<br>'; } } while(!empty($creators[3])); ?>
  5. Got it done with some Jquery -- Still some glitches but mostly works! $(document).ready(function() { var window_width = $(window).width(); var half_window_width = window_width / 2; var filler_width = half_window_width - 500; $("#cadence_header_filler").width(filler_width); $(window).resize(function() { var window_width = $(window).width(); var half_window_width = window_width / 2; var filler_width = half_window_width - 500; $("#cadence_header_filler").width(filler_width); }); });
  6. That setup doesn't seem to do much but make a worse version of what i have and yes i changed to work with my stuff... When I analyze it it kinda makes sense since your are floating left and right. I do not want my main header to the side of the screen. I want it smack dab in the middle while my left filler fills up all the space on the side if there is any. The right div really holds nothing and doesn't have any properties...
  7. Closest I can get is this: with the code of: <div class="cadence_header_holder"> <div class="cadence_header_left floatleft"></div> <div class="cadence_header_main"> </div> <div class="cadence_header_right floatleft"></div> <div class="clear"></div> </div> .cadence_header_holder { width: 100%; padding-top: 40px; padding-bottom: 40px; margin: 0 auto; } .cadence_header_main { background: url(../images/spec/cadence_header_main.png) no-repeat; width: 1000px; height: 140px; margin: 0 auto; } .cadence_header_left { width: 100%; background: url(../images/spec/cadence_header_left.png) repeat-x; height: 140px; }
  8. I want to make a header block like the image below(sorry for bad quality - big gifs mess up like that) I want the centered main div to be in the middle and then a filler div on the left to fill up the space. I have tried many things but this is just what I have at the moment. Please no absolute hacks I have this code so far: <div class="cadence_header_holder"> <div class="cadence_header_left floatleft"></div> <div class="cadence_header_main floatleft"> </div> <div class="cadence_header_right floatleft"></div> <div class="clear"></div> </div> .cadence_header_holder { width: 100%; padding-top: 40px; padding-bottom: 40px; margin: 0 auto; } .cadence_header_main { background: url(../images/spec/cadence_header_main.png) no-repeat; width: 1000px; height: 140px; margin: 0 auto; } .cadence_header_left { width: 100%; background: url(../images/spec/cadence_header_left.png) repeat-x; height: 140px; } That code aboves gives an output of:
  9. use this... while($row = mysql_fetch_array( $result )) { $i=1; if ($row['game_id']='$i') { if($row['pt_spread'] == 0) { $row['pt_spread'] = "" } echo "<tr><td>"; echo $row['date']; echo "</td><td>"; echo $row['team_name']; echo "</td><td>"; echo $row['owner']; echo "</td><td>"; echo $row['pt_spread']; echo "</td><td>"; echo $row['team_pts']; echo "</td><td>"; echo $row['team_bet']; echo "</td><td>"; echo $row['team_cover']; echo "</td><td>"; echo $row['owner_pts']; echo "</td></tr>"; if ($table_row_count % 2 && $table_row_count != 0) { echo ' <tr style="height: 8px"></tr> '; } $table_row_count++; } $i++; } echo "</table>";
  10. Well I am trying to use the mootools fx.slide to get some content to come out when a button is pushed. It is currently not working and I am really bad with java etc. I am really good with html and php. How do I get this script to work? I added the mootools library as so: <script type="text/javascript" src="scripts/mootools-core-1.3.1-full-compat.js"></script> I also put this in: <script type="text/javascript"> window.addEvent(\'domready\', function() { var status = { \'true\': \'open\', \'false\': \'close\' }; // -- vertical var myVerticalSlide = new Fx.Slide(\'vertical_slide\'); $(\'v_slidein\').addEvent(\'click\', function(event){ event.stop(); myVerticalSlide.slideIn(); }); $(\'v_slideout\').addEvent(\'click\', function(event){ event.stop(); myVerticalSlide.slideOut(); }); $(\'v_toggle\').addEvent(\'click\', function(event){ event.stop(); myVerticalSlide.toggle(); }); $(\'v_hide\').addEvent(\'click\', function(event){ event.stop(); myVerticalSlide.hide(); $(\'vertical_status\').set(\'text\', status[myVerticalSlide.open]); }); $(\'v_show\').addEvent(\'click\', function(event){ event.stop(); myVerticalSlide.show(); $(\'vertical_status\').set(\'text\', status[myVerticalSlide.open]); }); // When Vertical Slide ends its transition, we check for its status // note that complete will not affect \'hide\' and \'show\' methods myVerticalSlide.addEvent(\'complete\', function() { $(\'vertical_status\').set(\'text\', status[myVerticalSlide.open]); }); // -- horizontal var myHorizontalSlide = new Fx.Slide(\'horizontal_slide\', {mode: \'horizontal\'}); $(\'h_slidein\').addEvent(\'click\', function(event){ event.stop(); myHorizontalSlide.slideIn(); }); $(\'h_slideout\').addEvent(\'click\', function(event){ event.stop(); myHorizontalSlide.slideOut(); }); $(\'h_toggle\').addEvent(\'click\', function(event){ event.stop(); myHorizontalSlide.toggle(); }); $(\'h_hide\').addEvent(\'click\', function(event){ event.stop(); myHorizontalSlide.hide(); $(\'horizontal_status\').set(\'text\', status[myHorizontalSlide.open]); }); $(\'h_show\').addEvent(\'click\', function(event){ event.stop(); myHorizontalSlide.show(); $(\'horizontal_status\').set(\'text\', status[myHorizontalSlide.open]); }); // When Horizontal Slide ends its transition, we check for its status // note that complete will not affect \'hide\' and \'show\' methods myHorizontalSlide.addEvent(\'complete\', function() { $(\'horizontal_status\').set(\'text\', status[myHorizontalSlide.open]); }); }); </script> Then i try to implement with this: echo '<div class="profile_top_menu">'; echo ' <h3 class="section">Horizontal</h3> <div class="marginbottom"> <a id="h_slideout" href="#">slide out</a> | <a id="h_slidein" href="#">slide in</a> | <a id="h_toggle" href="#">toggle</a> | <a id="h_hide" href="#">hide</a> | <a id="h_show" href="#">show</a> | <strong>status</strong>: <span id="horizontal_status">open</span> </div> <div id="horizontal_slide"> asdfasdfasdfasdfasdf </div> ';
  11. You could rederict them and put it in a $_GET variable. for ex: http://www.phpfreaks.com/forums/index.php?song1=Christina Aguilera:Impossible; Then on the next page you could explode the $_GET['song1'] variable at the : to get the artist and song.. Just an idea.
  12. I don't reccomend using the tags because usually you can get all browsers to work but yes you can. Put the code you want to go for ie in these tags: <!--[if IE]> <![endif]--> Put the code you want to show for any other browser: <!--[if !IE]><!--> <!--<![endif]-->
  13. maybe this will help: http://www.phpfreaks.com/forums/index.php?topic=326822.0
  14. That will order your sites randomly so you can just display the first one... $amount_get = mysql_query("SELECT id FROM users"); $query = mysql_query("SELECT site_url,username,id FROM users WHERE 1 ORDER BY RAND() LIMIT 150"); $data_grab = mysql_fetch_assoc($query); echo $data_grab['site_url']."<input type='submit'>"; }
  15. try... if(preg_match('/(\s]{0,})/', $thing_to_check)) { // GIVE THEM AN ERROR }
  16. Thanks a BUNCH for the explanation. I see your join but i am getting a little dazed on exactly what is being joined and on etc when i look at this code below: Why do you select things like a.*(assuming everything) and then b. individual stuff. Can you explain what you joined into that query and how the comment replies get the id of the actual comment. Awesome info already $query = "SELECT a.*, b.comment_date AS reply_date, b.username AS reply_name, b.comment AS reply, b.reply_id AS reply_to FROM article_comments AS a JOIN article_comments AS b ON (a.id = b.reply_id) WHERE a.article_id = '$article_to_show_id'";
  17. Try: Find: $wordlist = "sh%t:cr*p|dang:d*ng|shoot:sh**t"; Replace: $search_for_bad_words = mysql_query("SELECT * FROM badwords WHERE 1"); $seperate_text = "|"; $entry_seperate_text = ":"; while($row = mysql_fetch_array($search_for_bad_words)) { $wordlist = $wordlist.$seperate_text.$row[word].$entry_seperate_text.$row[r_word]; }
  18. Alright man, how did you do that black magic? Was there a reason my way wasn't working? It works great but i want to learn from this mistake and problem so that i don't have to ask you guys again... Would you be so kind to give me a rundown?
  19. ahh good call, here is the output: never used that a. and b. stuff so no idea. Could you provide a reference or tut on how these work? SELECT a.*, b.comment_date AS reply_date, b.username AS reply_name, b.comment AS reply, b.reply_id AS reply_to FROM article_comments AS a JOIN article_comments AS b ON (a.id = b.reply_id) WHERE article_id = '1' has an error: Column 'article_id' in where clause is ambiguous
  20. Also if you are in an echo you could just do: (are you in the same scope as well? - your array on the same page) <img src="', $cbanner ,'">
  21. woops.. do this <?php $result = mysql_query(" SELECT * FROM schedule JOIN teams ON schedule.team = teams.team_id WHERE week_id ='1'"); echo "<table width=643 border=1>\n"; echo "<th>Date</th><th>Team</th><th>Owner</th><th>Spread</th><th>Score</th><th>Bet</th><th>Cover</th><th>Points</th>"; $table_row_count = 0; while($row = mysql_fetch_array( $result )) { $i=1; if ($row['game_id']='$i') { echo "<tr><td>"; echo $row['date']; echo "</td><td>"; echo $row['team_name']; echo "</td><td>"; echo $row['owner']; echo "</td><td>"; echo $row['pt_spread']; echo "</td><td>"; echo $row['team_pts']; echo "</td><td>"; echo $row['team_bet']; echo "</td><td>"; echo $row['team_cover']; echo "</td><td>"; echo $row['owner_pts']; echo "</td></tr>"; if ($table_row_count % 2 && $table_row_count != 0) { echo ' <tr style="height: 10px"></tr> '; } $table_row_count++; } $i++; } echo "</table>"; mysql_close($con); ?>
  22. Get warning Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in on this line: while($row_comment = mysql_fetch_array($search_for_article))
  23. Okay if they are three different tables then just do this: (assuming all your info is in one table) if in three tables post back... Hope you get the concept.. // This finds all rows that have the userid as the $userid $search_for_rows = mysql_query("SELECT * FROM user WHERE userid = $userid'); while($row = mysql_fetch_array($search_for_rows)) { // here is an example not sure how to select columns with a space, so just put a _ where you have a space in the db and here... $userid = $row[userid_PK]; }
  24. Try this... <?php $result = mysql_query(" SELECT * FROM schedule JOIN teams ON schedule.team = teams.team_id WHERE week_id ='1'"); echo "<table width=643 border=1>\n"; echo "<th>Date</th><th>Team</th><th>Owner</th><th>Spread</th><th>Score</th><th>Bet</th><th>Cover</th><th>Points</th>"; $table_row_count = 0; while($row = mysql_fetch_array( $result )) { $i=1; if ($row['game_id']='$i') { echo "<tr><td>"; echo $row['date']; echo "</td><td>"; echo $row['team_name']; echo "</td><td>"; echo $row['owner']; echo "</td><td>"; echo $row['pt_spread']; echo "</td><td>"; echo $row['team_pts']; echo "</td><td>"; echo $row['team_bet']; echo "</td><td>"; echo $row['team_cover']; echo "</td><td>"; echo $row['owner_pts']; if ($table_row_count % 2 && $table_row_count != 0) { echo "</td><td>"; echo ' <br><br> '; } echo "</td></tr>"; $table_row_count++; } $i++; } echo "</table>"; mysql_close($con); ?>
  25. Should work but post back with any problems... 1) if(preg_match('/([0-9]{1,})/', $thing_to_check)) { // GOOD } else { // ERROR } 2) if(preg_match('/none/', $thing_to_check)) { // ERROR }
×
×
  • 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.