Hello, we have web directory script have 50000 links and some links haven't its keywords 1- this is links table structure CREATE TABLE IF NOT EXISTS `dn_links` ( `id` int(10) unsigned NOT NULL auto_increment, `url` varchar(255) NOT NULL default '', `recip` varchar(255) NOT NULL default '', `title` varchar(255) NOT NULL default '', `description` varchar(255) NOT NULL default '', `detail` text NOT NULL, `keywords` text NOT NULL, ) ; Code (markup): 2-we have function to get meta function link_submitted_meta($in) { global $s,$m; $form = get_meta_tags($in[url]); $form[url] = $in[url]; if (!$form[title]) { $x = file($in[url]); foreach ($x as $k=>$v) { $k = strstr(trim(stripslashes($v)),'<TITLE>'); if (!$k) $k = strstr(trim(stripslashes($v)),'<title>'); if ($k) { $form[title] = eregi_replace('<title>','',eregi_replace('</title>','',$k)); break; } } } $s[subm_all] = 1; link_submit_form($in[selected_category],$form); } PHP: so that we want php code to check if " keyword filed is empty " > generate keyword automatically by this function and insert keywords to this field How we do that ?
Just run a mysql query to see if the keyword field doesn't have any data, i.e.: $query = "SELECT * FROM dn_links WHERE keywords = \"\""; $result = mysql_query($query); while($link = mysql_fetch_object($result)) { // run you function here for each link } PHP: That will return all the links in your table that don't have a keyword set.
thanks for code but please explain more because we tried this <? include('connect.php'); $query = "SELECT * FROM dn_links WHERE keywords = \"\""; $result = mysql_query($query); while($link = mysql_fetch_object($result)) { function link_submitted_meta($in) { global $s,$m; $form = get_meta_tags($in[url]); $form[url] = $in[url]; if (!$form[title]) { $x = file($in[url]); foreach ($x as $k=>$v) { $k = strstr(trim(stripslashes($v)),'<TITLE>'); if (!$k) $k = strstr(trim(stripslashes($v)),'<title>'); if ($k) { $form[title] = eregi_replace('<title>','',eregi_replace('</title>','',$k)); break; } } } $s[subm_all] = 1; link_submit_form($in[selected_category],$form); } } ?> Code (markup): But we found this error Fatal error: Cannot redeclare link_submitted_meta() (previously declared in /home/public_html/digint/demo.php:8) in home/public_html/digint/demo.php on line 8 Please add to us code that help us to do this <? if keyword filed is empty get_meta_tags($in) insert it to database ?>[/B]
Fatal error: Cannot redeclare link_submitted_meta() (previously declared in /home/public_html/digint/demo.php:8) in home/public_html/digint/demo.php on line 8 PHP: That error is caused by declaring the function link_submitted_meta() twice. In that code above you have: function link_submitted_meta($in) { PHP: However, according to PHP you are running a script called demo.php which also declares that function.
we used this code $result = mysql_query("SELECT id,url,keywords FROM dn_links") or die(mysql_error());if(mysql_num_rows($result) >= 1){ while($item = mysql_fetch_object($result)){ if(empty($item->keywords)){ $tags = get_meta_tags($item->url); mysql_query("UPDATE dn_links SET keywords='" . $tags['keywords'] . "' WHERE id=" . $item->id) or die(mysql_error()); } }} PHP: it's done A-data inserted like this ???? ????????? ? ???????? database Collation latin1_swedish_ci B-because our web directory have 30000 links 1-this operation take too much time and we get " Fatal error: Maximum execution time of 30 second exceeded " there is any fix to this ?