Jump to content

ChemicalBliss

Members
  • Posts

    719
  • Joined

  • Last visited

    Never

Everything posted by ChemicalBliss

  1. If you believe the code is correct and *should* work, which tbh it should, i would reccommend (if your using the latest version of PHP 5), to submit a bug report on php.net. Just a quick question, is it only on that specific machine it wont work? Have you tried it on other similar platforms? -CB-
  2. Im not stalking you andy i swear . But you can use a native mysql function to count the number of rows: SELECT count(*) FROM `table` WHERE `County`='Essex' eg: <?php // Connect $query = "SELECT count(*) FROM `table` WHERE `County`='Essex'"; $result = mysql_query($query) or die(mysql_error()); $number = mysql_result($result,0,0); echo($number); ?> -CB-
  3. Yours is bigger than mine.. lol . I dont mind whos he uses, stuff like this refines code and makes it quicker so please dont be put-out by my reposting new code. If you can make a better code set please do ill use it in my code, please dont feel im looking to be the best respected helper or w/e i really dont care . And i do the same as you (start typing and post anyway when someone beats me to it) . peace, -CB-
  4. ok, first, save the whole query into a variable and Then use the variable in mysql_query(). Then you can echo the Query with executing the statement (to make sure its what you expect). Also you can add an "Or Die()" Clause to the end of your query function: $query = "INSERT INTO table (fieldone, fieldtwo, fieldthree, fieldfour, fieldfive, fieldsix, fieldseven, fieldeight, fieldnine) VALUES('$fieldone', '$fieldtwo', '$fieldthree', '$fieldfour', '$fieldfive', '$fieldsix', '$fieldseven', '$fieldeight', '$fieldnine')"; echo($query); mysql_query($query) or die(mysql_error()); try that . -CB-
  5. lol, fair play for writing so much, but the only difference between my code and yours is yours checks wether it needs to be exploded (wether it has spaces). Oh and you wrote a decode function . Heres mine, encode and decode in one function. <?php $somestring = "Hello World, This will be encoded, then decoded."; function Encode_Decode($var,$type="encode"){ $words = explode(" ",$var); // Put words into an array (no spaces) // Loop each word and encode it for($i=0;$i<count($words);$i++){ $words[$i] = ($type == "decode")? base64_decode($words[$i]) : base64_decode($words[$i]); } return implode(" ",$words); // Return with spaces } $encoded = Encode_Decode($somestring); echo($encoded."<br />"); echo(Encode_Decode($encoded,"decode")); ?> -CB-
  6. Aside from writing your own encode/decode function (easier than what it sound but beyond the time scope i have right now), you could just encode each word seperately. <?php $somestring = "Hello World, This will be encoded"; function encodewithspaces($var){ $words = explode(" ",$var); // Put words into an array (no spaces) // Loop each word and encode it for($i=0;$i<count($words);$i++){ $words[$i] = base64_encode($words[$i]); } return implode(" ",$words); // Return with spaces } echo(encodewithspaces($somestring)); ?> hope this helps, -CB-
  7. Yup, my method is too loop through the array and check it manually one by one: Theory = Start Array with Duplicates Create new array (for this purpose ill name it "NewArray"). Loop through each item of Start Array, and add it to NewArray as long as it doesnt exist. Then your left with a new array. An Example: (UNTESTED) <?php $Array = array( "someemail@test.com", "email@test.com", "test@email.com", "someemail@test.com", "test@someemail.com" ); $nArray = array(); for($i=0;$i<count($Array);$i++){ if(!isset($nArray[$Array[$i]])){ $nArray[$Array[$i]] = count($nArray) - 1; } } $nArray = array_flip($nArray); ?> Hope this helps, -CB-
  8. A possible debug step to check the file integrity: Make a new file. with the same condition statement, on its own. See if it works. If the new file on its own works you know its something to do with the file your using. Hope this helps, -CB- PS, I have had issues of Windows-to-UNIX ports of Native windows text, essentiually the EOL characters used are different, and can create all sorts of unknown errors. Make sure your files EOL characters are UNIX standard \n (You can use Notepad++ to check and convert the files if necessary).
  9. Forget that lol use this easy fix: echo date('l jS \of F Y h:i:s A',time()-10800); // 10800 = 3 hours in seconds. -CB-
  10. You are storing images inside a database? This is not an answer to your question, rather a solution: Dont use databases to store images, they can become corrupt and it is definitely slower, and more cumbersome than using native file storage. It may seem "cool" to put images into a database but trust me its not worth the hassle. -CB-
  11. There are functions that can do this for you also if you google it, http://lmgtfy.com/?q=How+to+force+file+download+with+php -CB-
  12. Maybe this will help, take notice of the formatting and the comments (will tell you what ive changed). <h2>Log in</h2><br> <?php if ($_POST['login']) { // echo "hello"; // a test echo? //connect mysql_connect('localhost','forum','forum') or die(mysql_error()); // mysql_error() tells u what mysql actually says. mysql_select_db('phpbb') or die(mysql_error()); //include functions.php phpbb script require 'forum/includes/functions.php'; //get form data $username = strtolower($_POST['username']); // You dont need all this sanitization, you are not displaying what they type, you are checking it. $password = $_POST['password']; if (!$username || !$password){ echo "Please enter a username and password<p />"; }else{ //find username //username_clean ? just use the actual username they used to signup with, making variable usernames just adds headaches. $find = mysql_query("SELECT * FROM phpbb_users WHERE username='".mysql_real_escape_string($username)."'") or die(mysql_error()); if (mysql_num_rows($find) == 0){ echo "Username not found<p />"; }else{ // Easier way to get one column of data: $password_hash = mysql_result($find_row,0,'user_password'); /* while($find_row = mysql_fetch_assoc($find)) { // grab password hash for user $password_hash = $find_row['user_password']; } */ $check = phpbb_check_hash($password, $password_hash); if ($check == FALSE){ echo "Incorrect password<p />"; }else if ($check==TRUE){ $_SESSION['username'] = $username; header("Location: index.php"); exit(); } } } }else{ // Added Else, Only show this part if they are not trying to login. if (isset($_SESSION['username'])){ echo Welcome; }else{ echo '<form action="index.php" method="POST"> <input type="text" name="username" size=18> <br><input type="password" name="password" size=18> <br><input type="submit" name="login" value"Log in" size=10>'; } } ?>
  13. Oni-Kun. I have no idea what you mean when you ask, and then quoting my code? You never mentioned isset()? And you are wrong, no, Booleans are True/False, wether a variable is set or not is entirely different, a variable with no data can return false. Thus, in fact, the only way to check if a variable exists (post data with no data), use isset(), as i said before. Would like to know .. what are you on about? -------------- Jason; Maybe you need to rethink the general structure of your script. It should be something like: If(Session Exists){ // Continue to load page normally }else{ // Show log in page } To make it easier to understand you can use a function checkbbsession() that you make yourself that will check wether the person is logged in or not. and should return true or false respectively. You should also indent your code to make it easier to read and debug mistakes. Also, Oni-Kun, the Session if statement is already outside of the POST check statement? -CB- -CB-
  14. I wonder if he gave this result from my answer or yours, shame when people miss the information they need, anyway if your listening .. This just doesnt make sense, It means both arrays (SESSION and POST) are empty and that some other array is populated with what you want, but you dint echo or print any other array, so youve either typed the result in your self incorrectly or you echoed something else. Assuming the variables shown are found in the POST array: as i said before, use: if(isset($_POST['login'])) (check wether its set), i beleive the default behaviour for if($variable) checks wether $variable is true or false (or 0 or 1 etc). Also, the SESSION variable is empty, what is it supposed to have? phpBB's sessions? use print_r($_SESSION) on a phpBB file somewhere and check the sessions (what they are meant to be), then you can work out what you can do to keep them from page to page. -CB-
  15. With sending a verifiable email to that specific email address, there is no way of knowing if it truly exists unless you have access to the Database that contains the names configured for that domain. The Domain however you can check quite thoroughly. You can use a WHOIS (id reccomend using a specialized Class). or you can just ckeck if it exists by asking for an ip address (one simple function does this in PHP). -CB-
  16. Check the POST data: var_dump($_POST); at the top. Same with sessions. Should give you an idea why its not working. Also, i suggest using if(isset($_POST['login'])) .. Will remove any notice errors. Hope this helps you, -CB-
  17. Hmm, quick google revealed 1 solution, i will quote for you: By" Justin Koivisto" And some more detailed information by "denisb": Hope this helps, -CB-
  18. I havnt looked at the attachment to be perfectly honest i cba with downloading an attachment, i would reccomend posting it inline (i know you tried to make ur post neat and tidy, but sometimes content is key ). Though i am a realy lazy monkey . Anyway, You have either; 1) a Typo (Column name misspelled or incorrect Case, or column data mispelled or incorrect Case). 2) SQL Error, Either the data doesnt exist, or MySQL cannot evaluate a result set because there is an error in your SQL. To fix/debug: 1) echo $id before the query, to make sure it is what it's supposed to be. 2) echo the query to make sure its exactly what you expect/want. 3) Try the query in PHP My Admin (a Free MySQL Administration Interface). 4) Make sure the result set comes back clean and how you expect. print_r(mysql_fetch_assoc($result)); should suffice. 5) Make sure you are handling the data correctly, make sure you havnt changed the display code or anything else that could affect it. Good Luck, -CB-
  19. Hmm, it is relatively easy, as long as your text file conforms to certain formatting rules. You will need a rule to seperate each variable, either by a new line, or by a specific unique character. An Example Text File: MyContent = This is some interesting text, with no "newlines". MyContent2 = For example, This variable will only result in this line being displayed, This line will be ignored. You can also enclose strings in quotes or other special characters that wont be used inside the actual string, or even another way is to encode the string into hexadecimal characters (No special chars will be shown, even newlines should turn into a number or character). ---- By far though, the easiest, is to use and inline include file written in php: <?php $MyContent = "..."; ?> -- So, your first step is to figure out the formatting you need to work with (if your given the text files), or create some formatting (if you made the text-files), or go a much easier and quicker route of inline PHP (if you dont need them to be actual text files). -CB-
  20. You have it in there but your not using it for some reason: $equation2 . use $equation2 += .... instead of $originalcash2 += ... then just change the variable in the number_format function. -CB-
  21. $result = mysql_query($sql); Echo the $sql before the query, make sure it is exactly what it is supposed to be, make sure it works in phpmyadmin etc. If the results are getting through to php, then there is a problem with your display code rather than your query. -CB-
  22. Please confirm this script does what it says: test.php <?php session_start(); // Session Start if(isset($_GET['make'])){ $_SESSION['myusername'] = true; }else{ unset($_SESSION['myusername']); } if (isset($_SESSION['myusername'])){ echo ("boo!"); } else { echo ("meh!"); } echo("<br /><a href='test.php?make=boo'>Make me Boo!</a><Br /> <a href='test.php?'>Make me Meh!</a><Br />"); ?> If it does, you have an error in your script. You need to debug your code. Please provide the entire php script (mark out any sensitive data, but leave all code). Debugging code consists of outputting variables at specific points, or forcing variables to hold specific data that should work. This way you can pin-point the location or in-fact, offending characters that are preventing expected results. -CB-
  23. uh, i may be missing the point entirely but.. You mean this? Change "+=" to "=" on line 48 -CB-
  24. Give us the data you are working with (ie. the folder structure). Then we can see how we can manipulate the data to be sorted properly. Of course, any code given will be very basic and you will most likely have to adapt it to your specific needs. -CB-
×
×
  • 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.