Hey all,
First I know basically 0 about programming, so forgive the obvious mistakes. I have a simple (at least I thought script) that worked in php 5, but no go in php 7. I tried upgrading it to php 7, but can't get it to work. Can someone please help me.
<?php
function sentence() {
global $post;
mysqli_connect("localhost", "user", "pass", "database");
mysqli_query('set names "utf8"');
$query="SELECT name FROM seo ORDER BY RAND() LIMIT 10;";
$result=mysqli_query($query);
$num=mysqli_num_rows($result);
//Begin find and replace
while($row = mysqli_fetch_array($result))
{
//this is the string to look into
$myString = $row['name'];
//this is the thing to look for
$patterns = array();
$patterns[0] = '/1111/';
//this is what you replace it with
$result1 = $post->post_title;
//this is the echo
echo preg_replace_callback($patterns, $result1, $myString);
}
mysqli_close();
}
?>
Thank you in advance