Link to home
Start Free TrialLog in
Avatar of denny3d
denny3d

asked on

replace a variable from result of query mysql

Hello EE
into my php page i have a variable $owner
$owner = "pinco";

from a query of my db mysql i have a result like this:
"bla bla bla $owner bla bla bla"

i would print $owner of my result db whit value of variable of my page php.
where i wrong?
regards
Denis
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

http://www.laprbass.com/RAY_temp_denny3d.php

Outputs: bla bla bla pinco bla bla bla
<?php // RAY_temp_denny3d.php
error_reporting(E_ALL);

// SET A VARIABLE
$owner = 'pinco';

// USE THE VARIABLE IN A STRING
$str = "bla bla bla $owner bla bla bla";

// SHOW THE WORK PRODUCT
echo $str;

Open in new window

Avatar of denny3d
denny3d

ASKER

Hi Ray
dont work, i post my code:
into db i have this string: <p>Questo sito è di proprietà e viene gestito da $owner</p>
into my page i have this variable: $owner = 'pinco';

this is my code:
$sel_privacy = "SELECT id, titolo, body, FROM table";
$ris_privacy = mysql_query($sel_privacy);
$privacy = mysql_fetch_object($ris_privacy);
echo'<h1>' . $privacy->titolo . '</h1>';
echo'<p>';
echo $privacy->body;
echo'</p>';

I have this result:
Questo sito è di proprietà e viene gestito da $owner

where i wrong?
regards
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of denny3d

ASKER

excellent