I have solved the problem if i change the php variable in the database to contain

<div class="row-2">
    <div class="titles">
        [slogan]
    </div>
</div>

Then str_replace will replace it for the actual variable as long as i have

$content['content'] = str_replace("[slogan]", $config['slogan'], $content['content']);

Yes the configuration table is the first query and stored in the array config - its all working fine as it contains the site name which is being called fine,

Im not sure your getting what i mean - il post some of my code
$config = mysqli_fetch_array(mysqli_query($con,"SELECT * FROM configuration")); first call to the database then next is all the header information E.g meta tags and title

Then called is the site content depending on the page i have the htaccess to rewrite the filename as /home/title-of-page to index.php?page=title-of-page etc...

Once the page has been called i have some code which selects the content depending on the /home/$

$url = mysqli_real_escape_string($con, getFile());
$getPages = mysqli_query($con,"SELECT * FROM pages WHERE title = '$url'");
$content = mysqli_fetch_array($getPages);

once in the database the title of the page gets shortened down into 30 chararacters and has str_replace " ", "-" so the final link to the webpages are www.website.com/home/first-page-content etc...

one page that i am calling i have this stored in that database

<div class="row-2">
    <div class="titles">
        <?=$config['slogan']?>
    </div>
</div>

and i need to change the <?=$config['slogan']?> into the actual slogan which is held in the array $content['main_content']

i have tried to use str_replace to replace it but have had no avail.

look up mysqli in the php.net manual to see how to get your info out. DOn't use mysql - it's soon to die.

this is my first website in mysqli im use to mysql and have hardly used mysqli before ...

Do you mean a form or DB table?

I have 2 DB tables one called configuration and one called content - The configuration has the site name, title, slogan etc... and the content holds the page content

<div class="row-2">
    <div class="titles">
        <?=$config['slogan']?>
    </div>
</div>

is stored in the content table but i need to access the config['slogan'] from the configuration table...

I want to know if its possible to store php variables in mysql database i currently have a text field which stores the value

<div class="row-2">
    <div class="titles">
        <?=$config['slogan']?>
    </div>
</div>

this is the slogan for the website that is in anther table which is got before this - if i try and echo all that out it puts html comments around it so i get <!--$config['slogan']-->

if i use str_replace i get nothing from it - is it actually possible to change that into PHP without to much fuss or do i have to find anther way?

Used Ajax

I have a online photo gallery and when you hover over a image an edit button appears that opens up a jquery prompt box in which you enter the caption after this has been entered i have the following code

var caption=prompt("Please enter new caption"," ");
    if (caption!=null)
    {
    var link = "?id="+ $(this).parents('.thumbnail').attr('id') + "&c=" + caption;
    $.post("../photo_c.html"+link);
    //alert($(this).parents('.thumbnail').attr('id'));  

    $("#loaddiv").slideUp(300).delay(800).fadeIn('3000');
    }

This should refresh the div but it wont it flashes but the PHP caption that comes from the database wont change even tho the script at photo_c.html is changing it and working, i have been informed to change it to this

var caption = prompt("Please enter new caption", " ");
if (caption != null) {
    var link = "?id=" + $(this).parents('.thumbnail').attr('id') + "&c=" + caption;
    $.post("../photo_c.html" + link,function(){
        $("#loaddiv").html(caption).slideUp(300).delay(800).fadeIn('3000');
    });      
}

But that refreshes div but only shows the caption that was entered not the actual data that belongs in the div the content is

<ul class="thumbnails gallery" id="loaddiv">
<?php 
$get_all_pics = mysql_query("SELECT * FROM gallery_photos");
while ($photos = mysql_fetch_array($get_all_pics)) {
    echo 
 '<li id="'.$photos['photo_id'].'" class="thumbnail">
    <a data-rel="popover" data-content="'.$photos['photo_caption'].'" style="background:url(/images/'.$photos['photo_filename'].')" title="Caption" href="/images/'.$photos['photo_filename'].'"><img class="grayscale" src="/images/'.$photos['photo_filename'].'" alt="'.$photos['photo_caption'].'"></a>
  </li>';
}
?>
</ul>

as you can see i need to update the captions that show on the images by refreshing the div -

Any help would be greatly appricated

fixed it... forget to use a .=

Hello, im after merging two strings togther from a for each loop.

here is what i have

[CODE]
foreach($html->find('div[class=product_description]') as $post)
{
$desc_html_puller = preg_replace("/<.*?>/", "", $post);
echo $post
}
[/CODE]

that does the trick but i want to use the $post variable out of the for each loop, but when i do it only brings the first variable out

yes i thought with all the info in a array it would be alot easier to pass around the loads of variables,

and the tutorials i have seen about loops on smarty has all been with arrays

Hello,

i have managed to get hold of social engine and trying to edit the profile script to create a friends list like facebook instead of it saying i have so many friends,

This is my first time using smarty so im still learning

this is my profile.php
[CODE]
$page_id = $_GET['user'];
$sql = "SELECT FROM se_friends WHERE friend_user_id1 = '$page_id' AND friend_status = '1' LIMIT 0,9";
$mysql = mysql_query($sql) or die (mysql_error());
$all_friends = array();
$all_info = array();
while ($rows = mysql_fetch_array($mysql))
{
$friend_id = $rows['friend_user_id2'];
$query = "SELECT
FROM se_users WHERE user_id = '$friend_id'";
$mysql = mysql_query($query) or die(mysql_error());
while($get = mysql_fetch_array($mysql))
{
array_push($all_info, $get);
}
}

$smarty->assign("friends_list", $all_info);
[/CODE]

then profile.tpl
[CODE]
{section name=i loop=$friends_list}
<td><img class='photo' src='./images/nophoto.gif' width="50" height="50" align="absmiddle" border='0'><a style="padding-left:5px" href="profile.php?user={$friends_list[i].user_id}">{$friends_list[i].user_displayname}</a></td>
{/section}
[/CODE]

the first mysql statment works perfectly but the second one is not it only gets one results

im my database is [CODE]welcome $username[/CODE]

when the user logs in i want to be able to show the messge from database but with the users username in the place of $username

i have tried that but all i get is $username not the persons username.

Hello,

im unsure how to fetch a database row that includes php,

i have a row in my database that displays a marquee saying 'welcome $username'

i have connected to the database but the php on page shows 'welcome $username'
how would i get it to state the username instaed of $username

[CODE]
$query = mysql_query("SELECT * FROM marquees");
$results = mysql_fetch_array($results);

$home = $results['home'];

echo $home;
[/CODE]

Hello im creating a small social network from scratch and struggling with the newsfeed i have the newsfeed loaded through ajax then page loaded remotly i have a timeago jquery script and the timeago script is not working, but when i get rid of the ajax auto refresh and use the code without the auto refresh it works

here is the coding that wont work

home.php
[CODE]

<script type="text/javascript">
function Ajax(){
var xmlHttp;
try{
xmlHttp=new XMLHttpRequest();// Firefox, Opera 8.0+, Safari
}
catch (e){
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer
}
catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
alert("No AJAX!?");
return false;
}
}
}

xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
document.getElementById('Comments').innerHTML=xmlHttp.responseText;
setTimeout('Ajax()',100);
}
}
xmlHttp.open("GET","feed.php",true);
xmlHttp.send(null);
}

window.onload=function(){
setTimeout('Ajax()',100);
}
</script>

<div id="Comments">
</div>
[/CODE]

feed.php
[CODE]
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script src="jquery.timeago.js" type="text/javascript"></script>
<script src="test_helpers.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
prepareDynamicDates();
$("abbr.timeago").timeago();
});

</script>

<!-- the above code is the timeago script -->
<?php
$query = mysql_query("SELECT FROM user_streams WHERE wall_id = '$uid' order by id desc limit 0,25");
while ($get_info_user = mysql_fetch_array($query))
{
$get_info = mysql_query("SELECT
FROM user WHERE user_id = '$get_info_user[user_id]'");
$get_in = mysql_fetch_array($get_info);
$del = "";
$date = $get_info_user[created];

        if($user_id == $get_in[user_id])
        {
            $del = "<a href=\"#\"><img border=\"none\" src=\"../icons/btn_window_close.gif\"></a>";
        }
        echo "
        <table width=\"80%\">
        <tr>                                    
        <td width=\"7%\"><img src=\"../images/avatarpic-s.png\" border=\"none\" align=\"absmiddle\" /></td>
        <td width=\"87%\"><a href=\"profile.php?id=$get_in[user_id]\" style=\"text-decoration:none;\"><b>$get_in[full_name]</b></a></td>
        <td align=\"right\">$del</td>
        </tr>
        <tr>
        <td width=\"7%\"></td>
        <td width=\"87%\">$get_info_user[message]</td>
        </tr>
        <tr>
        <td width=\"7%\"></td>

// this line is what uses the time ago and show change $date into %minutes ago
\/ \/ \/ \/

<td ...

i have a array which contains then numbers 1,2,3 etc... i want to connect to my mysql database and collect the information from the databse where the id column is = either 1 / 2 / 3 etc...

how would i go about this?

[QUOTE=nats01282;1552450][B][U]code to set a user online[/U][/B]
what you could do which im am gonna do is check the users are friends then on every link that user clicks it update's the (lets say) Time table with there id and the time + X mins.

[B][U]now with the other friend looking to see who is online[/U][/B]
check the time table for friends and check the friends to see if the current time is less then time + X mins if so we know that friend is online[/QUOTE]

you could also try creating a php/mysql chat with this i have done it once and it worked fair well

[B][U]code to set a user online[/U][/B]
what you could do which im am gonna do is check the users are friends then on every link that user clicks it update's the (lets say) Time table with there id and the time + X mins.

[B][U]now with the other friend looking to see who is online[/U][/B]
check the time table for friends and check the friends to see if the current time is less then time + X mins if so we know that friend is online

hello,

on my website's homepage/login page im after a newsfeed like facebooks.

If its your first time to the site you will view a random few post's from people,

But if your a member and have signed up it will just show your friends.

currently i have a function

[CODE]

function friends_streams ($uid)
{
$res = mysql_query("SELECT * FROM friends WHERE uid='$uid'");
while ($row = mysql_fetch_array($res))
{
$fids[] = $row['fid'];

}
if (is_array($fids))
{
array_push($fids, $uid);

foreach ($fids as $value)
{
$my_in = mysql_query("SELECT * FROM accounts where id = '$value' ORDER BY id DESC");
$my_info = mysql_fetch_array($my_in);

// output the users comments here
}
}
}
[/CODE]

but the trouble is it orders the post not by the newest but by the friend's id going in order e.g

people | ID numbers
you | 1
friend 1 | 2
friend 2 | 3
friend 3 | 4

friend 3 writes a post - it will show at the top.
friend 2 then writes a post after f3 - still at the top.
friend 3 writes a new post and it shows up in the middle,

hope you understand whaat i mean because its very hard to explian whats happening

fixed it all i used was

[CODE]
if ($name == '' || $name == '<?php echo $firstname ?>')[/CODE]

Hello i am creating a small forum and having trouble with the user sign up form.

i have the start of a sign up form on the index page then that jumps to the sign up page with more info, e.g...

index.php
[CODE]
<form action="signup.php" method="post">
name:
<input type="text" name="name" >
email:
<input type="text" name="email" >
<input type="submit">
</form>
[/CODE]

signup.php
[CODE]
<?php
$name = $_POST['name'];
$email = $_POST['email'];
?>
<form action="signup.php" method="post">
name:
<input type="text" name="name" value="<?php echo $name ?>" >
email:
<input type="text" name="email" value="<?php echo $email ?>" >
confirm email:
<input type="text" name="email2" >
password:
<input type="password" name="pass" >
<input type="hidden" name="flag" value=1>
<input type="submit">
</form>
<?php
if (isset($_POST['flag']))
{
$name = $_POST['name'];
if ($name == '')
{
echo "<script>javascript: NoName();</script>"
}
}
?>
[/CODE]
and so on.

how would i get past this error as name does hold some info it holds the <?php echo $name ?>

but when i try to do
[CODE]
if ($name == '<?php echo $name ?>')
{
//do error
}
if ($name != '<?php echo $name ?>')
{
//carry on as normal and check rest
}
[/CODE]

nothing happens i get no errors... what can i use??

as i have said im trying to create a script that will allow for the user to click a link and pop up page opens up with the content from the same page...

i have put the code on that i have written but its not working? thts why i posted it

[QUOTE=smantscheff;1485002]So what?[/QUOTE]

Thanks for the help !!!

Hello i am trying to create a script that will allow for the user to click a link and pop up page opens up with the content from the same page
e.g
[CODE]
<?php
$option = $_GET['option'];
?>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function topWindow(){
popup = window.open("page1.php?option=<?php echo $option; ?>","scrollbars=no");
}
// End -->
</SCRIPT>

<?php
// list
echo "<a href=$PHP_SELF?option=1 onclick=\"topWindow()\">Link 1 </a>";
echo "<a href=$PHP_SELF?option=2 onclick=\"topWindow()\">Link 2 </a>";
echo "<a href=$PHP_SELF?option=3 onclick=\"topWindow()\">Link 3 </a>";

if ($option == 1)
{
// show this data in pop up
}
if ($option == 2)
{
// show this data in pop up
}
?>
[/CODE]

yep thank you

Thank you ardav that solved my problem and yes it was needed in a while loop as i was extracting loads of info about the database but managed to work around the code

[CODE]
//database connection stuff
while($info = mysql_fetch_array($information))
{
echo $info[message]."<br>";
}
[/CODE]

this is all i got how would i split the array $info[message] and put a <br> every 5 words or so?

BUMP!

i need a piece of code to break down the data brought in from the MYSQL database
im creating a small forum type on my website but with my layout if the user writes 5 lines it shows it all on 1 line and shows the bottom scroll bar,

i under stand that there is a for statement that will do it but unable to think of what the code is can any 1 help me out on this, thank you

Found the error was trying to insert data that had allready been inserted. changed the INSERT to UPDATE and all is fine now

Hello i am after creating a javascript alert box with a text input and a submit button that when the submit button is pressed the text field will save its self into a php variable that will then be inserted into the a database.

here is the code i have so far

[CODE]
if($Petname == '')
{ ?>
<body onload='javascript: jQuery.facebox("<div align=\"center\">Enter your pets Name: <input type=\"text\" name=\"pet\" ><br /><br /><input type=\"submit\"></div> ");'></body>
<?php }
[/CODE]
how would i retrieve the variable from the javascript and store it into php?