Hi,
I've been trying to search a database for each element in an array but have been having some problems. First off, here is the small script:
<?php
mysql_connect("hostname", "username", "password");
mysql_select_db(database);
$html = "This is some sample text for the html of the page. Here is a card name: [card]Verdant Force[/card]. Heres another [card]Counterspell[/card] and then the rest of the page...";
preg_match_all("/\[card\](.*?)\[\/card\]/i", $html, $matches);
foreach ($matches[1] as $value) {
$cardinfo=$db->sql_query("SELECT id, title FROM cards WHERE title='$value'");
list($card_id, $card_title)=$db ->sql_fetchrow($cardinfo);
echo "$value, $card_id, $card_title<br><br>";
}
?>
For some reason, it keeps giving me the following error:
Fatal error: Call to a member function on a non-object in /directory/.../file.php on line #
And this is the array:
Array (
[0] => Array ( [0] => [card]Verdant Force[/card] [1] => [card]Counterspell[/card] )
[1] => Array ( [0] => Verdant Force [1] => Counterspell )
)
If anyone has any information on setting the elements as variables so I can just search them that way or a different way I can do this, I would greatly appreciate it. The array is fine, as I can print out the values for $value, but I'm not sure why it won't let me search the database for those values.
Thanks,
~ender