Jump to content

mikesta707

Staff Alumni
  • Posts

    2,965
  • Joined

  • Last visited

Everything posted by mikesta707

  1. kk, ill report back with my findings EDIT: ok a few errors. The variable $this->encrypted never seems to be set (in your example code) because of the if statement in your constructor. because of this calling the decrypt function like so echo $da->decrypt(); results in an error (invalid argument for foreach. it refers to this foreach:) foreach ($encrypted as $key=>$val){
  2. well, one thing i noticed is since your using md5, which doesn't actually encrypt something, but rather hashes it (a hash can't be unhashed), i don't see how your decrypt function would work (assumign its supposed to decrypt an encrypted string). the encrypting part seems good though
  3. as in, call a javascript function in PHP? well remember, you can echo html via the echo statement, so you could do something like //assume js function is called foo echo '<script type="text/javascript">'; echo 'foo()'; echo '</script>';
  4. yes, that would also solve the problem. you could also use str_replace to remove all spaces from the $data variable, but that may have unwanted side effects (like changing the word apple pie to applepie)
  5. this isn't really an array problem, more a string problem. if you want spaces, then insert them echo "I have visited and lived in " . $countries[3] . " and " . $countries[0]; you have to realize that whatever you type into the script, its all the PHP knows or cares about. it won't add in spaces unless you tell it too, and you always need to be conscious of what exactly you are telling the program to do.
  6. that has nothing to do with the if statement. break is completely invalid in that context. can you post the rest of the code?
  7. its probably because your other "keys" have a preceding space before them. Try changing the line $data = "pepper, apple, orange"; to $data = "pepper,apple,orange"; you could also simply just put them into an array like $item = array("pepper", "apple", "orange"); and it should work
  8. no... if you read my response, its an opening parens '(' rather than an opening curly bracket '{' syntax wise they are completely different
  9. if you have skype installed, you may need to change the port (to add on to what ignace said)
  10. um.. no it doesn't. an if statement doesn't loop....
  11. um.. break commands are used in switch() statements, not in if statements. You can't really break out of an if statement. just remove the break, and the code should work as expected, though it could be simplified to if (!$context['user']['is_guest']) { header("Location:http:main_page.php"); }
  12. well where does $row come from? can i see the whole script? if you are doing a query then Matthew's advice would work also
  13. interesting. what type of object are you trying to store into an array?after a quick google search it seems that "resources" CANNOT be stored in the session array while regular objects can, and many people attribute this to why they get your specific error.
  14. this if statement if ($numrows!=0) ( you are using an opening parens instead of an opening curly bracket. after you remove the semi colon after the while loop, changing that if to if ($numrows!=0) { should fix the problem
  15. when an array is cast, or coerced into a string, all the elements are ignored all together, and the string becomes the literal string 'array'. There is no way to convert it back to its original array (even if you try casting it as an array). All casting the literal string 'Array' into an array will do is make a 1 element array with a the string 'Array' as its element. This is why when you do $array = array(...);//an array with some elements echo $array; all that gets echoed is 'Array'. The command echo needs a string, so anything that is to the right of the command is coerced into one. Most types in PHP can do this quite seemlessly, but objects usually have some trouble. This is why print_r and var_dump are useful consider another example $a = array(); for ($i = 0; $i < 2; $i++){ $a[] = $i; } $b = (string)$a; echo $b;//echos: Array $c = (array)$b; print_r($c);//prints: Array ( [0] => Array ) one option is to use serialize() and unserialize, which turns an object into a string representation (which you can then unserialize to turn back into its object) However, based on your original problem, you simply want to store an array of objects into the session array yes? as has been said before, as long as you have the class definition (IE include the class file) before session start, you should be able to pass objects in a session from page to page. The fact that they are in an array doesn't matter. Hell, $_SESSION is an array. for example, the following should work include("foo.php");//assume this has some class foo session_start(); $foo = new Foo(); $_SESSION['foo'] = $foo; //this also should work; $foos = array(); for ($i = 0; $i < 3; $i++){ $foos[] = new Foo(); } $_SESSION['foos'] = $arr;
  16. if the keys are always called 'scorex' where x is some number between 1 and 8 //take sum $sum = 0; for ($i = 1; $i <= 8; $i++){ $sum += $row['score'.$i]; } $row['average'] = $sum/8; //round $average $row['average'] = round($row['average'], 1)
  17. $count = 0; echo "<table><tr>"; while($result = mysql_fetch_array($search)) { echo "<td>".$result['username']."</td>"; if (($count + 1) % 5 == 0) echo "</tr><tr>"; $count++; } echo "</tr></table>"; something like that should do the trick EDIT: forgot to increment count and fixed a syntax error
  18. no problem. if your topic is solved you can click the mark solved button at the bottom of the thread
  19. its doing that because your while loop goes through all the ids in descending order, and overwrites your $id variable with the latest row gotten from the mysql_fetch_assoc() function. At the end, (assuming your first id is 0) the last row checked is the row with an id of 0, which is the last time $id is overwritten, so it ends up being 0 (which makes your if statement true) jdorms code will make it stop doing that, but what exactly are you trying to accomplish with your code? Based on your OP, and the code, I can't really tell
  20. $time = strtotime("next sunday"); $week = 60*60*24*7;//60 secs a min * 60 mins an hour * 24 hours a day * 7 days a week for ($i = 0; $i < 10; $i++){ echo date("Y-m-d", $time) . "<br />"; $time += $week; } that should help get you started. its gets the next sunday of the week, and outputs the next 10. its pretty simple logic wise, but you may want to put in a check to see if its a sunday, if you want to list the current day if its a sunday.
  21. echo -$daysleft; ?
  22. you can click the green mark solved button at the bottom of the thread to mark this topic as solved
  23. as schilly suggested, try verifying that $_GET['id'] is set. also try echoing the raw query itself to see that it is what you expect. try creating an else clause for the first if (not any of the nested ones) to see if that first isset(...) check is false or true
  24. what happens exactly? blank page? wrong info? query seems to fail? error message? a little more info is needed
  25. How are your pages stored? are you using glob or something to get the pages, or are there names stored in a database table? edit: an example with glob $glob = glob("{f,q}*.*", GLOB_BRACE); print_r($glob); will show all the files in the scripts directory that start with f or q (any extension accepted). this should give you an idea of where to start
×
×
  • 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.