1. Post #1
    Qombat's Avatar
    August 2010
    2,383 Posts
    After going through the front page and turning every thread to 'read' state, a number of the threads are menial things that are simple fixes, or just general questions. As a result, here's the "Web Development Questions That Don't Need Their Own Thread" thread.

    What''s the point of this thread anyways?
    It's for people who are terrified of making their own threads regarding simple or 'dumb' questions, or already do make them. It's time to stop making them, and simply ask them in here.

    Don't turn this thread into a shitstorm about sanitisation, OO vs Procedural, C# vs PHP, etc. We don't care unless it is 100% relevant to the question.

    I don't actually have a question to kick this off with, unfortunately. :saddowns:
    Reply With Quote Edit / Delete Australia Show Events Useful x 8Programming King x 3Dumb x 3Agree x 2Disagree x 1 (list)

  2. Post #2
    I spent $10 on this.
    :awesome:'s Avatar
    April 2009
    5,403 Posts
    This thread could be helpful, though most users use the What Are You Working On thread.
    Reply With Quote Edit / Delete United States Show Events Agree Agree x 6 (list)

  3. Post #3
    hello.jpg
    not_Morph53's Avatar
    September 2007
    4,311 Posts
    Is it a coincidence that I like both Perl and S&M?
    Reply With Quote Edit / Delete United States Show Events

  4. Post #4
    Richy19's Avatar
    May 2010
    4,851 Posts
    Is his a kind of What Do You Need Help With thread?
    Reply With Quote Edit / Delete United Kingdom Show Events

  5. Post #5
    Qombat's Avatar
    August 2010
    2,383 Posts
    Is his a kind of What Do You Need Help With thread?
    Kinda. I took the idea from the Linux forum actually.

    Edited:

    though most users use the What Are You Working On thread.
    Hence this thread.
    Reply With Quote Edit / Delete Australia Show Events

  6. Post #6
    CJF
    PieClock's Avatar
    August 2006
    15,000 Posts
    I already posted this in the WAYWO thread but my aswell post it here too:

    Is there any way to enable good anti aliasing on header tags?
    Reply With Quote Edit / Delete United Kingdom Show Events

  7. Post #7
    Torquil's Avatar
    August 2010
    172 Posts
    I already posted this in the WAYWO thread but my aswell post it here too:

    Is there any way to enable good anti aliasing on header tags?
    Cufon.
    Reply With Quote Edit / Delete United Kingdom Show Events Friendly Friendly x 2Agree Agree x 1 (list)

  8. Post #8
    Siemens's Avatar
    October 2010
    751 Posts
    Is it a coincidence that I like both Perl and S&M?
    yes.

    perl is a beautiful language
    Reply With Quote Edit / Delete Australia Show Events

  9. Post #9
    Fabulous Vailglorous Extraordinaire
    Haxxer's Avatar
    February 2007
    10,612 Posts
    Gah, trying to make this this that's supposed to take the sum out of two inputed numbers.

    $tal1 = $_POST["val1"];
    $tal2 = $_POST["val2"];
    $a = 1;
    
    for( $a = $tal1; $a <= $tal2; $a++){
    }

    I want it to take every number between $tal1 and $tal2 and add them together, ie. 3 to 7 becomes 25.

    I'm pretty much stuck.
    Reply With Quote Edit / Delete Sweden Show Events

  10. Post #10
    Siemens's Avatar
    October 2010
    751 Posts
    Gah, trying to make this this that's supposed to take the sum out of two inputed numbers.

    $tal1 = $_POST["val1"];
    $tal2 = $_POST["val2"];
    $a = 1;
    
    for( $a = $tal1; $a <= $tal2; $a++){
    }

    I want it to take every number between $tal1 and $tal2 and add them together, ie. 3 to 7 becomes 25.

    I'm pretty much stuck.
    Really not a hard problem:

    $tal1 = intval($_POST['val1']);
    $tal2 = intval($_POST['val2']);
    $total = 0;
    
    for($i = $tal1; $i <= $tal2; $i++)
    {
        $total += $i;
    }
    
    Reply With Quote Edit / Delete Australia Show Events

  11. Post #11
    Fabulous Vailglorous Extraordinaire
    Haxxer's Avatar
    February 2007
    10,612 Posts
    Thank you, but what does intval do?
    Reply With Quote Edit / Delete Sweden Show Events

  12. Post #12
    Siemens's Avatar
    October 2010
    751 Posts
    Thank you, but what does intval do?
    http://php.net/manual/en/function.intval.php
    Reply With Quote Edit / Delete Australia Show Events

  13. Post #13
    Fabulous Vailglorous Extraordinaire
    Haxxer's Avatar
    February 2007
    10,612 Posts
    I see. I'm quite new to all this, I need to train my math mind.
    Reply With Quote Edit / Delete Sweden Show Events

  14. Post #14
    Siemens's Avatar
    October 2010
    751 Posts
    I see. I'm quite new to all this, I need to train my math mind.
    :what:
    Reply With Quote Edit / Delete Australia Show Events Dumb Dumb x 1 (list)

  15. Post #15
    The Riddler's Avatar
    October 2009
    1,195 Posts
    I see. I'm quite new to all this, I need to train my math mind.
    Query. How good are you in Algebra?
    Just wondering. As a programmer, I find beginners intriguing.
    Reply With Quote Edit / Delete United States Show Events

  16. Post #16
    Fabulous Vailglorous Extraordinaire
    Haxxer's Avatar
    February 2007
    10,612 Posts
    Query. How good are you in Algebra?
    Relatively good. Math has never been my strong side.

    Also, I meant how to think when programming, I started like a week ago or something.
    Reply With Quote Edit / Delete Sweden Show Events

  17. Post #17
    The Riddler's Avatar
    October 2009
    1,195 Posts
    Relatively good. Math has never been my strong side.

    Also, I meant how to think when programming, I started like a week ago or something.
    That's why I asked, man. Algebra is a pertinent factor when it comes to a programmer's thinking process. Not for the equations, but more for logistic purposes. It helps a lot with defining algorithms. At least, that's what a programming teacher of mine taught me.
    Am I in the right port, now?
    Reply With Quote Edit / Delete United States Show Events Agree Agree x 5 (list)

  18. Post #18
    Fabulous Vailglorous Extraordinaire
    Haxxer's Avatar
    February 2007
    10,612 Posts
    That's why I asked, man. Algebra is a pertinent factor when it comes to a programmer's thinking process. Not for the equations, but more for logistic purposes. It helps a lot with defining algorithms. At least, that's what a programming teacher of mine taught me. Am I in the right port now?
    Indeed, I just didn't know of "+=" as I didn't put it in my references for some reason
    Reply With Quote Edit / Delete Sweden Show Events

  19. Post #19
    Siemens's Avatar
    October 2010
    751 Posts
    Indeed, I just didn't know of "+=" as I didn't put it in my references for some reason
    $a += $b;
    // is the same as:
    $a = $a + $b;
    
    Reply With Quote Edit / Delete Australia Show Events

  20. Post #20
    Fabulous Vailglorous Extraordinaire
    Haxxer's Avatar
    February 2007
    10,612 Posts
    Ah, thanks
    Reply With Quote Edit / Delete Sweden Show Events

  21. Post #21
    Richy19's Avatar
    May 2010
    4,851 Posts
    Does anyone know if: when you buy something through paypal express does paypal send both the buyer and the seller a receipt email with items sold, total price & buyers address?
    Reply With Quote Edit / Delete United Kingdom Show Events

  22. Post #22
    Fabulous Vailglorous Extraordinaire
    Haxxer's Avatar
    February 2007
    10,612 Posts
    I'm sorry for my stupidity and incompetence, but I have a new problem.

    This script is for writing QCs when compiling models, and the first document is supposed to allow the user to choose the amount of frames by simple input boxes which is sent to this next one.

    This one supposed to list the number of frames and allow the user to give each frame a name, which will then be sent to the next page to be printed:

    <?php
    	
    	$frames = $_POST['frames'];
    	$framenum = 0;
    	
    	if( is_numeric($frames)){
    	
    		echo "<FORM ACTION=\"qc3.php\" METHOD=\"post\">";
    		
    		for($frames = 1; $frames <= $_POST['frames']; $frames++){
    			
    			echo "Frame " . $frames . ": <input type=\"text\" name=\"framename" . $framenum . "\" size=\"20\">";
    			$framenum++;
    			echo "<br>";
    			
    		}
    		
    	}
    	else{
    	
    		echo "That is not a number";
    	
    	}
    				
    	echo "<INPUT TYPE=\"submit\" VALUE=\"Next\">";
    	echo "</FORM>";
    		
    ?>

    How am I supposed to send all the names to the next phase?
    Reply With Quote Edit / Delete Sweden Show Events

  23. Post #23
    Gold Member
    Alcapwne's Avatar
    May 2010
    3,408 Posts
    On the login page of my site, how would I make it so that the validation etc. script is run on the login page and any errors appear on the login page as well?

    I think I have to put the validation script itself on the login page, but I don't know where exactly to put it, or what action to assign to my 'login' button.

    My homepage is currently index.html, will this have to change to .php?

    Thanks
    Reply With Quote Edit / Delete United Kingdom Show Events

  24. Post #24
    CJF
    PieClock's Avatar
    August 2006
    15,000 Posts
    I'm sure someone can tell you how to do it better with their fancy languages and stuff, but what I do is send the action of the submit button to the same page and put the validation code on the same page. It doesn't matter where it is at. One thing you might want to do is to not make it run unless it has to.

    (Put in a check to see if a variable from the form exists or not.)

    <?php
    
    if($_POST['blah']) {
    
    echo('exists');
    
    } else {
    
    echo('doesn't exist yet');
    
    }
    ?>
    
    Reply With Quote Edit / Delete United Kingdom Show Events

  25. Post #25
    Gold Member
    Alcapwne's Avatar
    May 2010
    3,408 Posts
    I'm sure someone can tell you how to do it better with their fancy languages and stuff, but what I do is send the action of the submit button to the same page and put the validation code on the same page. It doesn't matter where it is at. One thing you might want to do is to not make it run unless it has to.

    (Put in a check to see if a variable from the form exists or not.)

    <?php
    
    if($_POST['blah']) {
    
    echo('exists');
    
    } else {
    
    echo('doesn't exist yet');
    
    }
    ?>
    
    So I can send the action to a .html page? How will it know what to do?
    Reply With Quote Edit / Delete United Kingdom Show Events

  26. Post #26
    CJF
    PieClock's Avatar
    August 2006
    15,000 Posts
    So I can send the action to a .html page? How will it know what to do?
    I believe it has to be .php

    HTML works in php files.
    Reply With Quote Edit / Delete United Kingdom Show Events

  27. Post #27
    Gold Member
    nivek's Avatar
    June 2009
    3,421 Posts
    <?php
    
    if($_POST['blah']) {
    
    echo('exists');
    
    } else {
    
    echo('doesn't exist yet');
    
    }
    ?>
    

    The apostrophe in doesn't breaks that...
    Reply With Quote Edit / Delete United States Show Events Agree Agree x 2 (list)

  28. Post #28
    Gold Member
    Alcapwne's Avatar
    May 2010
    3,408 Posts
    I believe it has to be .php

    HTML works in php files.
    Great, thanks
    Reply With Quote Edit / Delete United Kingdom Show Events

  29. Post #29
    CJF
    PieClock's Avatar
    August 2006
    15,000 Posts
    The apostrophe in doesn't breaks that...
    I'm sure he'll be changing that anyway. I guess I should get out of the habit of using ' ' first. :frown:
    Reply With Quote Edit / Delete United Kingdom Show Events

  30. Post #30
    hello.jpg
    not_Morph53's Avatar
    September 2007
    4,311 Posts
    The apostrophe in doesn't breaks that...
    This is my worst habit, I forget to escape shit all the time.
    Reply With Quote Edit / Delete United States Show Events Agree Agree x 1 (list)

  31. Post #31
    Gold Member
    Alcapwne's Avatar
    May 2010
    3,408 Posts
    I'm sure someone can tell you how to do it better with their fancy languages and stuff, but what I do is send the action of the submit button to the same page and put the validation code on the same page. It doesn't matter where it is at. One thing you might want to do is to not make it run unless it has to.
    I've got that bit sorted, now I just need to get the die() error messages to appear on the index.php page rather than a white blank page. How do I do this?
    Reply With Quote Edit / Delete United Kingdom Show Events

  32. Post #32
    CJF
    PieClock's Avatar
    August 2006
    15,000 Posts
    You put the die() functions into index.php instead of the white page?

    You should be able to take the code from the "white page" and put it into index.php inside the <?php ?> tag fine and it'll work. Place it where you want the errors to show up.

    Edited:

    I'm trying to tackle something here. I'm using mysqli prepared statements. What I want to do is pass HTML and CSS into them. HTML works fine. It passes through, however if I try something like

    <p style="text-align:center;">

    it doesn't work. The paragraph will come into effect but the text align wont.
    Reply With Quote Edit / Delete United Kingdom Show Events

  33. Post #33
    Gold Member
    deadeye536's Avatar
    February 2008
    1,338 Posts
    I'm sorry for my stupidity and incompetence, but I have a new problem.

    This script is for writing QCs when compiling models, and the first document is supposed to allow the user to choose the amount of frames by simple input boxes which is sent to this next one.

    This one supposed to list the number of frames and allow the user to give each frame a name, which will then be sent to the next page to be printed:

    -phpsnip-

    How am I supposed to send all the names to the next phase?
    We were all beginners at one point, don't worry about it

    From what I can tell, you are trying to find a way for your script to know all of the different name fields that are available, correct? Something you may try is a handy trick to POST the data as an array, and cycle through that loop using foreach. You can achieve this by using a name of "whatever[]".

    For example, say you have the form;
    <form method="POST" action="action.php">
    	<input type="text" name="frame[]" size="20" value="Facepunch" />
    	<input type="text" name="frame[]" size="20" value="Blah" />
    	<input type="text" name="frame[]" size="20" value="5" />
    </form>

    This will pass the data in a way where PHP will recognize it as an array. Basically, it's the same as saying,
    $_POST['frame'] = array('Facepunch', 'Blah', '5');

    Good luck, hope this helps.

    Edited:

    I'm trying to tackle something here. I'm using mysqli prepared statements. What I want to do is pass HTML and CSS into them. HTML works fine. It passes through, however if I try something like

    <p style="text-align:center;">

    it doesn't work. The paragraph will come into effect but the text align wont.
    How does the output of that look in the browser? Are there any stray backslashes? If there are some, you might need to run a stripslashes to get rid of them.

    Edited:

    I've got that bit sorted, now I just need to get the die() error messages to appear on the index.php page rather than a white blank page. How do I do this?
    So you're trying to do something along the lines of error handling that won't break the output of your page? You could try a few things. The first is something that isn't exactly error handling, but it will display your page around the message. Basically, you can write your own function such as;
    stylishDie('Oh no! Something happened, please try again!');
    exit;
    And, simply have the function wrap your page around that.
    function stylishDie($msg) {
        echo '<!DOCTYPE html>
            ...
        <div id="message">'.$msg.'</div>
            ...
        </html>';
    }

    That is probably the simplest way of doing this, but I'm certain there are much better, more flexible ways to get this done.

    Edited:

    I'm sure he'll be changing that anyway. I guess I should get out of the habit of using ' ' first. :frown:
    Worst part is that once you start using double quotes, you'll find yourself needlessly escaping single quotes.
    Reply With Quote Edit / Delete United States Show Events Informative Informative x 1Friendly Friendly x 1 (list)

  34. Post #34
    Fabulous Vailglorous Extraordinaire
    Haxxer's Avatar
    February 2007
    10,612 Posts
    We were all beginners at one point, don't worry about it

    From what I can tell, you are trying to find a way for your script to know all of the different name fields that are available, correct? Something you may try is a handy trick to POST the data as an array, and cycle through that loop using foreach. You can achieve this by using a name of "whatever[]".

    For example, say you have the form;
    <form method="POST" action="action.php">
    	<input type="text" name="frame[]" size="20" value="Facepunch" />
    	<input type="text" name="frame[]" size="20" value="Blah" />
    	<input type="text" name="frame[]" size="20" value="5" />
    </form>

    This will pass the data in a way where PHP will recognize it as an array. Basically, it's the same as saying,
    $_POST['frame'] = array('Facepunch', 'Blah', '5');

    Good luck, hope this helps.
    How would that work when I have up to 35 different names?
    I suppose it wouldn't work to set the number of frames in the array?

    Edited:

    Basically, I have three documents.
    qc.php, which sends the number of frames to the next document, qc2.php, which uses a for-loop to print out a text box for each frame. I basically want it to send each of these text boxes' values to the next page (qc3.php) and print it out.
    Reply With Quote Edit / Delete Sweden Show Events

  35. Post #35
    Gold Member
    chrise112's Avatar
    December 2005
    153 Posts
    PHP related question, what does it mean when you see -> or => i.e
    <?php
    // code
    $this -> $something_else
    ?>
    

    Am I correct to asume it's along the lines of and?
    Reply With Quote Edit / Delete Australia Show Events Dumb Dumb x 1 (list)

  36. Post #36
    Pocoyo's Avatar
    June 2009
    383 Posts
    Also, can someone give a quick explanation when to use ' and when to use "?
    Reply With Quote Edit / Delete Singapore Show Events

  37. Post #37
    Gold Member
    Alcapwne's Avatar
    May 2010
    3,408 Posts
    For some reason, my login cookie isn't being added :( Here is the cookie add code:

     <?php
    $_POST['username'] = stripslashes($_POST['username']); 
     	 $hour = time() + 3600; 
     setcookie("user", $_POST['username'], $hour); 
     setcookie("pass", $_POST['password'], $hour);	 
    ?>
    

    Everything before it works okay, and everything after it, because it redirects to the member's area but then the member's area sends you back to the login screen because there's no login cookie stored.

    What do?

    Also, does this code check whether a cookie exists correctly?

    		if (!$_COOKIE["user"] | !$_COOKIE["pass"])
    			{			echo '<meta http-equiv="refresh" content="0;http://clickphilia.leadhoster.com/index.php" />';
    						die('No cookie. Redirecting to login page...');
    
    Reply With Quote Edit / Delete United Kingdom Show Events

  38. Post #38
    Siemens's Avatar
    October 2010
    751 Posts
    PHP related question, what does it mean when you see -> or => i.e
    <?php
    // code
    $this -> $something_else
    ?>
    

    Am I correct to asume it's along the lines of and?
    -> is object access, eg:

    $myobj = new myClass;
    echo $myobj->myMember;
    

    => is for doing key/value shut, like when defining an associative array:

    $myarr = array( one => 1, two => 2 );
    echo $myarr['one']; // prints '1'
    

    It can also be used in a foreach loop to get each key and value in an associative array:

    foreach($myarr as $k=>$v)
    {
        echo $k . ': ' . $v . '\n';
    }
    /*
    one: 1
    two: 2
    */
    
    Reply With Quote Edit / Delete Australia Show Events

  39. Post #39
    Gold Member
    andersonmat's Avatar
    May 2008
    2,521 Posts
    Also, can someone give a quick explanation when to use ' and when to use "?
    PHP evaluates anything inside " ". If you use ' ' it will be plain text with no inside evaluation.

    (Technically, the first quotes would be a string, and the second a char but PHP lives in its own fantasy world of what's "correct".)
    Reply With Quote Edit / Delete United States Show Events

  40. Post #40
    CJF
    PieClock's Avatar
    August 2006
    15,000 Posts
    How does the output of that look in the browser? Are there any stray backslashes? If there are some, you might need to run a stripslashes to get rid of them.
    Hmm. Yes, in the source code there are slashes. I guess that was the problem, thanks.

    Yup, works great now.
    Reply With Quote Edit / Delete United Kingdom Show Events