Jump to content

[SOLVED] What wrong with this? User ID seems to wreck it...


forumnz

Recommended Posts

  • Replies 92
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Yup im sure and I realize that Im probably not meant to connect to the database 5 times =)

 

<?php require('require.php'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Designer Vision - Adventure Plan</title>
<style type="text/css">
<!--
ul{
list-style-image:url(file:///C|/Documents and Settings/Owner/My Documents/Sam/samweb/../images/../images/arrow2.jpg);
}
.style4 {font-size: 18px; color: #3A3A3A; font-weight: bold; }
.style6 {font-size: 12px; color: #3A3A3A; text-decoration: none; }
.style11 {font-size: 22px; color: #5B5E71; font-weight: bold; }
.style13 {font-size: 14px; color: #3A3A3A; text-decoration: none; font-weight: bold; }
.style14 {color: #3A3A3A; text-decoration: none; font-size: 14px;}
.style17 {color: #333333}
.style19 {color: #000000}
.style20 {color: #5B5E71}
.style1 {	font-size: 16px;
color: #3A3A3A;
text-decoration:none;
}
.style21 {font-size: 16px; color: #3A3A3A; font-weight: bold; }
.style66 {font-size: 14px; color: #3A3A3A; text-decoration:underline; font-weight:bold; }
.style57 {font-size: 12px; color: #3A3A3A; text-decoration: underline; }
ul{
list-style-image:url(../images/arrow2.jpg);
}
.style69 {font-size: 14px; color: #FF0000; font-weight: bold; }
-->
</style>
</head>

<body background="bg.gif">
<table width="100%" border="0" align="center">
  <tr>
    <td height="24"> </td>
  </tr>
  <tr>
    <td><table width="760" height="885" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="760" height="240" background="../images/webtop.gif"><table width="100%" height="240
	" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td width="760" height="240"><table width="94%" height="207" border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td height="53"> </td>
                  </tr>
                  <tr>
                    <td height="127"> </td>
                  </tr>
                  <tr>
                    <td height="20" class="style13"><div align="right" class="style14"><a href="index.php" class="style14">home</a>  <a href="services.php" class="style14">services</a>   <a href="portfolio.php" class="style14">portfolio</a>   <a href="plans.php" class="style14">plans</a>   <a href="contact.php" class="style14">contact</a>  </div></td>
                  </tr>
              </table></td>
            </tr>
        </table></td>
      </tr>
      <tr>
        <td height="605" background="../images/webrep.gif"><table width="96%" height="605" border="0">
          <tr>
            <td width="3%" height="400" rowspan="3"> </td>
            <td width="22%" rowspan="3" align="center" valign="top" class="style4"><?php include("../menu.php"); ?></td>
            <td width="4%" rowspan="3"> </td>
            <td height="544" valign="top" class="style13"><table width="100%" border="0">
              <tr>
                <td><div align="right">
                  <?php include("log.php")
			?>
                </div></td>
              </tr>
            </table>
            <p>Here is the progress of your site. </p>
              <p>Please note that this will be updated daily or whenever more work for your site is completed. </p>
              <table width="100%" border="0">
                <tr>
                  <td><?php

$database=mysql_connect("localhost","***","**");

mysql_select_db("test",$database);
//echo $userid;
$query="select * from members WHERE userid=$userid";


$result = mysql_query($query) or die(mysql_error());


while($img=mysql_fetch_assoc($result)){

$image_num=$img['stg1'];

if($image_num=="0"){

echo"<img src='images/not_completed.gif' />";

}elseif($image_num=="1"){

echo"<img src='images/completed.gif' />";

}else {

echo" sorry there is no images to show";

}
}
?></td>
                </tr>
                <tr>
                  <td>
			  /*<?php

$database=mysql_connect("localhost","***","**");

mysql_select_db("test",$database);
//echo $userid;
$query="select * from members WHERE userid=$userid";


$result = mysql_query($query) or die(mysql_error());


while($img=mysql_fetch_assoc($result)){

$image_num=$img['stg2'];

if($image_num=="0"){

echo"<img src='images/not_completed.gif' />";

}elseif($image_num=="1"){

echo"<img src='images/completed.gif' />";

}else {

echo" sorry there is no images to show";

}
}
?></td>
                </tr>
                <tr>
                  <td><?php

$database=mysql_connect("localhost","***","**");

mysql_select_db("test",$database);
//echo $userid;
$query="select * from members WHERE userid=$userid";


$result = mysql_query($query) or die(mysql_error());


while($img=mysql_fetch_assoc($result)){

$image_num=$img['stg3'];

if($image_num=="0"){

echo"<img src='images/not_completed.gif' />";

}elseif($image_num=="1"){

echo"<img src='images/completed.gif' />";

}else {

echo" sorry there is no images to show";

}
}
?></td>
                </tr>
                <tr>
                  <td><?php

$database=mysql_connect("localhost","***","**");

mysql_select_db("test",$database);
//echo $userid;
$query="select * from members WHERE userid=$userid";


$result = mysql_query($query) or die(mysql_error());


while($img=mysql_fetch_assoc($result)){

$image_num=$img['stg4'];

if($image_num=="0"){

echo"<img src='images/not_completed.gif' />";

}elseif($image_num=="1"){

echo"<img src='images/completed.gif' />";

}else {

echo" sorry there is no images to show";

}
}
?></td>
                </tr>
                <tr>
                  <td><?php

$database=mysql_connect("localhost","***","**");

mysql_select_db("test",$database);
//echo $userid;
$query="select * from members WHERE userid=$userid";


$result = mysql_query($query) or die(mysql_error());


while($img=mysql_fetch_assoc($result)){

$image_num=$img['stg5'];

if($image_num=="0"){

echo"<img src='images/not_completed.gif' />";

}elseif($image_num=="1"){

echo"<img src='images/completed.gif' />";

}else {

echo" sorry there is no images to show";

}
}
?>*/</td>
                </tr>
              </table>              
              <p> </p></td>
          </tr>
          
          <tr>
            <td valign="top"><div align="center"><a href="contact.php" class="style66">Contact Us</a></div></td>
          </tr>
          
          
          <tr>
            <td> </td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td width="760" height="40" background="../images/webbot.gif"> </td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>

Link to comment
Share on other sites

As long as all your queries are from the same db you only need to connect and select db once.

 In addition you have this for every query:

$query="select * from members WHERE userid=$userid";

 

This is telling it to select nothing from the db.

Should be something like select img or something.

You need to tell the db what you want selected from it.

In your table there is a field that you want brought to the page.

What is it?

Link to comment
Share on other sites

ya '$userid' would maybe change something but it could still work without them if its only numbers after all if it has a space after the number lets say  $userid= "    3";  that would give a error and you have to use quotes than but well I guess he solved it

Link to comment
Share on other sites

Isnt is in this part?

 

$query="select * from members WHERE userid=$userid";

 

Anyway, I have simplified it. Here is it:

 

<?php require('require.php'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>

<?php

$database=mysql_connect("localhost", "aaaa", "aaaaa");

mysql_select_db("test",$database);
echo $userid;
$query="select * from members WHERE userid=$userid";


$result = mysql_query($query) or die(mysql_error());


while($img=mysql_fetch_assoc($result)){

$image_num=$img['stg1'];

if($image_num=="0"){

echo"<img src='images/not_completed.gif' />";

}elseif($image_num=="1"){

echo"<img src='images/completed.gif' />";

}else {

echo"sorry there is no images to show";

}
}
?>

</body>
</html>

Link to comment
Share on other sites

It also needs to be identified in the php. The query uses userid from php to relate to your table. Usually it is defined as a post userid or a session userid.

Somewhere in the code before the query it should have

$userid= then after the equal sign you define what exactly it is.

 

What I am trying to say is, how does this php file identify with $userid?

POST from a form, a session, or does it need passed on from the previous web page?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.