Jump to content


Photo

Classes and Objects


  • Please log in to reply
15 replies to this topic

#1 turbocueca

turbocueca
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts

Posted 10 April 2006 - 08:55 PM

Hello people, long time no see. I've been studying some manuals of PHP, but there was one thing I didn't understand, what are classes and objects? Can someone please explain to me?

#2 titangf

titangf
  • Members
  • PipPipPip
  • Advanced Member
  • 58 posts
  • LocationColorado, USA

Posted 10 April 2006 - 09:06 PM

Here's how I interpret each...

-A class is a collection of variables and functions that operate on those variables.

-An object is an instance of classes that group data and relevant methods together.

I hope this helps in deciphering it all out.
[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--][a href="http://www.csszengarden.com/" target="_blank"]css zen garden - beautiful design with the programmer in mind[/a][!--colorc--][/span][!--/colorc--]

[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--]Time is the invention of man to gauge what his achievements have been before he fades to dust.[!--colorc--][/span][!--/colorc--]

#3 turbocueca

turbocueca
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts

Posted 10 April 2006 - 09:25 PM

Yeah the manual said the same thing, but is this too important ?

#4 titangf

titangf
  • Members
  • PipPipPip
  • Advanced Member
  • 58 posts
  • LocationColorado, USA

Posted 10 April 2006 - 09:35 PM

Its all important because it is the structure in which PHP functions and are built.

Here's a better way of looking at it... in a general sense... your "Objects" are like your generals in an army who know exactally everything that is going on... they in turn command the "Classes" (aka. your squad leaders) to do their bidding... and the functions and variables to do the true dirty work (aka your grunts/privates).

Its all a higher-archy that works together to get the job done.
[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--][a href="http://www.csszengarden.com/" target="_blank"]css zen garden - beautiful design with the programmer in mind[/a][!--colorc--][/span][!--/colorc--]

[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--]Time is the invention of man to gauge what his achievements have been before he fades to dust.[!--colorc--][/span][!--/colorc--]

#5 turbocueca

turbocueca
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts

Posted 10 April 2006 - 09:46 PM

cool, where can i find a simple tutorial to search mysql results?

#6 titangf

titangf
  • Members
  • PipPipPip
  • Advanced Member
  • 58 posts
  • LocationColorado, USA

Posted 10 April 2006 - 09:52 PM

Try this one out...

[a href=\"http://www.phpfreaks.com/quickcode/Basic-MySQL-Search/12.php\" target=\"_blank\"]http://www.phpfreaks.com/quickcode/Basic-MySQL-Search/12.php[/a]

Always check out the free code on this site... alot of it is very powerful
[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--][a href="http://www.csszengarden.com/" target="_blank"]css zen garden - beautiful design with the programmer in mind[/a][!--colorc--][/span][!--/colorc--]

[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--]Time is the invention of man to gauge what his achievements have been before he fades to dust.[!--colorc--][/span][!--/colorc--]

#7 titangf

titangf
  • Members
  • PipPipPip
  • Advanced Member
  • 58 posts
  • LocationColorado, USA

Posted 10 April 2006 - 10:10 PM

Any other questions... I think this is up my alley of expert-ezz, lol
[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--][a href="http://www.csszengarden.com/" target="_blank"]css zen garden - beautiful design with the programmer in mind[/a][!--colorc--][/span][!--/colorc--]

[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--]Time is the invention of man to gauge what his achievements have been before he fades to dust.[!--colorc--][/span][!--/colorc--]

#8 turbocueca

turbocueca
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts

Posted 10 April 2006 - 10:38 PM

whats this? :

Parse error: parse error, unexpected '\"' in /home/www/infocenter.awardspace.com/inter/ps2ub/search.php on line 50

$sql = mysql_query("SELECT name, work_status FROM usbextreme WHERE name LIKE "" . $_POST['query'] . "" OR work_status LIKE "" .$_POST['query'] . """) or die (mysql_error());

Note: I did the first way and mysql said something about the syntax, then I tried with the way justin16l told and it gave this error.

#9 titangf

titangf
  • Members
  • PipPipPip
  • Advanced Member
  • 58 posts
  • LocationColorado, USA

Posted 11 April 2006 - 04:00 PM

ok understanding concepts is my stronger suit right now and the coding follows after that. But I'll take a shot in the dark with this one.

I don't understand why your trying to limit the mysql_query with the $_POST command. If your trying to limit the query from one page to another it should be using the $_GET command. I don't see how the $_POST will limit your query of the database.

I'm not sure the solution, but this should go into a new topic post if you want this one answered and you might want to put more code up than just that small smidget so people can understand what the code is trying to do. Sorry i couldn't help, I'm better at the concepts of how php works than the detailed coding.
[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--][a href="http://www.csszengarden.com/" target="_blank"]css zen garden - beautiful design with the programmer in mind[/a][!--colorc--][/span][!--/colorc--]

[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--]Time is the invention of man to gauge what his achievements have been before he fades to dust.[!--colorc--][/span][!--/colorc--]

#10 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 11 April 2006 - 04:08 PM

Your problem stems from all the double quotes "". Also, naming the returned value from a mysql_query() $sql is very misleading. If successfull mysql_query will return a result resource, on failure it will return a bool false. Naming it something like $result is much more suitable.
$result = mysql_query("SELECT name, work_status FROM usbextreme WHERE name LIKE '". $_POST['query']. "' OR work_status LIKE '". $_POST['query']. '") or die (mysql_error());
Not sure what titangf was talking about in his post.... there is no LIMIT clause in your sql statement.

#11 titangf

titangf
  • Members
  • PipPipPip
  • Advanced Member
  • 58 posts
  • LocationColorado, USA

Posted 11 April 2006 - 04:27 PM

Sorry turbo, didn't mean to mislead you. Well... I guess you learn something new everyday...

didn't realize that mysql_query had no limits... Guess i'll have to just go with my motto with this one...


Even the true masters of their times only claim to be students.
[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--][a href="http://www.csszengarden.com/" target="_blank"]css zen garden - beautiful design with the programmer in mind[/a][!--colorc--][/span][!--/colorc--]

[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--]Time is the invention of man to gauge what his achievements have been before he fades to dust.[!--colorc--][/span][!--/colorc--]

#12 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 11 April 2006 - 04:34 PM

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]didn't realize that mysql_query had no limits[/quote]
Sorry, you've lost me. You can limit results by using a LIMIT clause in your sql statement, but that has nothing to do with the php function mysql_query().

#13 titangf

titangf
  • Members
  • PipPipPip
  • Advanced Member
  • 58 posts
  • LocationColorado, USA

Posted 11 April 2006 - 04:54 PM

no worries... I think i'm a little lost too... lol
[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--][a href="http://www.csszengarden.com/" target="_blank"]css zen garden - beautiful design with the programmer in mind[/a][!--colorc--][/span][!--/colorc--]

[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--]Time is the invention of man to gauge what his achievements have been before he fades to dust.[!--colorc--][/span][!--/colorc--]

#14 turbocueca

turbocueca
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts

Posted 11 April 2006 - 06:05 PM

just let me eat somethin' and i'll test the code

#15 turbocueca

turbocueca
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts

Posted 11 April 2006 - 06:21 PM

Here is what happen:

[a href=\"http://infocenter.awardspace.com/inter/ps2ub/search.php\" target=\"_blank\"]http://infocenter.awardspace.com/inter/ps2ub/search.php[/a]

<html>
<head><title>ola</title></head>
<body>
<form method="POST" action="">
Search Word: <input type="text" name="query">
<input type="SUBMIT" value="Search!">
</form>

<?
include 'db.php';
// PHP Search Script

$result = mysql_query("SELECT name, work_status FROM usbextreme WHERE name LIKE '". $_POST['query']. "' OR work_status LIKE '". $_POST['query']. '"') or die (mysql_error());

while(list($column1, $column2)=mysql_fetch_array($result)){

echo "Result: $column1, $column2 <br />";

}
?>
</body>
</html>


#16 turbocueca

turbocueca
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts

Posted 11 April 2006 - 07:45 PM

no problem thanks. I managed to get the page working. Just added two ' on the search string.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users