Hi guys, ive been developing my own forum software.
I am up to the stage of viewing smileys on a post once a string has been called, can anyone help me think of a solution if a string is called example it will convert to output html image code?
Sorry trying to get it to work but im just confusing myself, this is what i have:
My smileys are stored in a database with tables SmileyImage and SmileyCode
Smiley code is the code to activate the smiley, example and smileyimage is the name of the smiley, example happy.gif.
I also have a code which displays text from a forum message which if the smileycode is called it will change it into the html code example, <img src=âimages/smileys/<?= $qry13[SmileyImage]â> This comes from the string $mtext. When the code has been processed with the smileys i want the new string to be named $finalmessage.
My code below exports a loop of the smileys from the database:
$result = mysql_db_query($dbname, "SELECT * FROM forum_smileys ");
if (mysql_num_rows($result)) {
while ($qry13 = mysql_fetch_array($result)) {
$finalmessage = substr_replace($qry13[SmileyCode], "<img src='../images/smileys/$qry13[SmileyImage]'>", 0);
}
}
My smileys are stored in a database with tables SmileyImage and SmileyCode
$result = mysql_db_query($dbname, "SELECT * FROM forum_smileys ");
So the first statement should have been âMy smilies are stored in a database table called forum_smileys with fields SmileyImage and SmileyCodeâ. But thatâs just grammatical.
while ($qry13 = mysql_fetch_array($result)) {
You meant to use mysql_fetch_assoc here, not fetch_array.
mysql_fetch_assoc() is equivalent to calling mysql_fetch_array() with MYSQL_ASSOC for the optional second parameter.
mysql_fetch_assoc() is also doesnât really need to exist because it just returns the key names insted of Numeric keys and key names which happens in mysql_fetch_array.
âAssociative arraysâ returned by mysql_fetch_assoc() are arrays with key names so, theyâre more human readable.
Some times mysql_fetch_assoc() is faster than mysql_fetch_array() .
mysql_fetch_assoc() may also need less memory as it generates an array of key names instead of keynames and key indexes in mysql_fetch_array().
Sorry just abit confused now, we need to detect the smileys from $qry[âMessageTextâ] how can we incorperate so $finalmessage replaces the smiley codes with the image?
fetch_assoc will be faster because it retrieves/holds 1/2 the data that fetch_array does. (without an argument, array fills BOTH, so will hold both numeric and associative keys)
And⌠yes, youâve gotten your commands mixed up. substr != str.