Forums / WEB Development
Creates room with picture
Started on the old forum in November 2009 · view the original in the archive · old links redirect here
41 replies · 2,321 views · started 17 years ago · 1 min read
TL;DR · summary of 41 replies
- The code needs to be fixed so that when creating a new room, it displays an image above the room name. - Adding another input box for pic in index.php?action=mkroom and collecting it in genproc.php?action=mkroom is suggested as a solution. - There are two unresolved issues: one about images not loading properly and the other about multiple rooms showing duplicate pictures.
Written automatically from the replies by a language model on our own server. It can be wrong; the posts below are the source.
Sort replies:
Oldest
Top voted
Newest
WA
wapmetal wrote:
try this bro if it will work......
$rooms = mysql_query("SELECT id, name, pass, pic FROM ibwf_rooms WHERE static='0'");
$co=0;
while ($room= mysql_fetch_array($rooms))
{
$co++;
if(canenter($room[0], $sid))
{
$wapmetal = mysql_fetch_array(mysql_query("SELECT pic FROM ibwf_rooms WHERE rid='".$room[0]."'"));
if($wapmetal=="")
{
$wapmetal = "<img src=\"$wapmetal\" alt=\"*\"/><br/>";
echo "$wapmetal <a href=\"chat.php?&rid=$room[0]&sid=$sid\">".htmlspecialchars($room[1])."</a><br/>";
}else{
echo htmlspecialchars($room[1]);
echo "<form action=\"chat.php\" method=\"get\">";
echo "<br/><input format=\"*x\" name=\"rpw\" maxlength=\"10\"/><br/>";
echo "<input type=\"submit\" value=\"GO\"/>";
echo "<input type=\"hidden\" name=\"rid\" value=\"$room[0]\"/>";
echo "<input type=\"hidden\" name=\"sid\" value=\"$sid\"/>";
echo "</form>";
}
}
}
from select querry below u can also use this
$wapmetal = mysql_fetch_array(mysql_query("SELECT pic FROM ibwf_rooms WHERE id='".$room[0]."'"));
i havent try this and you must try it...
i dont use lava anymore...
why do u need to call pic from database for a second time?
$rooms = mysql_query("SELECT id, name, pass, pic FROM ibwf_rooms WHERE static='0'");
$wapmetal = mysql_fetch_array(mysql_query("SELECT pic FROM ibwf_rooms WHERE rid='".$room[0]."'"));
unnessary calls from database causes lag.
also your coding says if there is a picture on the room then it is password protected?
just change:
$ilink = "<img src="../rwidc.php?id=$uid" alt="*"/>";
to what ever standard image you want
you will need to add another input box on index.php?action=mkroom
eg:
echo "<input name="pic" maxlength="255" value="http://"/>";
and then on genproc.php?action=mkroom
you will need to collect the POST varible (pic) an insert it into database along with the original sql update
eg:
, pic='".$pic."'
LE
I did this in the file index.php
echo "<form action=\"genproc.php?action=pic&pic='".$pic."'\" method=\"post\">";
echo "<form action=\"genproc.php?action=mkroom&sid=$sid\" method=\"post\">";
echo "<form action=\"genproc.php?action=mkroom&sid=$sid\" method=\"post\">";
echo "Add Image:<input name=\"pic\" maxlength=\"255\" value=\"[URL]http://\"/><br/>";[/PHP[/URL]]
in the file chat.php done this
[PHP]$wapmetal = mysql_fetch_array(mysql_query("SELECT pic FROM ibwf_rooms WHERE rid='".$room[0]."'"));
$co=0;
while ($room= mysql_fetch_array($rooms))
{
$co++;
if(canenter($room[0], $sid))
{
$wapmetal = mysql_fetch_array(mysql_query("SELECT pic FROM ibwf_rooms WHERE rid='".$room[0]."'"));
if($wapmetal=="")
{
$wapmetal = "<img src=\"$wapmetal\" alt=\"*\"/><br/>";
echo "$wapmetal <a href=\"chat.php?&rid=$room[0]&sid=$sid\">".htmlspecialchars($room[1])."</a><br/>";
}else
{
echo htmlspecialchars($room[1]);
echo "<form action=\"chat.php\" method=\"get\">";
echo "<br/><input format=\"*x\" name=\"rpw\" maxlength=\"10\"/><br/>";
echo "<input type=\"submit\" value=\"GO\"/>";
echo "<input type=\"hidden\" name=\"rid\" value=\"$room[0]\"/>";
echo "<input type=\"hidden\" name=\"sid\" value=\"$sid\"/>";
echo "</form>";
}
}
}
and when I create room leads me to login on the home..
WA
Leviathan73 wrote:
I did this in the file index.php
echo "<form action=\"genproc.php?action=pic&pic='".$pic."'\" method=\"post\">";
echo "<form action=\"genproc.php?action=mkroom&sid=$sid\" method=\"post\">";
echo "<form action=\"genproc.php?action=mkroom&sid=$sid\" method=\"post\">";
echo "Add Image:<input name=\"pic\" maxlength=\"255\" value=\"http://\"/><br/>";[/PHP]
in the file chat.php done this
$wapmetal = mysql_fetch_array(mysql_query("SELECT pic FROM ibwf_rooms WHERE rid='".$room[0]."'"));
$co=0;
while ($room= mysql_fetch_array($rooms))
{
$co++;
if(canenter($room[0], $sid))
{
$wapmetal = mysql_fetch_array(mysql_query("SELECT pic FROM ibwf_rooms WHERE rid='".$room[0]."'"));
if($wapmetal=="")
{
$wapmetal = "<img src=\"$wapmetal\" alt=\"*\"/><br/>";
echo "$wapmetal <a href=\"chat.php?&rid=$room[0]&sid=$sid\">".htmlspecialchars($room[1])."</a><br/>";
}else
{
echo htmlspecialchars($room[1]);
echo "<form action=\"chat.php\" method=\"get\">";
echo "<br/><input format=\"*x\" name=\"rpw\" maxlength=\"10\"/><br/>";
echo "<input type=\"submit\" value=\"GO\"/>";
echo "<input type=\"hidden\" name=\"rid\" value=\"$room[0]\"/>";
echo "<input type=\"hidden\" name=\"sid\" value=\"$sid\"/>";
echo "</form>";
}
}
}
and when I create room leads me to login on the home..
i cant understand...
WA
tnt
something else wrote:
why do u need to call pic from database for a second time?
$rooms = mysql_query("SELECT id, name, pass, pic FROM ibwf_rooms WHERE static='0'");
$wapmetal = mysql_fetch_array(mysql_query("SELECT pic FROM ibwf_rooms WHERE rid='".$room[0]."'"));
unnessary calls from database causes lag.
also your coding says if there is a picture on the room then it is password protected?
lol wots the BIg thing on this??
i just forgot to remove the 'pic'
i used this
$wapmetal = mysql_fetch_array(mysql_query("SELECT pic FROM ibwf_rooms WHERE rid='".$room[0]."'"));
cus i was pointing in the rid='".$room[0]."' so it will surely follow its order
lol
yeah if u keep requesting from database it will cause you lag....
when u can request it at the same time .... both ways work but if you keep calling information every time you want a new variable from database you will end up with a very slow site
eg:
product | cost | stock
potatoes| 2.50 | 3000
oranges | 1.00 | 200
grapes | 1.70 | 500
ur coding first calls for the line say oranges in this case to see how many there is in stock...
(while your database has found oranges u could find cost out at same time.)
but instead your making the database re-find the line oranges for a second time to find out cost.
Thats why u can end up with a slow site if u make to many requests 🙂
So therefor requesting from this line:
$rooms = mysql_query("SELECT id, name, pass, pic FROM ibwf_rooms WHERE static='0'");
is quicker than requesting again for a second time here:
$wapmetal = mysql_fetch_array(mysql_query("SELECT pic FROM ibwf_rooms WHERE rid='".$room[0]."'"));
(even if pic wasnt in the top line)
LE
I changed that
$wapmetal = mysql_fetch_array(mysql_query("SELECT pic FROM ibwf_rooms WHERE "));
$co=0;
while ($room= mysql_fetch_array($rooms))
{
$co++;
if(canenter($room[0], $sid))
{
$wapmetal = mysql_fetch_array(mysql_query("SELECT pic FROM ibwf_rooms WHERE "));
but brings me to the login home..
$rooms = mysql_query("SELECT id, name, pass, pic FROM ibwf_rooms WHERE static='0'");
$co=0;
while ($room= mysql_fetch_array($rooms))
{
$ilink = trim($room[3]);
if($ilink=="")
{
$ilink = "<img src=\"default_image.gif\" alt=\"*\"/>";
}else{
$ilink = "<img src=\"$ilink\" alt=\"*\"/>";
}
$co++;
if(canenter($room[0], $sid))
{
$noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_chonline WHERE rid='".$room[0]."'"));
if($room[2]=="")
{
echo "$ilink <a href=\"chat.php?&rid=$room[0]&sid=$sid\">".htmlspecialchars($room[1])."($noi[0])</a><br/>";
}else{
echo htmlspecialchars($room[1]);
echo "$ilink <form action=\"chat.php\" method=\"get\">";
echo "<br/><input format=\"*x\" name=\"rpw\" maxlength=\"10\"/><br/>";
echo "<input type=\"submit\" value=\"GO\"/>";
echo "<input type=\"hidden\" name=\"rid\" value=\"$room[0]\"/>";
echo "<input type=\"hidden\" name=\"sid\" value=\"$sid\"/>";
echo "</form>";
}
}
}
echo "<form action=\"genproc.php?action=mkroom&sid=$sid\" method=\"post\">";
echo "Room Name: <input name=\"rname\" maxlength=\"30\"><br/>";
echo "Password: <input name=\"rpass\" style=\"-wap-input-format: '*x'\" maxlength=\"10\"><br/>";
echo "Pic Url: <input name=\"pic\" maxlength=\"255\" value=\"http://\"/><br/>";
echo "<input type=\"Submit\" name=\"Create\" Value=\"Create\"></form>";
$pic = mysql_escape_string($_POST["pic"]);
$pic = htmlspecialchars($pic);
$res = mysql_query("INSERT INTO ibwf_rooms SET name='".$rname."', pass='".$rpass."', censord='".$cns."', static='0', lastmsg='".time()."', pic='".$pic."'");
LE
something,
I do not understand why you can not see picture. I am in the database, table ibwf_rooms I only added this line
pic varchar(255) default=""
Perhaps I should say more .. boh
if your having trouble with trim remove it
change it to:
$ilink = $room[3];
if($ilink=="")
{
$ilink = "<img src="default_image.gif" alt=""/>";
}else{
$ilink = "<img src="$ilink" alt=" "/>";
}
also check to make sure the url is in the database
LE
Something_else, the imageis not seen
WA
If(!$ilink=="") i thnk it is lyk that. . uhm btw i already fix ths coding bout ur thread in my own site so wl gonna post it when my pc works again. . hehe
LE
changed, but the image is not seen 🙁
WA
can u post ur code ...maybe i have idea for that
LE
sorry, I was wrong to put the codes in the file, I put them right now! But there is a problem, when I create private room and insert an image from the image folder, the image you see in the database, but not in a private room, why? I tried with all codes and 2
$ilink = $room[3];
if($ilink=="")
{
$ilink = "<img src=\"../images/logo.gif\" alt=\"*\"/>";
}else{
$ilink = "<img src=\"$ilink\" alt=\"*\"/>";
}
and
$ilink = trim($room[3]);
if($ilink=="")
{
$ilink = "<img src=\"../images/logo.gif\" alt=\"*\"/>";
}else{
$ilink = "<img src=\"../uploaded/files/$ilink\" alt=\"*\"/>";
}
but not seen, is seen only in the database ..
LE
something else heeelppp!!!!!
LE
chat.php files but perhaps lacking a reference code?