turbocueca Posted April 10, 2006 Share Posted April 10, 2006 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? Quote Link to comment Share on other sites More sharing options...
titangf Posted April 10, 2006 Share Posted April 10, 2006 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. Quote Link to comment Share on other sites More sharing options...
turbocueca Posted April 10, 2006 Author Share Posted April 10, 2006 Yeah the manual said the same thing, but is this too important ? Quote Link to comment Share on other sites More sharing options...
titangf Posted April 10, 2006 Share Posted April 10, 2006 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. Quote Link to comment Share on other sites More sharing options...
turbocueca Posted April 10, 2006 Author Share Posted April 10, 2006 cool, where can i find a simple tutorial to search mysql results? Quote Link to comment Share on other sites More sharing options...
titangf Posted April 10, 2006 Share Posted April 10, 2006 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 Quote Link to comment Share on other sites More sharing options...
titangf Posted April 10, 2006 Share Posted April 10, 2006 Any other questions... I think this is up my alley of expert-ezz, lol Quote Link to comment Share on other sites More sharing options...
turbocueca Posted April 10, 2006 Author Share Posted April 10, 2006 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. Quote Link to comment Share on other sites More sharing options...
titangf Posted April 11, 2006 Share Posted April 11, 2006 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. Quote Link to comment Share on other sites More sharing options...
trq Posted April 11, 2006 Share Posted April 11, 2006 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. Quote Link to comment Share on other sites More sharing options...
titangf Posted April 11, 2006 Share Posted April 11, 2006 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. Quote Link to comment Share on other sites More sharing options...
trq Posted April 11, 2006 Share Posted April 11, 2006 [!--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(). Quote Link to comment Share on other sites More sharing options...
titangf Posted April 11, 2006 Share Posted April 11, 2006 no worries... I think i'm a little lost too... lol Quote Link to comment Share on other sites More sharing options...
turbocueca Posted April 11, 2006 Author Share Posted April 11, 2006 just let me eat somethin' and i'll test the code Quote Link to comment Share on other sites More sharing options...
turbocueca Posted April 11, 2006 Author Share Posted April 11, 2006 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] Quote Link to comment Share on other sites More sharing options...
turbocueca Posted April 11, 2006 Author Share Posted April 11, 2006 no problem thanks. I managed to get the page working. Just added two ' on the search string. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.