Jump to content

Classes and Objects


turbocueca

Recommended Posts

Here's how I interpret each...

-A [b]class[/b] is a collection of variables and functions that operate on those variables.

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

I hope this helps in deciphering it all out.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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
Link to comment
Share on other sites

whats this? :

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

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

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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.
[code]
$result = mysql_query("SELECT name, work_status FROM usbextreme WHERE name LIKE '". $_POST['query']. "' OR work_status LIKE '". $_POST['query']. '") or die (mysql_error());
[/code]
Not sure what titangf was talking about in his post.... there is no LIMIT clause in your sql statement.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

[!--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().
Link to comment
Share on other sites

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]

[code]<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>[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.