Jump to content
Larry Ullman's Book Forums

Andy Fang

Members
  • Posts

    19
  • Joined

  • Last visited

Posts posted by Andy Fang

  1. 1. Open the file using fopen() (Check for a GET request from the form you have a button in)

    2. Read through the file and assign it to an array

    3. Pop the last (or first, but that'll be slower) element from the array

    4. Use the email() function to send it where it should

    5. Write the array back to the file

    6. Close the file

     

    Search for how to handle these problems, and you should be able to make it work quite quickly.

     

    The problem is I don't know how to automatically assign the username:password an array and mail them in a rotating order (first time is the first line, second time mails second line, etc.

  2. Alright, I changed the code to this:

    <p/>
    <p/>
    <p/>
    <p/>
    <p/>
    <?php $membersf = array('andy80','affiliatescraper','BHWbots','AWMarketBot','Jennifer50','seomaster','botwork','promo_guy');
    
    $membersf1 = array('seoworld1','Illuminous','socialmediadude','fiverrnuker','botmarket','automationallday');
    $membersf2 = array ('tonial','WillR','Tony Cheng','theSE0','SEOnukeX','Domination King','Nochloss5331','martino1','jasonj','torzilla','vpnnpv');
    
    
    ?>
    
    
    
    <div class="footer">
      <div class="footer_resize">
        
    	<table><tr><th>Members Active within Last 30 Minutes (<?php echo mt_rand(11, 35); ?> PRO and <?php echo mt_rand(20, 51); ?> guests)</th></tr></table><table><tr><td><font color="purple"><b>Stev</b></font>, <?php echo $membersf[array_rand($membersf)]; ?>, <?php echo $membersf[array_rand($membersf]; ?>, <?php echo $membersf[array_rand($membersf)]; ?>, <?php echo $membersf[array_rand($membersf)]; ?>, <?php echo $membersf[array_rand($membersf)]; ?>, <?php echo $membersf[array_rand($membersf)]; ?>...</td></tr></table>	<br><br>
    	<center>
    	© <?php echo date("Y") ?><a href="http://marketbot.net">MarketBot Niche Finder and Affiliate Marketing Software</a> All Rights Reserved.</a>
    	
    	</center>
    	<br>
    	
        <div class="clr"></div>
      </div>
      <div class="clr"></div>
    </div>
    <script>
    	function downloadJSAtOnload() {
    		var element = document.createElement("script");
    		element.src = "js/full.js";
    		document.body.appendChild(element);
    	}
    	if (window.addEventListener)
    		window.addEventListener("load", downloadJSAtOnload, false);
    	else if (window.attachEvent)
    		window.attachEvent("onload", downloadJSAtOnload);
    	else window.onload = downloadJSAtOnload;
    </script>
    <!--[if IE 6]>
    <script type='text/javascript' src='js/dd_belated_png.js'></script>
    <script>DD_belatedPNG.fix('.ie6fix');</script>
    <![endif]-->
    
    </body>
    </html>
    
    <body>
    </html>
    

    And am getting this error: 

     

     

    Parse error: syntax error, unexpected ']' in /home1/vpnmoz/public_html/footer.php on line 19
  3. You have a parse error on line 9. Specifically, you've got a whole lot of text there (i.e., strings) that aren't quoted. 

     

    Hey Larry,

     

    I quoted the strings in the array like so:

    <p/>
    <p/>
    <p/>
    <p/>
    <p/>
    <?php $membersf = array('andy80','affiliatescraper','BHWbots','AWMarketBot','Jennifer50','seomaster','botwork','promo_guy');
    
    <?php $membersf = array('andy80','affiliatescraper','BHWbots','AWMarketBot','Jennifer50','seomaster','botwork','promo_guy');
    
    
    
    ?>
    
    
    
    <div class="footer">
      <div class="footer_resize">
        
    	<table><tr><th>Members Active within Last 30 Minutes (<?php echo mt_rand(11, 35); ?> PRO and <?php echo mt_rand(20, 51); ?> guests)</th></tr></table><table><tr><td><font color="purple"><b>Stev</b></font>, <?php echo $membersf[array_rand($membersf)]; ?>, <?php echo $membersf[array_rand($membersf]; ?>, <?php echo $membersf[array_rand($membersf)]; ?>, <?php echo $membersf[array_rand($membersf)]; ?>, <?php echo $membersf[array_rand($membersf)]; ?>, <?php echo $membersf[array_rand($membersf)]; ?>...</td></tr></table>	<br><br>
    	<center>
    	© <?php echo date("Y") ?><a href="http://marketbot.net">MarketBot Niche Finder and Affiliate Marketing Software</a> All Rights Reserved.</a>
    	
    	</center>
    	<br>
    	
        <div class="clr"></div>
      </div>
      <div class="clr"></div>
    </div>
    <script>
    	function downloadJSAtOnload() {
    		var element = document.createElement("script");
    		element.src = "js/full.js";
    		document.body.appendChild(element);
    	}
    	if (window.addEventListener)
    		window.addEventListener("load", downloadJSAtOnload, false);
    	else if (window.attachEvent)
    		window.attachEvent("onload", downloadJSAtOnload);
    	else window.onload = downloadJSAtOnload;
    </script>
    <!--[if IE 6]>
    <script type='text/javascript' src='js/dd_belated_png.js'></script>
    <script>DD_belatedPNG.fix('.ie6fix');</script>
    <![endif]-->
    
    </body>
    </html>
    
    <body>
    </html>
    

    But I'm still getting the error.

  4. Hello Larry,

     

    I'm getting this error at my footer.php file here. Basically I try to delete the code happening in line 9, then it says it's happening somewhere else. I delete that part as well, and it says it's happening somewhere else.

     

    This is driving me crazy. What do I have to do? I basically want to echo a random string from an array of hundreds of usernames as seen below. I've tried echoing from just $membersf, and it worked just fine. Then when I added a few more strings to the array, suddenly it stopped working. So I split the array up into 3 arrays, and still no luck. What do I do to make this work?

    <p/>
    <p/>
    <p/>
    <p/>
    <p/>
    <?php $membersf = array(andy80,affiliatescraper,BHWbots,AWMarketBot,Jennifer50,seomaster,botwork,promo_guy);
    
    $membersf1 = array(seoworld1,Illuminous,socialmediadude,fiverrnuker,botmarket,automationallday);
    $membersf2 = array (tonial,WillR,Tony Cheng,theSE0,SEOnukeX,Domination King,Nochloss5331,martino1,jasonj,torzilla,vpnnpv);
    
    
    ?>
    
    
    
    <div class="footer">
      <div class="footer_resize">
        
    	<table><tr><th>Members Active within Last 30 Minutes (<?php echo mt_rand(11, 35); ?> PRO and <?php echo mt_rand(20, 51); ?> guests)</th></tr></table><table><tr><td><font color="purple"><b>Stev</b></font>, <?php echo $membersf[array_rand($membersf)]; ?>, <?php echo $membersf[array_rand($membersf]; ?>, <?php echo $membersf[array_rand($membersf)]; ?>, <?php echo $membersf[array_rand($membersf)]; ?>, <?php echo $membersf[array_rand($membersf)]; ?>, <?php echo $membersf[array_rand($membersf)]; ?>...</td></tr></table>	<br><br>
    	<center>
    	© <?php echo date("Y") ?><a href="http://marketbot.net">MarketBot Niche Finder and Affiliate Marketing Software</a> All Rights Reserved.</a>
    	
    	</center>
    	<br>
    	
        <div class="clr"></div>
      </div>
      <div class="clr"></div>
    </div>
    <script>
    	function downloadJSAtOnload() {
    		var element = document.createElement("script");
    		element.src = "js/full.js";
    		document.body.appendChild(element);
    	}
    	if (window.addEventListener)
    		window.addEventListener("load", downloadJSAtOnload, false);
    	else if (window.attachEvent)
    		window.attachEvent("onload", downloadJSAtOnload);
    	else window.onload = downloadJSAtOnload;
    </script>
    <!--[if IE 6]>
    <script type='text/javascript' src='js/dd_belated_png.js'></script>
    <script>DD_belatedPNG.fix('.ie6fix');</script>
    <![endif]-->
    
    </body>
    </html>
    
    <body>
    </html>
    
    
  5. Hello LU,

     

    My website is botproducts.net. The problem I'm having is that I want to include the header file located at 

    http://botproducts.net/leagueoflegends/header.php
    

    however I get this error:

     

     

    PHP Error Message

    Warning: include() [function.include]: Failed opening '/leagueoflegends/header.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/a2456912/public_html/leagueoflegends/index.htmlon line 3

     

    and also the code I'm using is include ('leagueoflegends/header.php');

  6. Hey there,

     

    How do I create a very simple CMS that basically does the following things:

     

    1. Creates a page as a .php script by accessing the page domain.com/create
    2. Creates the page using a notepad++ like editor (with colored syntax)
    3. Everytime a page is created, there will be a header include and footer include so you don't have to put HTML tags or specify a CSS every time.
    4. Possible to make instant preview?

    So basically, how do I do this?

  7. Well, the script I provided was a very basic starter script that you can build off of.

    All the script does is grab a string of data from the API based on the entered user name and then displayed that string.

    To make the string data more readable, I also split the string on newlines, and displayed the resulting array as well.

     

    You will probably have to reference the API documentation on the game site, but somewhere, there should be an explanation of what all the values in the API response string mean.

     

    Once you know what value(s) you want, simply use the explode function (or whatever) to split the string on newlines (and maybe commas too) and then grab the value you need from the resulting array.

     

    Does that make sense?

     

    I'm sorry but I still don't understand. Could you give me an example which does the following:

     

    1. User enters username
    2. PHP will automatically search the API for the skill levels for that username
    3. How will I reference that number exactly? For instance, the 10th number

    Thanks!

  8. Hmm, so I'm a little bit confused.

     

    With the code you provided me, I placed at the very top of the script. What I want to do is allow users to enter their username and have the script calculate instantly once the user hits enter or clicks elsewhere the text box. I'm not very familiar with the other functions but what variables do I use to define the script?

     

    For instance how would I use the Defence Level of a player, with something like:

    $def = #defence level of player, grabbed from the API.
    

    How would I be able to grab let's say, the 10th number separated by commas?

     

    Basically I need to know the values of the levels in order to add formulas to them and make a calculator. I'm sure the script knows, but I don't!

     

    Thanks!

  9. Hey Larry,

     

    I've just started with PHP and have tried learning with a few books (Missing Manual, Dummies, etc) and yours was by far the easiest/ straight forward to understand.

     

    That said I would like to practise my PHP skills by starting this project:

     

    Basically it's a calculator for a game called RuneScape, and what it will do is calculate the chances of you winning against a match to another opponent, through their skill levels such as Attack, Strength and Defence. The game has their own API that allows you to search any player's skill levels on the High Scores here:

     

    http://services.runescape.com/m=hiscore_oldschool/index_lite.ws?player=magmoz

    (Replace "magmoz" with any player").

     

    Basically I want users to be able to enter their username, hit a button and a variable will store the data. Then enter their opponent's username, hit a button and the variable will store their data. The script will then use both data to calculate the chances of winning.

     

    The issue is I don't understand how to grab the data from the API, onto my script. I also hope to calculate the results without reloading the page. An example of this is here:

     

    http://www.tip.it/runescape/pages/view/combat_calc.htm

    (Just type "torzilla" and hit enter or click anywhere on the screen and it will automatically store the data and calculate the results. Change any of the skill levels, and it will calculate it once again).

     

    This is a project I am dedicated to learn, please help me with this, it'd be a lifesaver!

     

    Thanks!

  10.  

    You need parentheses as well.

    Also, is the page you're putting the include function call in at the root of your domain. If so, the following should work:

    include ('script/header.html');

     

    Wow, thanks for that. It's half working now. It seems the CSS is broken now.

    Warning: include(/script/header.html) [function.include]: failed to open stream: No such file or directory in /home4/andyfang/public_html/script/index.php on line 3
    
    Warning: include() [function.include]: Failed opening '/script/header.html' for inclusion (include_path='.:/opt/php53/lib/php') in /home4/andyfang/public_html/script/index.php on line 3
    
  11. Hey there,

     

    First off I'd like to say this book blows my mind. It's so easy to follow through! 10/10 would recommend.

     

    Now my issue is that I want to use the include ( ) function to include an HTML template. After having this PHP:

    <?php
    $page_title = 'Scripts by the Magmoz Community';
    include (/header.html);
    ?>
    
    
    
    <!-- content starts
    ================================================== -->
    <section id="content" class="clearfix"> 
      
      <!--slider-bg starts-->
      <div id="slider-bg">
        <div class="container">
          <div class="row content-top"> 
            
            <!--slides starts-->
            <div class="span12">
              <div id="slider" class="flexslider">
                <ul class="slides">
                  
                  <!--slide one starts-->
                  <li>
                    <div class="row">
                      <div class="span6">
                        <h2>Promise to create <br/>
                          unique experiences for web and mobile</h2>
                        <p>Autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum qui blandit praesent feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. </p>
                      </div>
                      <div class="span6"> <img src="img/preview/tab-slide1.png" alt="slide"/> </div>
                    </div>
                  </li>
                  <!--slide one ends--> 
                  
                  <!--slide two starts-->
                  <li>
                    <div class="row">
                      <div class="span6">
                        <h2>Responsive interface <br/>
                          became necessity for various devices</h2>
                        <p> Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui zzril delenit quam littera qui blandit praesent augue duis dolore te feugait nulla facilisi. </p>
                      </div>
                      <div class="span6"> <img src="img/preview/tab-slide2.png" alt="slide"/> </div>
                    </div>
                  </li>
                  <!--slide two ends--> 
                  
                  <!--slide three starts-->
                  <li>
                    <div class="row">
                      <div class="span6">
                        <h2>Easy to edit & <br/>
                          customize templates for web and mobile</h2>
                        <p>Autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril in iis qui facit eorum delenit augue duis dolore te feugait nulla facilisi. </p>
                      </div>
                      <div class="span6"> <img src="img/preview/tab-slide3.png" alt="slide"/> </div>
                    </div>
                  </li>
                  <!--slide three ends--> 
                  
                  <!--slide four starts-->
                  <li>
                    <div class="row">
                      <div class="span6">
                        <h2>Awesome creativity<br/>
                          & passion to develop apps for mobile devices</h2>
                        <p> Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui qui blandit praesent zzril gothica delenit augue duis dolore te feugait nulla facilisi. </p>
                      </div>
                      <div class="span6"> <img src="img/preview/tab-slide4.png" alt="slide"/> </div>
                    </div>
                  </li>
                  <!--slide four ends--> 
                  
                  <!--slide five starts-->
                  <li>
                    <div class="row">
                      <div class="span6">
                        <h2>Our cloud thinking <br/>
                          process creates unlimited possibilities</h2>
                        <p>Autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te qui blandit praesent feugait nulla facilisi. </p>
                      </div>
                      <div class="span6"> <img src="img/preview/tab-slide5.png" alt="slide"/> </div>
                    </div>
                  </li>
                  <!--slide five ends-->
                  
                </ul>
              </div>
            </div>
            
            <!--slides ends--> 
            
            <!--thumbnails starts-->
            <div class="span12">
              <div id="thumb-slider" class="flexslider">
                <ul class="slides">
                  <li>
                    <div class="thumb-text clearfix"><img src="img/icons/slider-tab-icon1.png" width="64" height="64" alt="icon">
                      <p>Awesome web templates</p>
                    </div>
                  </li>
                  <li>
                    <div class="thumb-text clearfix"><img src="img/icons/slider-tab-icon2.png" width="64" height="64" alt="icon">
                      <p>Responsive layout</p>
                    </div>
                  </li>
                  <li>
                    <div class="thumb-text clearfix"><img src="img/icons/slider-tab-icon3.png" width="64" height="64" alt="icon">
                      <p>Easy to customize </p>
                    </div>
                  </li>
                  <li>
                    <div class="thumb-text clearfix"><img src="img/icons/slider-tab-icon4.png" width="64" height="64" alt="icon">
                      <p>State of art design</p>
                    </div>
                  </li>
                  <li>
                    <div class="thumb-text clearfix"><img src="img/icons/slider-tab-icon5.png" width="64" height="64" alt="icon">
                      <p>Infinite modules</p>
                    </div>
                  </li>
                </ul>
              </div>
            </div>
            <!--thumbnails ends--> 
            
          </div>
        </div>
      </div>
      <!--slider-bg ends-->
      
      <div class="container"> 
        
        <!--features starts-->
        <div class="row">
          <div class="span12">
            <h1>Unique experiences for <span class="color">web</span> & <span class="color">mobile</span></h1>
            <ul class="list-3col text-center">
              <li>
                <div class="icon-bg"><img src="img/icons/icon1-iphone.png" width="120" height="120" alt="icon"></div>
                <h2>Responsive</h2>
                Duis autem vel eum iriure qui  dolor est etiam in velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros. </li>
              <li>
                <div class="icon-bg"><img src="img/icons/icon1-leaf.png" width="120" height="120" alt="icon"></div>
                <h2>Customizable</h2>
                Autem vel eum praesent dolor in hendrerit in vulputate velit esse molestie consequat, at vero vel blandit illum dolore eu feugiat nulla.</li>
              <li>
                <div class="icon-bg"><img src="img/icons/icon1-create.png" width="120" height="120" alt="icon"></div>
                <h2>Documented</h2>
                Eodem modo typi qui nunc nobis videntur parum clari, fiant sollemnes  est ad minim usus  liber tempor option legentis in futurum.</li>
            </ul>
          </div>
        </div>
        <!--features ends--> 
        
        <!--spacer here-->
        <div class="spacer-40px"></div>
        
        <!--carousel starts-->
        <div class="row">
          <div class="span12"> 
            
            <!--icon and heading-->
            
            <h4 class="heading-icon clearfix"><img src="img/icons/heading-icon-1.png" width="40" height="40" alt="icon" class="icon-small-bg"> Features at a glance</h4>
            
            <!--carousel list starts-->
            <div id="carousel" class="es-carousel-wrapper">
              <div class="es-carousel">
                <ul>
                  <li>
                    <div class="folio-thumb"><img src="img/preview/thumb-1.jpg" alt="image" /> <a href="img/preview/thumb-1.jpg" data-rel="prettyPhoto[gallery1]" title="This is title of Image" class="icon-zoom"></a></div>
                    <h5>Easy to use lorem interface</h5>
                    <p>Autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum assum dolore eu feugiat nulla.</p>
                  </li>
                  <li>
                    <div class="folio-thumb"><img src="img/preview/thumb-2.jpg" alt="image" /> <a href="img/preview/thumb-2.jpg" data-rel="prettyPhoto[gallery1]" title="This is title of Image" class="icon-zoom"></a></div>
                    <h5>Cost effective ipsum amet</h5>
                    <p>Typi non habent vero claritatem insitam usus legentis in iis qui facit eorum volutpat est legere lius quod ullamcorper legentis legunt. </p>
                  </li>
                  <li>
                    <div class="folio-thumb"><img src="img/preview/thumb-3.jpg" alt="image" /> <a href="img/preview/thumb-3.jpg" data-rel="prettyPhoto[gallery1]" title="This is title of Image" class="icon-zoom"></a></div>
                    <h5>Clean layout for lorem</h5>
                    <p>Duis autem vel eum iriure dolor in congue velit hendrerit in vulputate velit esse dolore eu feugiat nulla facilisis at vero  congue nihil.</p>
                  </li>
                  <li>
                    <div class="folio-thumb"><img src="img/preview/thumb-4.jpg" alt="image" /> <a href="img/preview/thumb-4.jpg" data-rel="prettyPhoto[gallery1]" title="This is title of Image" class="icon-zoom"></a></div>
                    <h5>24x7 support on sit amet</h5>
                    <p>Autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum assum dolore eu feugiat nulla.</p>
                  </li>
                  <li>
                    <div class="folio-thumb"><img src="img/preview/thumb-5.jpg" alt="image" /> <a href="img/preview/thumb-5.jpg" data-rel="prettyPhoto[gallery1]" title="This is title of Image" class="icon-zoom"></a></div>
                    <h5>Instant updation sit</h5>
                    <p>Typi non habent vero claritatem insitam usus legentis in iis qui facit eorum volutpat est legere lius quod ullamcorper legentis legunt. </p>
                  </li>
                  <li>
                    <div class="folio-thumb"><img src="img/preview/thumb-6.jpg" alt="image" /> <a href="img/preview/thumb-6.jpg" data-rel="prettyPhoto[gallery1]" title="This is title of Image" class="icon-zoom"></a></div>
                    <h5>Visually appealing dolor</h5>
                    <p>Duis autem vel eum iriure dolor in congue velit hendrerit in vulputate velit esse dolore eu feugiat nulla facilisis at vero  congue nihil.</p>
                  </li>
                </ul>
              </div>
            </div>
            <!--carousel list ends--> 
            
          </div>
        </div>
        <!--carousel ends--> 
        
        <!--spacer here-->
        <div class="spacer-40px"></div>
        
        <!--row starts-->
        <div class="row"> 
          
          <!--column one starts-->
          <div class="span6">
            <h4 class="heading-icon clearfix"><img src="img/icons/heading-icon-2.png" width="40" height="40" alt="icon" class="icon-small-bg"> Very powerful options built right in</h4>
            <p>Autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel sequitur mutationem illum dolore eu feugiat nulla.</p>
            
            <!--two column list (nested columns) starts-->
            <div class="row">
              <ul class="span3 list-checkmark">
                <li>Easy to use lorem interface</li>
                <li>Cost effective ipsum amet </li>
                <li>Clean layout for lorem</li>
              </ul>
              <ul class="span3 list-checkmark">
                <li>24x7 support on sit amet</li>
                <li>Instant updation sit</li>
                <li>Visually appealing dolor</li>
              </ul>
            </div>
            <!--two column list starts--> 
            
            <a href="#">Learn more »</a> </div>
          <!--column one ends--> 
          
          <!--column two starts-->
          <div class="span6"> <img src="img/preview/img-window.png" alt="image"> </div>
          <!--column two ends--> 
          
        </div>
        <!--row ends--> 
        
        <!--spacer here-->
        <div class="spacer-30px"></div>
        
        <!--box starts-->
        <div class="row">
          <div class="span12">
            <div class="dark-box">
              <h1><span class="color">Get started</span> today with a free trial!</h1>
              <ul class="list-separator">
                <li>14 days free trial <span class="separator">|</span></li>
                <li> No credit card required <span class="separator">|</span> </li>
                <li> <span class="color">$10/mo</span> after end of trial period</li>
              </ul>
              <a href="#" class="mybtn">Download</a> </div>
          </div>
        </div>
        <!--box ends--> 
        
      </div>
    </section>
    <!-- content ends
    ================================================== --> 
    
    
    
    
    
    
    
    
    <?php
    include (/footer.html);
    ?>
    

    http://script.magmoz.org to know what I'm talking about.

     

    What can I do to fix this?

     

    Thanks!

     

×
×
  • Create New...