Jump to content


Photo

Res diffrent image for table value "FIXED THANKS TO AndyB"


  • Please log in to reply
32 replies to this topic

#1 Gregg

Gregg
  • Members
  • PipPipPip
  • Advanced Member
  • 61 posts
  • LocationUSA

Posted 03 September 2006 - 08:41 PM

???
Ok, i want to make it so when it checks there "premium status" it will res an image instead of the letter.
The table is stores in the 'users', under 'premium' Y=Paid N=Free, and the photos are stored in 'images/'

#2 pocobueno1388

pocobueno1388
  • Members
  • PipPipPip
  • Advanced Member
  • 3,369 posts
  • LocationPalm Beach, Florida

Posted 03 September 2006 - 08:45 PM

Try:


<?php
 $sql1="select * from  loggedin where username='$identity' and main='Y'";
$res1=mysql_query($sql1,$db);
$row1=mysql_fetch_array($res1);
	 
	if($row1[ROWNAME] == 'Y'){
		 $images/=$row1["SilverMember.gif"];
	} else {
		$images/="Free_Member.gif";

}//end if

?>



#3 radar

radar
  • Members
  • PipPipPip
  • Advanced Member
  • 645 posts
  • LocationSLC

Posted 03 September 2006 - 08:59 PM

First off neither code will work I don't think.. So here is a code that should work..  I am just working off what you've got here and not re-writing the whole thing...  I'm not going to be re-writing the whole thing just some of it..

<?php
 $sql1="select * from  loggedin where username='$identity' and main='Y'";
$res1=mysql_query($sql1,$db);
$row1=mysql_fetch_array($res1);
	 
	if($row1[main] == 'Y'){
$images = "images/silvermember.gif";
	} else {
		$images = "images/freemember.gif";
}//end if
echo '<img src='.$images.'/>';
?>



this code should work...  the reason why the other wouldnt work is because #1 where it sets the image the syntax appears to be all wrong...  And then of course it doesnt echo out the image code to print the image to the end user...  Since in the $row1 array there is more than likely not an entry called SilverMember.gif or Free_Member.gif that is an obvious flaw in the coding...  In the original code there were a lot more errors than that though were fixed by paco..  though some errors were still left -- the code i have provided should do the job.

Now I'm not sure what you are building -- though if $identity contains the username of a person who is logged in.. ie the end user..  The image will only show up under their name for them if they are online which defeats the purpose because if they are online they know they are online..  So anyway hope the code helps..

#4 Gregg

Gregg
  • Members
  • PipPipPip
  • Advanced Member
  • 61 posts
  • LocationUSA

Posted 03 September 2006 - 09:20 PM

No, this is in the profiles, so it will let a user know if they are free or paid. For other users to view lol.
Nope, it said not a valid resource.
So i changed it, and i notced in the head i allready had the call function so it noght be to blam cause i use it to call the members photo.
So i need to get it a diffrent way. OH I MENT "premium" THERE PAID LEVEL...
Here is the head code, any thoughts on how to call it using it and loading the correct image?

<?
include("cookie.php");
include("connect.php");

$sql1="select * from users where identity='$UsErCoOkIe'";
$res1=mysql_query($sql1,$db);
$row1=mysql_fetch_array($res1);
$cuserid=$row1["userid"];

$sql="select *,date_format(joiningdate,'%e') as day ,date_format(joiningdate,'%b') as mon ,date_format(joiningdate,'%Y') as yr from users where userid='$id'";
$res=mysql_query($sql,$db);
$row=mysql_fetch_array($res);
$userid=$row["userid"];
$identity=$row["identity"];

if($cuserid!=$userid)
{
	$rescheck=mysql_query("select * from whochecked where who='$UsErCoOkIe' and userid='$userid'",$db);
	$totcheck=mysql_num_rows($rescheck);
	if($totcheck>0)
		mysql_query("update whochecked set time=now(), new='Y' where userid='$userid' and who='$UsErCoOkIe'",$db);
	else
		mysql_query("insert into whochecked(userid,who, time, new) values('$userid', '$UsErCoOkIe',now(),'Y')",$db);
}	
	 $sql1="select * from photo where username='$identity' and main='Y'";
	 $res1=mysql_query($sql1,$db);
	 $row1=mysql_fetch_array($res1);
	 
	if($row1["photo"])
		 $photo=$row1["photo"];
	else
		$photo="No_Photo.gif";

  $PRODUCTIMAGES="photoimage/";
  $sql="select * from users where identity='$UsErCoOkIe'";
  $result=mysql_query($sql,$db);
  $row7=mysql_fetch_array($result);
  $id1=$row7["userid"];
									 
?>

Here is the code i modifyed it dongt get an error but dont pull the pic eather haha.
<?php
	if($row1[premium] == 'Y'){
$images = "images/silvermember.gif";
	} else {
		$images = "images/freemember.gif";
}//end if
echo '<img src='.$images.'/>';
?>


#5 radar

radar
  • Members
  • PipPipPip
  • Advanced Member
  • 645 posts
  • LocationSLC

Posted 03 September 2006 - 09:39 PM

change premium back to how I had it main...  that is how you need it because of this...

$sql1="select * from photo where username='$identity' and main='Y'";

main="Y" now if you have a row in your database where premium = Y too then that should work as it.. but try changing premium to main and it should work...

#6 Gregg

Gregg
  • Members
  • PipPipPip
  • Advanced Member
  • 61 posts
  • LocationUSA

Posted 03 September 2006 - 09:43 PM

I placed it like this:
<?php
 $sql1="select * from  premium where username='$identity' and main='Y'";
$res1=mysql_query($sql1,$db);
$row1=mysql_fetch_array($res1);

	if($row1[main] == 'Y'){
$images = "images/SilverMember.gif";
	} else {
		$images = "images/FreeMember.gif";
}//end if
echo '<img src='.$images.'/>';
?>

But still got erros!

#7 radar

radar
  • Members
  • PipPipPip
  • Advanced Member
  • 645 posts
  • LocationSLC

Posted 03 September 2006 - 10:02 PM

What errors are you getting?  Also on the page if it is trying to do an image.. right click on it and hit properties and make sure it is giving you the right url...

#8 Gregg

Gregg
  • Members
  • PipPipPip
  • Advanced Member
  • 61 posts
  • LocationUSA

Posted 03 September 2006 - 10:08 PM

Yes its the right location but it keeps saying:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/viewprofile.php on line 133

Is it saying that cause i allready called the info in the head:

<?
include("cookie.php");
include("connect.php");

$sql1="select * from users where identity='$UsErCoOkIe'";
$res1=mysql_query($sql1,$db);
$row1=mysql_fetch_array($res1);
$cuserid=$row1["userid"];

$sql="select *,date_format(joiningdate,'%e') as day ,date_format(joiningdate,'%b') as mon ,date_format(joiningdate,'%Y') as yr from users where userid='$id'";
$res=mysql_query($sql,$db);
$row=mysql_fetch_array($res);
$userid=$row["userid"];
$identity=$row["identity"];

if($cuserid!=$userid)
{
	$rescheck=mysql_query("select * from whochecked where who='$UsErCoOkIe' and userid='$userid'",$db);
	$totcheck=mysql_num_rows($rescheck);
	if($totcheck>0)
		mysql_query("update whochecked set time=now(), new='Y' where userid='$userid' and who='$UsErCoOkIe'",$db);
	else
		mysql_query("insert into whochecked(userid,who, time, new) values('$userid', '$UsErCoOkIe',now(),'Y')",$db);
}	
	 $sql1="select * from photo where username='$identity' and main='Y'";
	 $res1=mysql_query($sql1,$db);
	 $row1=mysql_fetch_array($res1);
	 
	if($row1["photo"])
		 $photo=$row1["photo"];
	else
		$photo="No_Photo.gif";

  $PRODUCTIMAGES="photoimage/";
  $sql="select * from users where identity='$UsErCoOkIe'";
  $result=mysql_query($sql,$db);
  $row7=mysql_fetch_array($result);
  $id1=$row7["userid"];
									 
?>


#9 radar

radar
  • Members
  • PipPipPip
  • Advanced Member
  • 645 posts
  • LocationSLC

Posted 03 September 2006 - 10:58 PM

Okay so what the code for view profile and what is line 133..

#10 Gregg

Gregg
  • Members
  • PipPipPip
  • Advanced Member
  • 61 posts
  • LocationUSA

Posted 04 September 2006 - 01:22 AM

The above code it to get the profile info, including there pic stats & so on.

Line:133
Is..
out of the code you posted!

<?php
$sql1="select * from  premium where username='$identity' and main='Y'";
$res1=mysql_query($sql1,$db);
$row1=mysql_fetch_array($res1); *****LINE 133*****

	if($row1[main] == 'Y'){
$images = "SilverMember.gif";
	} else {
		$images = "FreeMember.gif";
}//end if
echo '<img src='.$images.'/>';
?>


#11 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 04 September 2006 - 01:27 AM

OK, let's find out what the problem is ... change

$res1=mysql_query($sql1,$db);

to:
$res1=mysql_query($sql1,$db) or die("Error: ". mysql_error(). " with query ". $sql1); // display any problems


Legend has it that reading the manual never killed anyone.
My site

#12 Gregg

Gregg
  • Members
  • PipPipPip
  • Advanced Member
  • 61 posts
  • LocationUSA

Posted 04 September 2006 - 01:43 AM

Error: Table 'darkwate_DatingSite.premium' doesn't exist with query select * from premium where userid='Jewel36' and main='Y'

Ok, i notcied the first error was "username" it was supost to be "Userid"
so i changed it and fixed that error but it keeps trying to pull from a diffrent db?
I have a conect php all ready connected to the database, i just need it to read the premium table within the users table:

<?php
 $sql1="select * from  users where userid='$identity' and premium='Y'";
$res1=mysql_query($sql1,$db);
$res1=mysql_query($sql1,$db) or die("Error: ". mysql_error(). " with query ". $sql1); // display any problems

	if($row1[premium] == 'Y'){
$images = "SilverMember.gif";
	} else {
		$images = "FreeMember.gif";
}//end if
echo '<img src='.$images.'/>';
?>
No errors but blank pic??
The table that stores the users is "users" & userid" is the id, premium is the "N=FREE Y=PAID" & Images/ is the folder for the pics!

i removes the images/ to see if it was that not loading the pics but no its still blan "error pic"
********
*    X    *
*    X    *
********

#13 radar

radar
  • Members
  • PipPipPip
  • Advanced Member
  • 645 posts
  • LocationSLC

Posted 04 September 2006 - 01:55 AM

So if the connection is already there -- take out the ,$db in both and see what that does (if you've made a connection previous to calling this part of the script and this connection is still in place)...

remember to make sure its trying to display the correct picture.. copy the url and such into the browser and see if it comes up...  there may be a problem in that part...

in fact upon further inspection i think i found the problem...

try this..

<?php
 $sql1="select * from  users where userid='$identity' and premium='Y'";
$res1=mysql_query($sql1,$db);
$res1=mysql_query($sql1,$db) or die("Error: ". mysql_error(). " with query ". $sql1); // display any problems

	if($row1[premium] == 'Y'){
$images = "Images/SilverMember.gif";
	} else {
		$images = "Images/FreeMember.gif";
}//end if
echo '<img src='.$images.'/>';
?>

note: if the folder is images not Images lowecase the I -- otherwise it should work...

#14 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 04 September 2006 - 01:59 AM

Since the error shows the table does not exist in that database, it seems to me that you need to select the right database before querying the table ...

$db_name = "name of database containing the table named premium";
mysql_select_db($db_name) or die ("Error: Unable to open the database.");

Legend has it that reading the manual never killed anyone.
My site

#15 Gregg

Gregg
  • Members
  • PipPipPip
  • Advanced Member
  • 61 posts
  • LocationUSA

Posted 04 September 2006 - 02:02 AM

Still the image is blank...aaaaaaaaaaaa

Posted Image

I just had to use a simple, <? echo $row["loggedin"]?> to get her logged in info cause the head code all readt determand her id and info.

#16 radar

radar
  • Members
  • PipPipPip
  • Advanced Member
  • 645 posts
  • LocationSLC

Posted 04 September 2006 - 02:07 AM

Show an link to the image you want to show and show a link to the image it is trying to show..

#17 Gregg

Gregg
  • Members
  • PipPipPip
  • Advanced Member
  • 61 posts
  • LocationUSA

Posted 04 September 2006 - 02:51 AM

ok, all the pages "PHP" & folders are in the "datingsite/" folder so it souldent matter cause the connect.php loads it corectly!

Free gif:
Posted Image
http://darkwaterstud.../FreeMember.gif
Code: images/FreeMember.gif

And:
Posted Image
http://darkwaterstud...ilverMember.gif
Code: images/SilverMember.gif

As you can see the url is ok, and loads fine!

I decided to test it, so i erased the code and placed "<? echo $row["premium"]?>"
Works fine, it showed  a "N" or "Y"
But i just want it simple like that but with an image not text lol.

#18 radar

radar
  • Members
  • PipPipPip
  • Advanced Member
  • 645 posts
  • LocationSLC

Posted 04 September 2006 - 04:38 AM

okay so those work -- but now what about the url's the script is trying to load?

#19 Gregg

Gregg
  • Members
  • PipPipPip
  • Advanced Member
  • 61 posts
  • LocationUSA

Posted 04 September 2006 - 04:46 AM

HEAD:
<?
include("cookie.php");
include("connect.php");

$sql1="select * from users where identity='$UsErCoOkIe'";
$res1=mysql_query($sql1,$db);
$row1=mysql_fetch_array($res1);
$cuserid=$row1["userid"];

$sql="select *,date_format(joiningdate,'%e') as day ,date_format(joiningdate,'%b') as mon ,date_format(joiningdate,'%Y') as yr from users where userid='$id'";
$res=mysql_query($sql,$db);
$row=mysql_fetch_array($res);
$userid=$row["userid"];
$identity=$row["identity"];

if($cuserid!=$userid)
{
	$rescheck=mysql_query("select * from whochecked where who='$UsErCoOkIe' and userid='$userid'",$db);
	$totcheck=mysql_num_rows($rescheck);
	if($totcheck>0)
		mysql_query("update whochecked set time=now(), new='Y' where userid='$userid' and who='$UsErCoOkIe'",$db);
	else
		mysql_query("insert into whochecked(userid,who, time, new) values('$userid', '$UsErCoOkIe',now(),'Y')",$db);
}	
	 $sql1="select * from photo where username='$identity' and main='Y'";
	 $res1=mysql_query($sql1,$db);
	 $row1=mysql_fetch_array($res1);
	 
	if($row1["photo"])
		 $photo=$row1["photo"];
	else
		$photo="No_Photo.gif";

  $PRODUCTIMAGES="photoimage/";
  $sql="select * from users where identity='$UsErCoOkIe'";
  $result=mysql_query($sql,$db);
  $row7=mysql_fetch_array($result);
  $id1=$row7["userid"];
									 
?>

BODY:
<?php
$sql1="select * from users where identity='$UsErCoOkIe'";
$res1=mysql_query($sql1,$db);
$row1=mysql_fetch_array($res1);
$cuserid=$row1["userid"] or die("Error: ". mysql_error(). " with query ". $sql1); // display any problems

	if($row[premium] == 'Y'){
$images = "images/SilverMember.gif";
	} else {
		$images = "images/FreeMember.gif";
}//end if
echo '<img src='.$images.'/>';
?>


#20 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 04 September 2006 - 04:56 AM

<?php
$sql1="select * from users where identity='$UsErCoOkIe'";
$res1=mysql_query($sql1,$db) or die("Error: ". mysql_error(). " with query ". $sql1); // display any problems;
$row1=mysql_fetch_array($res1);

$cuserid=$row1["userid"]; // who knows that this means 

// and surely it's the row1 array we want to check
if($row1[premium] == 'Y') {
    $images = "images/SilverMember.gif";
} else {
    $images = "images/FreeMember.gif";
}//end if
echo '<img src='.$images.'/>';
?>

Legend has it that reading the manual never killed anyone.
My site




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users