Gregg Posted September 3, 2006 Share Posted September 3, 2006 ???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/' Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted September 3, 2006 Share Posted September 3, 2006 Try:[code]<?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?>[/code] Quote Link to comment Share on other sites More sharing options...
radar Posted September 3, 2006 Share Posted September 3, 2006 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..[code]<?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 ifecho '<img src='.$images.'/>';?>[/code]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.. Quote Link to comment Share on other sites More sharing options...
Gregg Posted September 3, 2006 Author Share Posted September 3, 2006 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?[code]<?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"]; ?>[/code]Here is the code i modifyed it dongt get an error but dont pull the pic eather haha.[code]<?php if($row1[premium] == 'Y'){$images = "images/silvermember.gif"; } else { $images = "images/freemember.gif";}//end ifecho '<img src='.$images.'/>';?>[/code] Quote Link to comment Share on other sites More sharing options...
radar Posted September 3, 2006 Share Posted September 3, 2006 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... Quote Link to comment Share on other sites More sharing options...
Gregg Posted September 3, 2006 Author Share Posted September 3, 2006 I placed it like this:[code]<?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 ifecho '<img src='.$images.'/>';?>[/code]But still got erros! Quote Link to comment Share on other sites More sharing options...
radar Posted September 3, 2006 Share Posted September 3, 2006 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... Quote Link to comment Share on other sites More sharing options...
Gregg Posted September 3, 2006 Author Share Posted September 3, 2006 Yes its the right location but it keeps saying:[code]Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/viewprofile.php on line 133[/code]Is it saying that cause i allready called the info in the head:[code]<?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"]; ?>[/code] Quote Link to comment Share on other sites More sharing options...
radar Posted September 3, 2006 Share Posted September 3, 2006 Okay so what the code for view profile and what is line 133.. Quote Link to comment Share on other sites More sharing options...
Gregg Posted September 4, 2006 Author Share Posted September 4, 2006 The above code it to get the profile info, including there pic stats & so on.Line:133Is..[code]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 ifecho '<img src='.$images.'/>';?>[/code] Quote Link to comment Share on other sites More sharing options...
AndyB Posted September 4, 2006 Share Posted September 4, 2006 OK, let's find out what the problem is ... change[code]$res1=mysql_query($sql1,$db);[/code]to:[code]$res1=mysql_query($sql1,$db) or die("Error: ". mysql_error(). " with query ". $sql1); // display any problems[/code] Quote Link to comment Share on other sites More sharing options...
Gregg Posted September 4, 2006 Author Share Posted September 4, 2006 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:[code]<?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 ifecho '<img src='.$images.'/>';?>[/code]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 ********* Quote Link to comment Share on other sites More sharing options...
radar Posted September 4, 2006 Share Posted September 4, 2006 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..[code]<?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 ifecho '<img src='.$images.'/>';?>[/code]note: if the folder is images not Images lowecase the I -- otherwise it should work... Quote Link to comment Share on other sites More sharing options...
AndyB Posted September 4, 2006 Share Posted September 4, 2006 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 ...[code]$db_name = "name of database containing the table named premium";mysql_select_db($db_name) or die ("Error: Unable to open the database."); [/code] Quote Link to comment Share on other sites More sharing options...
Gregg Posted September 4, 2006 Author Share Posted September 4, 2006 Still the image is blank...aaaaaaaaaaaa[img]http://darkwaterstudio.net/datingsite/ViewProfil_Test.gif[/img]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. Quote Link to comment Share on other sites More sharing options...
radar Posted September 4, 2006 Share Posted September 4, 2006 Show an link to the image you want to show and show a link to the image it is trying to show.. Quote Link to comment Share on other sites More sharing options...
Gregg Posted September 4, 2006 Author Share Posted September 4, 2006 ok, all the pages "PHP" & folders are in the "datingsite/" folder so it souldent matter cause the connect.php loads it corectly!Free gif:[img]http://darkwaterstudio.net/datingsite/images/FreeMember.gif[/img]http://darkwaterstudio.net/datingsite/images/FreeMember.gifCode: images/FreeMember.gifAnd:[img]http://darkwaterstudio.net/datingsite/images/SilverMember.gif[/img]http://darkwaterstudio.net/datingsite/images/SilverMember.gifCode: images/SilverMember.gifAs 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. Quote Link to comment Share on other sites More sharing options...
radar Posted September 4, 2006 Share Posted September 4, 2006 okay so those work -- but now what about the url's the script is trying to load? Quote Link to comment Share on other sites More sharing options...
Gregg Posted September 4, 2006 Author Share Posted September 4, 2006 HEAD:[code]<?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"]; ?>[/code]BODY:[code]<?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 ifecho '<img src='.$images.'/>';?>[/code] Quote Link to comment Share on other sites More sharing options...
AndyB Posted September 4, 2006 Share Posted September 4, 2006 [code]<?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 checkif($row1[premium] == 'Y') { $images = "images/SilverMember.gif";} else { $images = "images/FreeMember.gif";}//end ifecho '<img src='.$images.'/>';?>[/code] Quote Link to comment Share on other sites More sharing options...
Gregg Posted September 4, 2006 Author Share Posted September 4, 2006 Well i tryed it and it had no errors but the pic dident load..Same error pic "blank"WTF? Quote Link to comment Share on other sites More sharing options...
radar Posted September 4, 2006 Share Posted September 4, 2006 If you have msn messenger i can try and help you more.. you can get my msn from my post as "more on: Arrays, Queries and Loops" or something like that... Quote Link to comment Share on other sites More sharing options...
AndyB Posted September 4, 2006 Share Posted September 4, 2006 [quote author=Gregg link=topic=106769.msg427561#msg427561 date=1157349287]Well i tryed it and it had no errors but the pic dident load..Same error pic "blank"WTF?[/quote]Look at the generated html code and post back the exact img src shown in the page for the 'missing' image. This looks like a case of pointing on the wrong path or folders/images incorrectly-named. As a matter of good practice, always name images and folders in lowercase exclusively (and without spaces). Quote Link to comment Share on other sites More sharing options...
Gregg Posted September 4, 2006 Author Share Posted September 4, 2006 yeah, the url is perfect ecept it says "images/photo.gif/" at the end ot it!why the extra / after the image code? Quote Link to comment Share on other sites More sharing options...
AndyB Posted September 4, 2006 Share Posted September 4, 2006 echo '<img src=' .$images.'/>';should be:echo "<img src='. $images. "'/>"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.