Jump to content

Jeremysr

Members
  • Posts

    199
  • Joined

  • Last visited

    Never

Everything posted by Jeremysr

  1. In the long if statement that checks to see if the fields were inputted, two of them don't have exclamation marks. ($EventImage and $Eventpopup) So the if statement returns true no matter what. So either remove those two from the if statement or add exclamation marks to them like the others.
  2. First store the whole content in a variable, I'll call it $content. Then get the first 350 characters like this: [code=php:0] for ($x = 0; $x < 350; $x++) {     $content_teaser .= $content[$x]; } [/code] Then to find the position of the last puncutation mark, use a for loop starting at the end and going backwards until it finds a puncuatation mark. [code=php:0] for ($x = len($content_teaser); $content_teaser[$x] != "." || $content_teaser[$x] != "!" || $content_teaser[$x] != "?"; $x--) {     $punctuationmark = $x; } [/code] Then finally, get all the characters up to that puncuation mark! [code=php:0] for ($x = 0; $x <= $puncuationmark; $x++) {     $content_teaser .= $content[$x]; } [/code]
  3. That's because you're using double-quotes inside of what you're echoing. Use single-quotes to echo it: [code=php:0]echo '<iframe src="http://www.game-monitor.com/server-stat.php?ip=8.6.3.213:27015&style=1&text=000000&link=0000FF&back=F2F6FC&border=8F9DB4&body=" allowtransparency="true" background-color="transparent" width="200" height="210" frameborder="0" scrolling="no"></iframe>';[/code]
  4. You could do it like this: [code=php:0] $usernames = array("someusername", "anotherusername", "another_username"); $passwords = array("firstpassword", "secondpassword", "thirdpassword"); // Then get those variables like this: // $usernames[0] will be "someusername" and $password[0] will be that persons password // $usernames[1] will be "anotherusername" and $password[1] will be that persons password...etc. // Go through a loop for all the usernames and passwords and check each one like this: // count() will get the number of variables in an array for ($x=0; $x < count($usernames); $x++) {     if ($username == $usernames[$x] && $password = $passwords[$x]) {           $loggedin = true;     } } [/code]
  5. include()? [code=php:0]include ("something.html");[/code] Or echo? [code=php:0]echo '<iframe src="http://www.game-monitor.com/server-stat.php?ip=8.6.3.213:27015&style=1&text=000000&link=0000FF&back=F2F6FC&border=8F9DB4&body=" allowtransparency="true" background-color="transparent" width="200" height="210" frameborder="0" scrolling="no"></iframe>';[/code]
  6. Um..I don't think you can do that like that...I think you need to echo it: [code=php:0]function displayLogin(){   global $logged_in;   if($logged_in){       echo "<h1>Logged In!</h1>";       echo "Welcome <b>$_SESSION[username]</b>, you are logged in. <a href=\"logout.php\">Logout</a>";   }   else{ echo '<h1>Login</h1>'; echo '<form action="" method="post">'; echo '<table align="left" border="0" cellspacing="0" cellpadding="3">'; echo '<tr><td>Username:</td><td><input type="text" name="user" maxlength="30"></td></tr>'; echo '<tr><td>Password:</td><td><input type="password" name="pass" maxlength="30"></td></tr>'; echo '<tr><td colspan="2" align="left"><input type="checkbox" name="remember">'; echo '<font size="2">Remember me next time</td></tr>'; echo '<tr><td colspan="2" align="right"><input type="submit" name="sublogin" value="Login"></td></tr>'; echo '<tr><td colspan="2" align="left"><a href="register.php">Join</a></td></tr>'; echo '</table>'; echo '</form>';   } }[/code]
  7. This doesn't really have anything to do with PHP, to do this you would use Javascript. Unfortunately I can't help you because I don't know much Javascript...but try posting this in the Javascript board which you'll find further down on the main forum page.
  8. Try this for the userExists function... [code=php:0]function userExists($to){   global $conn;   $q = "select username from users where name = $to";   $result = mysql_query($q,$conn);   return (mysql_numrows($result) > 0); }[/code] I dunno how your database is set up, so I don't know if it's "where name = $to" or "where username = $to" or whatever..
  9. Why not just check to see if the username they entered exists in the username database? That would be much easier for you and your users.
  10. Well you can change it to whatever you want, I was just explaining how to find a string inside of a string.. Jocka's looks a lot easier though, I didn't know about the substr function.
  11. You can get the current URL by using the variable $_SERVER['PHP_SELF'] Then to see if "buy-" is in the URL, you use the strstr function. Which returns true if it finds a certain string inside the string. So... [code=php:0] $url = $_SERVER['PHP_SELF']; if (strstr($url, "buy-")) {     echo ("buy- is in the url"); } else {     echo ("buy- isn't in the url"); } [/code]
  12. In some of your echo lines, you have .'s at the end right before the semi-colon. Try removing them.
  13. How are you storing the credit card details? If it's all in one string, you can do it like this: [code=php:0] $cardnumber = "1234 5678 0987 6543"; // just for an example $last_four_digits = $cardnumber[15] . $cardnumber[16] . $cardnumber[17] . $cardnumber[18]; echo ("XXXX XXXX XXXX $last_four_digits"); [/code] And in case you didn't know, $cardnumber[15] means the 15th character in that string (starting with the first character being zero)
  14. Change the input tags to this: [code=php:0]<input type="hidden" name="order_id" value="<? echo($ordid); ?>">[/code] I think that's the problem.
  15. [quote author=thorpe link=topic=104587.msg417245#msg417245 date=1155795777] Jeremysr, a simple yes / no. Do you understand the meaning of your (our) avitar? [/quote] Yes. I read the "How to be a Hacker" article and the emblem faqs. And Unholy Prayer, semi-colons signify the end of a line.
  16. I think it should work if you remove the quotes: [code=php:0]$query = db_insert(compid,title,categoryid,subcategoryid,description,locationid,skills);[/code]
  17. I don't see anything wrong with it, but it might be the line above or below line 4...I think if you missed a semi-colon on line 3 it'd say that it is an error on line 4.
  18. Use the == operator instead. [code=php:0]if ($search == $value)[/code]
  19. No I'm pretty sure this can't be done in PHP. I think you need to use Javascript, but I'm not sure how to do this.
  20. Smilies are easy: just replace :-) or whatever with an image tag. [code=php:0]str_replace(":-)", "<img src='happy.gif'>", $post_content);[/code]
  21. Change all the if($category to if($site
  22. [quote author=BillyBoB link=topic=104559.msg417180#msg417180 date=1155781902] nope that wont work ... it will not work because what if the timein is jan. (01) and the current time is nov. (11) that would give me -10 [/quote] It should work if all three variables in my example are timestamps.
  23. Just subtract the times. $time_inbetween = $current_time - $intime; Where $current_time is the current timestamp and $intime is the timestamp in the database. $timeinbetween should be a timestamp (the number of seconds between the two other timestamps) So use date() with $time_inbetween to get the number of hours/minutes/seconds/days/weeks or whatever you want.
  24. Maybe something like this? [code] <?php $people = array('a','b','c','d','e','f','g','h'); for ($x = 0; $x < 8; $x++) {     for ($y = 0; $y < 8; $y++) {           if ($x != $y) { echo ("$people[$x] $people[$y]<br />"); }     } } ?> [/code]
×
×
  • 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.