Jump to content

Philip

Staff Alumni
  • Posts

    4,665
  • Joined

  • Last visited

  • Days Won

    20

Everything posted by Philip

  1. A class is a wrapper, or a bucket of variables and functions that are typically have some connection to each other. Variables inside a class are called properties, and functions inside of classes are called methods. In PHP, an object is a variable representation of a class - so when you call $ford = new car;, $ford is the object, and car is the class.
  2. Try running this and seeing which you like better (see attached image for what the results are): <?php $longVar = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam et consectetur tortor. Donec nec ante arcu. Proin consectetur, turpis non vehicula dignissim, lectus ante pretium nunc, vitae ultricies enim lacus quis purus. Nulla imperdiet ornare tempor. Proin sit amet aliquet tellus. Sed quis ligula vitae urna pharetra dictum. Suspendisse potenti. Integer a rhoncus odio. Donec porta, massa nec feugiat auctor, purus urna tempus leo, ac mattis metus tortor eu metus. Integer tincidunt mattis scelerisque. Nulla mi tellus, dignissim sed fermentum ac, lacinia vitae mi. Phasellus tortor diam, accumsan vitae pulvinar id, malesuada eu velit. Duis pharetra urna et massa ultrices mattis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Integer blandit pharetra purus, vel interdum arcu rutrum sed. Donec id tincidunt dolor. In hac habitasse platea dictumst.'; echo $longVar,'<hr>'; echo chunk_split($longVar, 64, '<br>'); echo '<hr>'; echo wordwrap($longVar, 64, '<br>'); ?> [attachment deleted by admin]
  3. You could do: class Car { public $wheels; public $engine; public $steering; public $colour; public $speed; public function __construct($speed) { $this->setEngine(); $this->setColour(); $this->setWheels(); $this->speed = $speed; } //... } $someCar = new Car($_GET['speed']);
  4. Yes, that's correct, it will run those functions and set the speed to a default of 0
  5. You're probably looking for wordwrap() or if you want to be exactly 65 chars, chunk_split()
  6. from and to are reserved words that needs to be surrounded by backticks. (I find it good practice to put backticks around all of the col/table names) $postcommentq = mysql_query("INSERT INTO `usercomments` (`from`, `to`, `comment`, `date`, `approve`) VALUES ('$cookieid', '$getid', '$postcomment', NOW(), 'N')")or die(mysql_error()); Also, make sure to clean the $cookieid/$getid variables
  7. A construct is the method (a class function) that is called whenever you create a class (e.g. $porsche = new Car(); ) This allows you to do whatever you want to properties (class variables) like setting defaults and such, or running other methods/functions. The setWheels($wheels = 4) is if the user does not give any data when they call that method it defaults to that. So, if I put it setWheels(2) it would give it 2 wheels, but if I put in setWheels() it would give it the default of 4.
  8. I'm really not sure I understand what you are trying to accomplish... but I can tell you the $i isn't working because you're using single quotes instead of double quotes: Either of these will work: <td><?php echo tep_draw_input_field("player[{$i}]_roster_fname", $row['player_roster_fname'], 'size="10"'); ?></td> <td><?php echo tep_draw_input_field('player['.$i.']_roster_fname', $row['player_roster_fname'], 'size="10"'); ?></td>
  9. Or if outside the current tags and you don't want it to be executed: just use < for < and > for >
  10. If you use prepare you do not need to escape the quotes - however if you're using normal query you do.
  11. mrMarcus - actually if the column is of numeric type it is not needed to place single quotes around the value. However, you are right with regards to never directly putting any request variables in the query
  12. haha, fetch_attay?
  13. You're not calling a fetch from the database. $query = mysql_query("SELECT `something` FROM `somewhere` LIMIT 1"); $row = mysql_fetch_assoc($query); echo $row['something'];
  14. You'd need to have js change it to display: block; jquery will have built in features that will do that... here's a tutorial/code sample: http://www.learningjquery.com/2006/09/slicker-show-and-hide
  15. You could set it's visibility property to none: display: none;
  16. You need to use sessions or a database/flat file to continue using a value across multiple scripts. Static reads as following:
  17. What's your current code then?
  18. You need to double check you parenthesis on your if statement, they don't line up (error_reporting would have found this ) Hopefully color coding the parenthesis will help you find your errors (and yes, the ones that don't line up are bolded and underlined): Also, on your query: $query = "INSERT INTO bookings (bookTitle, date, bookStart, bookEnd, bookLanes) VALUES ('$_POST[booktitle]','$_POST[date]','$_POST[bookStart]','$_POST[bookEnd]','$_POST[bookLanes]')"; Make sure to use curly brackets { } or concatenate the variables with a period: $query = "INSERT INTO bookings (bookTitle, date, bookStart, bookEnd, bookLanes) VALUES ('".$_POST['booktitle']."','".$_POST['date']."','".$_POST['bookStart']."','".$_POST['bookEnd']."','".$_POST['bookLanes']."')";
  19. Yeah, more of a SMF bug though. See if one if the admins is willing to try the fix
  20. Haha, I tried. Yours went away just fine Oh and from SMF board (although a 1.x):
  21. We've built our own, but we typically use http://rackmountsetc.com/ If you went with only Dell/HP - meh.... We also need to know what your budget looks like. We could set you up with an awesome server, and then you tell us its way overpriced. Just a quick look at what I did on dell.com: 2x quad core 2.33GHz Xeons (same ones I have - which are pretty quick haha), 4GB of RAM, 4x 500GB drives @ RAID 10, so 1TB of space backed mirrored all for $3.5k. It's an okay price, mainly the CPUs & HDD ate up your budget.
  22. $query = mysql_query("SELECT name FROM users LIMIT ".($num-1).", 1");
  23. Well - ip2long kinda does that. Returns false on invalid IP - but I agree, it would be nice to have a built in function is_ip
  24. $array = str_split($string);
  25. SELECT name FROM users LIMIT 5,1 would grab row 6
×
×
  • 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.