Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




How To Get The Match Score


I own a sms site and wants to update the users with the cricket match score.
I think i need some sort of xml feeds.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Returning Highest Score
I've been able to get the highest score from my table, however in some instances mysql_num_rows returns > 1, which is fine, just means two rows have the same score. I need to be able to now work out who has the highest VoteCount of all the results I got back from the highest score check. I need this because by the end, I only want the result of the Map with the highest score with the most votes (Yes it's a map server I'm making) Code:

PHP Script To Set Assignment Based On Weight Score
for example: if there are 4 stores and if store #1 is assigned a weight score of 10 - it would get 10% of the orders. if store #2 is assigned a weight score of 30 - it would get 30% of the orders and so forth, until it equals out to 100%. Is there a PHP function that i could use for this or would i have to just manually code this? Could someone please show me how would i go about doing this? Thanks.

PDF Mix & Match
I was wondering if anyone had any experience of splitting & appending PDF's?

A client has a huge pdf, and he wants to give the user the ability to mix and match the chapters that they want to download. The final final will be 1 pdf, but may consist of various different chapters chosen from a list. The chapters will be ripped from 1 master pdf.

Oh, and the PDF is not just text it contains all manner of images,links & the like!

And that is what is required. I was wondering if anyone had any pointers regarding this? I'm thinking PDFLib, but I haven't fully looked into it yet.

PHP Pattern Match
I need to convert the following pattern which I found in a php program into a perl regex... but I have NO CLUE WHAT IT DOES!

&[^;];

<[^>]*>

Actually, for the second one, I have an idea as to what it does, but I'm not sure... they are both used in this context:

Run SQL With Value Match To $array
I wonder if it is possible to do "select" in mySQL database with value matching to an $array.

For example,

$array = array("shanghai", "beijing");

I want to select cities whose names match the values in $array.

Instead of using foreach(), is it possible to do the select with the array itself. I know some languages support this function. For example:

SELECT fieldname FROM cities
WHERE city_name in '$array'

Is it possible in PHP with MySQL?

Regex: How Do I Match A Dot?
I am trying to match the dot, so that it actually matches "a dot" and not "everything". How do I write that? Example: the word "st."

I have tried
'/st./i'
'/st./i'

Sorry if this question is noobish. I have not been able to find the answer searching the net.

While Query Only Does First Match
I'm generating letters based on the date a lead was entered into the database. I've tried moving the } into several places. If I move it before the 2nd query I get all the letters but no dealers. If I move it to the bottom (as it now) I get 1 letter with the dealers. I can't figure out what to do to make the query generate all the letters with their associated dealers. PHP Code:

Trying To Match Date..
I am trying to make an Order History Lookup page for an E-commerce site. Now.. when an order is submitted the dateinserted is formated as date("U") and stored in the Db table.
Now.. when I create the lookup date formfields I have them as such:

Month (02)
Day (25)
Year (02)

How would I go about getting these values so that I can compare exactly against the date("U") string that is stored in the DB?

Preg Match Help
I have a site the produces results like this:

<a href="/file/564547">Text here</a></td>

I need to be able to extract the number and text. Have tried this:

preg_match_all("/<a href="/file/([^0-9])">(.*)</a></td>/", $data, $m);

and this:

preg_match_all("/<a href="/file/([0-9])">(.*)</a></td>/", $data, $m);

but $m is always empty!

Regex - How To Match Until Something
How do you replace an occurence until a certain point: You can see my
example code below and the output:

$string1 = 'Hello world today'
$string2 = 'Hello blahblah'

$string1 = preg_replace ( '/Hello.*(?!today)/', 'Hello ***' , $string1
);
$string2 = preg_replace ( '/Hello.*(?!today)/', 'Hello ***' , $string2
);

echo "$string1 - This should be Hello *** today
";
echo "$string2 - This is correct
";

Outputs:
======
Hello *** - This should be Hello *** today
Hello *** - This is correct

Match Any Character But
Can I use any reg exp(mainly for mod rewrite) where I can match any
character but a fixed list?

I need to match a string that does not contain any /'s but I don't want to
have to use a character search string. (I don't see any need to have to
hardcode it)

that is,

..

matches any single charactr

and (.*) matches any string

what I want to do is use something like % that means

..%/

which means match any character but /.

Of course it would need to be valid and I know I can't make up semantics for
the reg ex. My point is is that, is that I don't want to have to use
[a-z0-9-%&^$#@!etc...] to mean . but not /.

Surely there is a way to exclude a few characters from . without having to
increase the complexity of the expression 1000 fold?

If you don't get that, then a simple example would be that I have an
arbitrary string and I want to match only if that string does not contain an
a. Sure I can so something like
[bcdefghijklmnopqrstuv1234567890!@#$%^&*()_+]['/.,<>?:"{}+-=~`..........................]
but surely reg exp has an easier way??? (again, this is specifically for mod
rewrite)




Regex: Before And After The Match
I want to match a table and also capture the parts before and after the
table:
preg_match_all("|(.*)(<table.*table>)(.*)|",$text, $parts);
But of course it doesn't work, presumably because the first .* is
greedy. I tried adding an ? but that doesn't work either. How do I do
this ?

Php Emails Do Not Match ??
i have created a registration script for my website and i have added a new featurer that makes you enter your email address twice and then it is supposed to check if they are the same  and then if they are submit the form but if not show an error but even if the email addresses are the same it still shows the error below is the code for the email checking Code:

Data Mis-match In DBF Files
I'm still working on reading dbf files:

The following works well:
Code: <?php
$gdb = dbase_open('Contact1a.dbf', 0);

$rn = dbase_numrecords($gdb);
echo "Number of record is: $rn <br> <br>";

if ($gdb) {
$record_numbers = dbase_numrecords($gdb);
for ($i = 1; $i <= $record_numbers; $i++) {
$row = dbase_get_record_with_names($gdb, $i);
$company = $row['COMPANY'];
$contact = $row['CONTACT'];
$source = $row['SOURCE'];
if($source == "sean"){
echo " Company = $company, $contact, $source <br>";
}
}
}
?>

But, the "IF" conditional for the echo statement never evaluates to TRUE even though there are records in the "source" field which are exactly "sean".

If I comment out the "if" statement and the corresponding "}" the echo statement returns all records and, sure enough, some of them show "sean" as the source.

I don't know whether the dbf data includes non-printing characters which are corrupting the conditional or what..

Search Database - MATCH() AGAINST() Or LIKE
I have a fairly basic database that holds articles that visitors of my web site can search based on content of the articles and the author. Simplified the tables look like this...

articles
+-----------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+--------------+------+-----+---------+-------+
| doc_id | varchar(8) | | PRI | | |
| title | varchar(255) | YES | MUL | NULL | |
| date | date | YES | | NULL | |
| source | text | YES | | NULL | |
| abstract | text | YES | MUL | NULL | |
| body | mediumtext | YES | | NULL | |
+-----------------+--------------+------+-----+---------+-------+

authors
+---------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+----------------+
| author_id | int(11) | | PRI | NULL | auto_increment |
| doc_id | varchar(8) | YES | | NULL | |
| author | varchar(100) | YES | MUL | NULL | |
+---------------+--------------+------+-----+---------+----------------+

The Authors name is kept in the form of first initial, middle initial (if known) and last name (ie J. Bloggs).

Basically users have two fields they can complete for searching. One is the keywords (ie words in the body of the article) and the other is for the author of the article. Currently I perform a full text search to find authors that match the author they enter but I'm not sure this is the best method as authors with short last names (ie. Li or Cho) can't be found.

This is the code I am using to generate a query to search the database. PHP Code:

PCRE And Match Words
The project I'm currently working on requires a lot of pattern matching and I'm currently having troubles matching more an amount of words. I'm trying to find strings in an array which have less than three words in them, I'm using the below but it is not working:

(preg_match("'(S*s+){0,3}'isx" ,$qualified[$i][1]))

Preg_match - How To Match X00 (null)?
I'd like to work with a binary file....

I read the whole file into variable (it conatains binary data from 00-FF):

$fp=fopen($cfg,"r");
$content=fread($fp,filesize($cfg));
fclose($fp);

// and then I'd like to check if it contains special binary sequence, let's say bytes "00 01
02 03":

$replacestring="/x00x01x02x03/im";

if (preg_match($replacestring,$content)==0) {
echo("bad input file format");
exit();
}

but i get error message:

<b>Warning</b>: preg_match(): No ending delimiter '/' found in <b>test.bat</b> on
line <b>57</b><br />

I think it is maybe because php uses strings terminated with null, but can i force php to use strings with predefined length for example? Is there a way to work with strings containing null characters?

Search Authors Without Using MATCH AGAINST
I have a website that holds journal articles. Details for each articles are kept in a database. People can search for articles based on the contents of the articles or the author. Author names are kept in the form of "J. R. Bloggs".

Currently when a user searches by author I use the MySQL feature MATCH AGAINST. The problem with this is that fulltext indexes only indexes words that have 4 or more characters and a lot of authors in my database have surnames like Li, Wui, Lui, Lea and so on.

I'm looking for an alternative that will improve the results of the search. Using the MySQL LIKE feature isn't a very good alternative as it returns anything that contains the string of 2 or 3 characters. Does anyone know any clever tricks to get more useful results?

I was thinking I might be able to return a MySQL LIKE query results into an array then use the php function similar_text() to calculate the percentage similar each of the authors are then return only the authors that are 80% similar. I haven't tried this yet as I wanted to see what others might say plus with a few thousand articles in the database this may be extremely slow?

I Want To Get A String Using Preg Match.
I was looking for the good regexp, pattern I should use if i want to find this expression in a text file, string using preg_match

I would first to find this expression in a string where
"username" is always changing :

class="blue" value="username"

Once this expression found, I want to
receive the "username" withou the " "
all alone in a string...

Conditional Preg Match
The following bit of code does a preg match and does something if true
(sets $browser to ppcie)

Without using if then and else's how do I code it so it does not equal
what it is testing for? So if it does not find ppc in the $agent then
it does something else/sets it to something else?

$agent = getenv("HTTP_USER_AGENT");
if (preg_match("/PPC/i", "$agent")) {
$browser = 'PPCIE'
}

Match HTTP_REFERER To Database?
I need to match the site that the user is coming from to an entry in my database. At the moment I have the urls submitted by users (minus the "http://") in a single database field (I can use multiple fields if necessary). My problem is that the URL in my database could be ANY of these cominations:

site.com/
www.site.com
site.com/directory
www.site.com/directory/file.php
site.com/directory/another_directory/file.html
...
(and pretty much any other combination you can think of), which I need to match to where the user is coming from, which could be anywhere on the referer's site. I thought about using parse_url() on the HTTP_REFERER and just getting the domain name, but that wouldn't work if 2 people signed up from the same free hosts, eg:

members.freehost.com/user_id_1/index.html
members.freehost.com/user_id_2/

Best Approach To This Using Preg_replace/match
i found this code out in the ng, and its seems long and clunky,
i am still experimenting with preg_match and _replace, but the
syntax is a bit confusing. it seems i always misplace or mistype
something.

this is the code that i am trying to replace with better, optimized code.
i would like to make a preg_match and then preg_replace for this, and if
a match is found, just removing it.

i started with this:
(preg_match ("/(*/)|(/*)|(--)|(#|;)/", $line))
and
$line = preg_replace ("/(*/)|(/*)|(--)|(#|;)/", "", $line) . ";";

and this is the total items that i am searching for:
$line = str_replace(".", " ", $line);
$line = str_replace(""", " ", $line);
$line = str_replace("'", "", $line);
$line = str_replace("+", " ", $line);
$line = str_replace("-", " ", $line);
$line = str_replace("*", " ", $line);
$line = str_replace("/", " ", $line);
$line = str_replace("!", " ", $line);
$line = str_replace("%", " ", $line);
$line = str_replace(">", " ", $line);
$line = str_replace("<", " ", $line);
$line = str_replace("^", " ", $line);
$line = str_replace("(", " ", $line);
$line = str_replace(")", " ", $line);
$line = str_replace("[", " ", $line);
$line = str_replace("]", " ", $line);
$line = str_replace("{", " ", $line);
$line = str_replace("}", " ", $line);
$line = str_replace("", " ", $line);
$line = str_replace("=", " ", $line);
$line = str_replace("$", " ", $line);
$line = str_replace("#", " ", $line);
$line = str_replace("?", " ", $line);
$line = str_replace("~", " ", $line);
$line = str_replace(":", " ", $line);
$line = str_replace("_", " ", $line);
$line = str_replace(" ", " ", $line);
$line = str_replace("&amp;", " ", $line);
$line = str_replace("&copy;", " ", $line);
$line = str_replace("&nbsp;", " ", $line);
$line = str_replace("&quot;", " ", $line);
$line = str_replace("&uuml;", "ü", $line);
$line = str_replace("&Uuml;", "Ü", $line);
$line = str_replace("&", " ", $line);
$line = str_replace(";", " ", $line);
$line = str_replace("
", " ", $line);

Which Database Is Best For Match Querying
im wondering is there a better db than mysql for perfoming queries to
search textfields for the occurence of a string value? for example does
oracle have greater functionality is this regard?

Trying To Create A Match Thing
I have been trying to get an apartment exchanging site going. In Sweden it is common to rent your apartment and people often swap apartments with each other. Im trying to create a script (site) where people can do this. But I am a lousy programmer. I basically only know how to alter php since working many years with phpbb-forums.

What I need to learn is how to create a match like this:

1.) Person adds his appartment. He puts in info like how many rooms, how much rent and the size of the apartment.

2.) After this he fills in a form with the exact same fields but this time what he wants to have

3.) Another person puts in an ad that meets the first persons needs and there is a match.

I have no clue how to even start. Would be even more amazing if there could be a 3-part-match like "No1 wants No2 who wants No3 who wants No1". Is this complicated to do?

I have asked on one too many forums now and always been ignored so I hope this active forum can help me. I can concider paying someone for writing a script like this and helping me integrate it into my site.

Eregi.... Match [] In String..
Using the following:

<?php
$lines=file("c:\progra~1\bpftp server\users.ini");
foreach ($lines as $line_num => $line)
{
    echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br />";
}
for ($i=0;$i<=count($lines);$i++)
{
    if (eregi("^[a-zA-Z0-9[.[.][.].]]{1,}$",$lines[$i]))    
    {
        echo $lines[$i];
    }
    else
    {
        echo $result;
    }
}
?>

to try and match [xxxxx] on a line in the file - I thought I had it as far as I could see... looks like I was mistaken....

anyone have any suggestions for the eregi?

Strpos() Fails To Match
Minor problem with strpos() ... If $value is present at the very start of my string $row->mfg_types, the strpos() fails to match. I worked around this by adding the underscore as the first character but what am I doing incorrectly? I understand that it is returning a zero (string matched starting at character 0) which is also boolean false.

$checkboxes = explode('|', $MFG_TYPES);
echo "
<tr><td>Mfg. Types:</td><td>";
foreach ($checkboxes as $value) {
echo "<input type="checkbox" value="$value" name="mfg[]"";
if (!strpos('_'.$row->mfg_types, $value) === false) {
// the '_' was added at front because the function wouldn't
// pickup if the $value started as the first character of the string
echo " checked="on"";
}
echo ">$value<br />";
}
echo "</td></tr>";

Preg Match... Weird Error!
I'm using Preg_match to look through a string for swear words.

Select Each Word Match On A String
here if we give the keyword as sony discman shock . the keyword is the product name.
here i have to select datas. here sony discman is the product name of same. shock is another product. here i separate the string using explode function, what the thing three records are retrieved. ie.,the same record of product name is retrieved twice.how to solve this .

Regular Expression - Match String Containing A But Not A And B
A quick regex question which I've worked around for the time being,
but would like an answer to if anyone can help.

I want to match on all strings which end _id, but not those ending
row_id.

Some sample strings:

row_id
parent_id
person_id
person

I'd like to match all but the 1st and last.

I've tried many variants, including

preg_match('/(row)w{0}_id$/',$subject);
preg_match('/(row){0}_id$/',$subject);
preg_match('/(?!row)_id$/',$subject);

Find Match In MySQL Table
I have a table with several fields (id, company, city, and others). What I think I want to do is to select all the records (ordering by company asc for display purposes) and loop through them to find the requested id, BUT then I need to know the current row that match occurs in the overall list.

If I am not mistaken, if I do the match on the 'id' in the table with the id requested, then only that one row will be selected. So then for getting the prev/next links to work off the 'ordered by company asc' order and not just the 'id' sort, I need to know where this particular id matched row is in the overall list.

Why Doesn't Echo Match Field Contents?
Why is it that emails.from name or $from_name echoes as 'Joe Blow' in the following script WHEN the entire from_name field contents actually == 'Joe Blow <jblow@att.net>'
AND how might I use that field to find and update a contacts table record where contacts.full LIKE $from_name? Tried numerous variations on the following but no luck.
PHP Code:

How To Find A Match In A Text Field ?
i am using ereg($rowvalue[0],'humor2')==true to find a match in the text field. how can i find a exact match, ie. the text field contains 'humor,humor2'

so, if using ereg the result will be true for both humor and humor2 but only 1 - humor2 is correct. how do i find an exact match ?

Pattern Match And Extract Problem
I expect someone can crack this one in no time.

what I'd like to do is to match a pattern in a string and extract a
portion of it. For example if I had a string like:

'The store had apples(20) and pears(30)'

how do I extract the &#3920;' and &#3930;'? ie. if the pattern is 'apples(??)', how
do I expect the '?'.

Preg Match Fatal Error.
I get this error when using preg_match:

Fatal error: Can't use function return value in write context in /Applications/xampp/htdocs/sites/cmyk/signup.php on line 14

Here's the code (starts at line 2):

// if post info sent
if (!empty($_POST)) {
// set arrays
$errorclass = array();
$errornote = array();
// check post info
foreach ($_POST as $k => $v) {
if (stristr($k,"email") ¦¦ stristr($k,"password") ¦¦ stristr($k,"postcode")) {
// check for basic alpha numeric entry
if (!preg_match("/[0-9A-Za-zs-]+/",$v)) {
// error
$errorclass($k) = " class="error"";
$errornote($k) = "Invalid ".ucwords(
str_replace(
array("name","number"),
array(" name"," number"),
$k)
);
} else {
// format data
$postdata[$k] = ucwords($v);
}
}
}

Couting Number Of Rows With A Match
Im trying work out how to do a count of how many rows have "userID" as "Session" (Session carries user id). i got this so far:

Quote$CountTotal = mysql_query("SELECT * FROM messages
WHERE UserID='{$_SESSION['Current_User']}'");

obviously this will select all the messages in the UserID field but how do i just count the amount it found ?

Counting Preg Match Results
i was wondering if there was a way to count how many preg match results you get back
my code is: $matchesfound = preg_match('/subject="/', $nsubject, $matchfound);

Match Input Value With Values In A Delimited File
I'm very very new to php. I need your help. I have a text file which is ~ delimited. Each line has a name and link. I want to check if the link is similar to my input and if it is then return the name.

Compare Contents Of Two Arrays And Display What DOESN'T Match
I've got two arrays that I need to compare. One is $roomNums and the other is $roomNumsBooked. The point is to compare $roomNumsBooked against $roomNums (both arrays) and then display what DOESN'T match so I can get the rooms currently available.

I've written a script that works, but it seems every-so-clumsy. I was wondering if I could somehow use preg_match to do this but my prevous experiments have failed. Here's what I've done that works:

*******************************************
$roomNums = array('A','B','H','J','K','L','M','P','T');
$roomNumsBooked = array('A','B','L','T');
for ($i = 0; $i < count($roomNumsBooked); $i++)
{
for ($j = 0; $j < count($roomNums); $j++)
{
if ($roomNums[$j] == $roomNumsBooked[$i])
{
$roomNums[$j] = &#390;'
}
}
}
print_r ($roomNums);
echo '<br>'
echo 'Available Rooms: '
for ($i = 0; $i < count($roomNums); $i++)
{
if ($roomNums[$i]!= &#390;')
{
echo $roomNums[$i] , ', '
}
}
*******************************************

The echoed result is H, J, K, M, P which is correct, but is there a better, more efficient and/or elegant way to do this?

Regular Expression To Match Multiple Lines
I'm trying to pull some text from an HTML page, which is between identifiable tags. PHP Code:

Regex - Match Special Char Anywhere In String
i'm trying to validate a form submitted by the user. in the name field some people might include a "-" or "." as in: mrs. nancy smith-kline or something. how do i allow those special characters anywhere in the string along with the letters? using eregi, this is as best i can figure it:

$pattern = "a-z.-";
or
$pattern = "[[:alpha:]].-";

what's wrong with this?

Searching For Serial Numbers That Don't Match In A Spreadsheet
I have a list of serial numbers. One has more serial numbers than the other and I need to identify the units that do not match. Can someone explain a simple way to identify these units?

Is There Any Function In Php That Will Match A Word Exactly And If It Finds It, It Returns True.
Is there any function in php that will match a word exactly and if it
finds it, it returns true. For example if I search for "CA":

strVar = "Bob is from Los Angeles CA" - return true
strVar "Bob is from Canada" -- returns false

Preg_match() Error, Match Only Valid Date In Mm/dd Format.
I am trying to create a function that will match only valid date in mm/
dd format. (Month in, 01, 02, ..., 09, 10, 11, 12 and Dates in 01,
02, ..., 11, 12, ..., 30, 31).

I am trying this code, but it fails to work.

The error is :-
PHP Warning: preg_match(): Compilation failed: unmatched parentheses
at offset 15 in /home/wizard/regexDateTime.php on line xx

The code is here.

Match Regular Expressions In A Webpage, Not The Entire Source
In order to check availability, I want to visit many different pages
from a database and try and match the regular expressions 'out of
stock' or 'unavailable' or 'sold out' etc. If found, the product will
be flagged as unavailable.

I tried using fopen() and preg_match() but the problem is, if the reg.
expression is present in javascript or in comments, the item gets
wrongly flagged. Is there a way of taking what appears on the users
screen, after parsing the page, and looking at it as a string I suppose
?

Regular Expression To Match Characters Inside Links
I have little knowledge of regex, but I want to replace '&' and '=' from inside links.

Example:

$text = '<a href="http://www.site.com/index.php?param=123&param2=345"> stuff'

Finding Matches In A Table And Then Moving That Match To Another Table?
Ok, I have a database that has a table called critiera in this table
is to fields on is ID and the other is critiera.

Now I want to filter out all the one that don't apple to the list and
move the one that match to a different database.

I know how to open a connection, close, select

but I don't know how I would inside of a database use another one as
the way to create the list of critieras....

Why Does MATCH/AGAINST Fail To Catch Entries That LIKE Does Catch?
Wierd. Go to this page:

and search for "yoga"

This query gets run:

SELECT * FROM albums WHERE MATCH(name,description) AGAINST ('yoga')
ORDER BY id DESC

it returns nothing. (other searches work, but not the one for
"yoga").

But if I do SELECT * FROM albums WHERE description LIKE '%yoga%'

then I get 5 matches

The Server Date Cant Match With My Country Date.
which using Date()
the server date/time can not match with my country date/time
eg server time: 1.30pm ..but my localtime already 3.3pm


Copyright © 2005-08 www.BigResource.com, All rights reserved