demented_gurl Posted April 7, 2009 Share Posted April 7, 2009 hye. i'm trying to compare 2strings, 1string is passed from the database, and the other string is passed from a textfield in a form. below is the code that i have tried, but the page shows an error concerning " while($Row= mysql_fetch_row($result)) "..please help. current_project_title - is the column name of the previous projects stored. project_name - the project name passed from textfield. <?php $current_project_title = $_Get["current_project_title"]; $query = "SELECT * FROM project"; $result = mysql_query($query); $similar = 0; while($Row= mysql_fetch_row($result)) { $project_name = $Row["project_name"]; if (strcmp($current_project_title,$project_name) > 90%) similar = 1; echo ("$project_name",$year); } if($similar > 0) {no register} else {register}; ?> Link to comment https://forums.phpfreaks.com/topic/152949-string-comparisonhelp-please/ Share on other sites More sharing options...
thebadbad Posted April 7, 2009 Share Posted April 7, 2009 And the error is? And it should be $_GET instead of $_Get. Also, strcmp() returns an integer. So you can't compare it to 90% (which will also spawn a syntax error I'm sure). And what's up with {no register} and {register}? Supposed to be comments? Link to comment https://forums.phpfreaks.com/topic/152949-string-comparisonhelp-please/#findComment-803274 Share on other sites More sharing options...
Mark Baker Posted April 7, 2009 Share Posted April 7, 2009 strcmp is a simple test that determines whether the two strings are identical or not. If you want to calculate the similarity between two strings, then I suggest you take a look at the levelshtein() or similar_text() functions Link to comment https://forums.phpfreaks.com/topic/152949-string-comparisonhelp-please/#findComment-803352 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.