Jump to content

help on insert/php


MDanz

Recommended Posts

 $tags = get_meta_tags($url);

$keywords = $tags['keywords'];

 

this get me the keywords for a website.  Just say there are 5 keywords in that one variable. e.g. apple, banana, orange, pear and coconut.  how do i insert these 5 keywords in that one variable($keywords) into seperate rows. 

 

So insert first keyword into one row

second keyword into one row

 

etc remember they are all in one variable.

 

 

how can i do this?... example would help

 

 

Link to comment
https://forums.phpfreaks.com/topic/191126-help-on-insertphp/
Share on other sites

i keep getting the

Parse error: syntax error, unexpected T_VARIABLE on the line with foreach..

 

$radiobutton = $_POST['radiobutton'];
$name = mysql_real_escape_string($_POST['name']);
$url = mysql_real_escape_string($_POST['url']);

  $tags = get_meta_tags($url);
  
$description = $tags['description'];    
  $keywords = $tags['keywords'];
  $ip = $_SERVER['REMOTE_ADDR'];


foreach (explode(',' $keywords) as $keyword) {



  if($radiobutton == 'on')
{


$sql = "INSERT INTO Stacks (`username`,`hyperlink`,`name`,`summary`,`info`,`keywords`,`ip`,`posted`,`adult`) VALUES('$username', '$url', '$name', '$description', '$description', '$keyword', '$ip', NOW(), '1')";
$query = mysql_query($sql);
}

else
{

$sql = "INSERT INTO Stacks (`username`,`hyperlink`,`name`,`summary`,`info`,`keywords`,`ip`,`posted`) VALUES('$username', '$url', '$name', '$description', '$description', '$keyword', '$ip', NOW())";
$query = mysql_query($sql);

}

  if($query){ 
  
   $name = mysql_real_escape_string($_POST['name']);
  $url = mysql_real_escape_string($_POST['url']);
$query3=  mysql_query("UPDATE Stacks SET `keywords`=CONCAT(`keywords`, ' ', '$name') WHERE hyperlink='$url'") or die (mysql_error());


$key = mysql_real_escape_string($_POST['key']);
  $url = mysql_real_escape_string($_POST['url']);
$query2=  mysql_query("UPDATE Stacks SET `keywords`=CONCAT(`keywords`, ' ', '$key') WHERE hyperlink='$url'") or die (mysql_error());

if(!empty($key))
{
print "<br><font color=white>Your webpage has been stacked.  <form><input type='button' value='Return' onClick='history.go(-1);return
true;'> </form>"; 
}
else
{
print "<br><font color=white>Your webpage has been stacked.  <a href='menu.php'>Return to Stacker</a></font>";
}

}}
else {
print "<br><font color=white>This webpage hasn't got meta tags set. <a href='menu.php'>Return to Stacker</a></font>";
}

Link to comment
https://forums.phpfreaks.com/topic/191126-help-on-insertphp/#findComment-1007791
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.