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.

7 participants
wapmetal Lead · 609 posts #21

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...

something else Fellow · 2,296 posts #22

why do u need to call pic from database for a second time?

$rooms = mysql_query("SELECT id, name, pass, picFROM ibwf_rooms WHERE static='0'");

$wapmetal = mysql_fetch_array(mysql_query("SELECT picFROM 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?

something else Fellow · 2,296 posts #23

just change: $ilink = "<img src="../rwidc.php?id=$uid" alt="*"/>"; to what ever standard image you want

something else Fellow · 2,296 posts #24

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."'

Leviathan73 Senior · 260 posts #25

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..

wapmetal Lead · 609 posts #26

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...

wapmetal Lead · 609 posts #27

tnt

something else wrote: why do u need to call pic from database for a second time?

$rooms = mysql_query("SELECT id, name, pass, picFROM ibwf_rooms WHERE static='0'");

$wapmetal = mysql_fetch_array(mysql_query("SELECT picFROM 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

something else Fellow · 2,296 posts #28

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)

Leviathan73 Senior · 260 posts #29

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..

something else Fellow · 2,296 posts #30
        $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."'");
Leviathan73 Senior · 260 posts #32

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

something else Fellow · 2,296 posts #33

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

Leviathan73 Senior · 260 posts #38

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 ..

Leviathan73 Senior · 260 posts #40

chat.php files but perhaps lacking a reference code?

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close