Jump to content

Alex

Staff Alumni
  • Posts

    2,467
  • Joined

  • Last visited

Everything posted by Alex

  1. The same way they do, but instead of passing it to eval just echo it to get the contents.
  2. The function that bh stated isn't for what you want to do at all. Two completely different types of threads.
  3. You can't instantiate an object that way. You'll need to instantiate the Moo object inside the foo object's constructor. Here's an example on how to do what you're trying to do: class foo { public function sayHello() { echo 'Hello'; } } class bar { protected $foo; public function __construct() { $this->foo = new foo(); } public function someMethod() { $this->foo->sayHello(); } } $instance = new bar(); $instance->someMethod();
  4. I'm still not sure what you're asking, and I don't see how that additional code relates to your original question.
  5. Oh, sorry, your post was confusing. In that case you can add them normally as PHP will automatically convert them to integers for you when performing the arithmetic. $string1="10"; $string2="5"; echo $string1 + $string2; // 15
  6. If you want to get 105 then you want to treat them as strings and concatenate them. $string1="10"; $string2="5"; echo $string1 . $string2; // 105
  7. What are you trying to do on this line?: $one.$add = new Person('laryy'); Are you trying to use variable variables? Where is $one defined?
  8. You have a comma after setting the value of email but you're only updating 1 column, remove it. $result = mysql_query("UPDATE class_members SET email ='".$_POST['email']."' WHERE mem_id='".$_POST['mem_id']."'") or die(mysql_error());
  9. As PFMaBiSmAd said, this is poor security, but to answer your question there are a few problems with your code. You need to place session_start at the top of the page. On the following two lines organization is spelled incorrectly: $oranization = $_POST['organiation']; ... $e_reply = "You can contact $organzation, $name via email, $email"; You should not use short tags (<? ?> and <?=$var?>) because it will make your script much less portable. Instead you should use the normal <?php ?> / <?php echo $var; ?> tags.
  10. Please post your entire code.
  11. You should not use session_unregister because it's depreciated. Instead you should just use unset to unset the session variable. unset($_SESSION['var']);
  12. This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=305825.0
  13. You can do that yourself. There is a button at the bottom left to do so.
  14. You could also use a for loop like this: for($i = 0, $n = sizeof($arr);$i < $n;++$i) { echo '<a href="' . $arr[$i] . '">' . $arr[++$i] . '</a>' ; }
  15. Then how did you plan on doing what you did with it in the OP? Here's what you might do (I made some assumptions so you might have to change the column names and things like that): $sql = "select Name, Birthday, City, Country, Status from table where userid = loggedInUser"; // Did you mean $loggedInUser ? if($result = mysql_query($sql)) { $row = mysql_fetch_assoc($result); foreach($row as $name => $val) { if(!empty($val)) { echo "$name: $val<p/>"; } else { echo "<a href='edit_profile.php'>edit this!</a>"; } } } else { // error }
  16. The code I provided will loop through all of the elements in the array, so it's not necessary to write repetitive code. Try it. If you have any problems post back.
  17. If you're accessing an element of an array inside of a string you need to wrap it in curly braces like so: fwrite($info,"Height: {$_GET['height']} <br />");
  18. Assuming that the $loggedInfo array only contains the fields that you want to display in this particular area you can do something like this: foreach($loggedInfo as $name => $val) { if(!empty($val)) { echo "$name: $val<p/>"; } else { echo "<a href='edit_profile.php'>edit this!</a>"; } } If you want you can also shorten it with the ternary operator: foreach($loggedInfo as $name => $val) { echo !empty($val) ? "$name: $val<p/>" : "<a href='edit_profile.php'>edit this!</a>"; }
  19. This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=305750.0
  20. You would have to do it like this: d.childNodes[0].nodeValue = "<?php echo $battleText; ?>";
  21. The data returned is correct. You just need to loop over it with PHP in the correct manner, but that's more of a question suited for the PHP coding help forum.
  22. That's not a JOIN at all.. Using a JOIN your query might look something like this: SELECT categories.*, subcats.* FROM categories JOIN subcats on (categories.cat_id = subcats.cat_id) ORDER BY cat_name
  23. DOM might not be the best tool in this case because their markup is invalid. If you want to use DOM you'll have to suppress the warnings generated by their HTML. Here's an example on how it could be done using DOM anyway.. $doc = new DOMDocument(); @$doc->loadHTMLFile('http://nflcarsworldwide.net/'); // @ to suppress warnings from their invalid HTML $temp = new DOMDocument(); foreach ($doc->getElementById('right')->childNodes as $child){ $temp->appendChild($temp->importNode($child, true)); } echo trim($temp->saveHTML());
×
×
  • 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.