Philip
Staff Alumni-
Posts
4,665 -
Joined
-
Last visited
-
Days Won
20
Everything posted by Philip
-
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.
-
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]
-
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']);
-
Yes, that's correct, it will run those functions and set the speed to a default of 0
-
You're probably looking for wordwrap() or if you want to be exactly 65 chars, chunk_split()
-
[SOLVED] Can't figure why my form is not inserting...
Philip replied to pneudralics's topic in PHP Coding Help
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 -
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.
-
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>
-
Or if outside the current tags and you don't want it to be executed: just use < for < and > for >
-
Question: mysql_real_escape_string with PDO statements
Philip replied to cunoodle2's topic in PHP Coding Help
If you use prepare you do not need to escape the quotes - however if you're using normal query you do. -
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
-
haha, fetch_attay?
-
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'];
-
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
-
You could set it's visibility property to none: display: none;
-
You need to use sessions or a database/flat file to continue using a value across multiple scripts. Static reads as following:
-
What's your current code then?
-
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']."')";
-
[SOLVED] "MESSAGES[1]", but no messages
Philip replied to Maq's topic in PHPFreaks.com Website Feedback
Yeah, more of a SMF bug though. See if one if the admins is willing to try the fix -
[SOLVED] "MESSAGES[1]", but no messages
Philip replied to Maq's topic in PHPFreaks.com Website Feedback
Haha, I tried. Yours went away just fine Oh and from SMF board (although a 1.x): -
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.
-
[SOLVED] Is there a way of selecting data from a particular row number?
Philip replied to madspof's topic in MySQL Help
$query = mysql_query("SELECT name FROM users LIMIT ".($num-1).", 1"); -
How to identify if the input string is valid IP address format
Philip replied to bloodgoat's topic in Regex Help
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 -
$array = str_split($string);
-
[SOLVED] Is there a way of selecting data from a particular row number?
Philip replied to madspof's topic in MySQL Help
SELECT name FROM users LIMIT 5,1 would grab row 6