0

I have variables gathered from another website with preg_match_all and echo the value. But the value is in $var1[0][n], n>0 form;I couldn't inserted the value into mysql. Thanks for any help.

$path='@<div class="comp-cell-row-div vtable infoColumn" style="width:    25%;">(.*?)</div>@si';
$vr12=file_get_contents('https://www....');
preg_match_all($path,$vr12,$ad12);
echo $ad12[0][14];

$value = array( var_dump($ad12));

foreach($value as $val){mysqli_query($conn,"UPDATE `test` SET     `param1`='$val' WHERE `id`='118'");
}

 or mysqli_query($conn,"INSERT INTO `test` VALUES .....");
1
  • 1
    Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. Commented Oct 19, 2022 at 11:06

1 Answer 1

0

First of all, we need to manipulate data. Choose db as varchar to see saved tags with data. Pregmatc_all also gets tags, strings in varchar format. To eleminate unwanted tags or signs; use trim and substr expressions on php.

In the example I trim before 17th character. This is a property of strpos

$data12=trim(substr($ad12[0][n], 17, strpos($ad12[0][n],'')),$extratags);
mysqli_query($conn,"UPDATE `table` SET `val12` = '$data12' WHERE `col1` = 'data1'; ");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.