thesaleboat Posted July 10, 2008 Share Posted July 10, 2008 So, I am editting a website that was originally created in XHTML but we switched it to PHP but everything is divided very precisely (i hate HTML ) so I have code developed to see if the user has visited a page before and if he has it updates the database. I need an image on the website to change if the user has been there already so here is my code, obviously it doesn't work but I've tried a few different things. I want the layout of the page to remain the same. Please HELP me -> ??? ... <tr> <td class="progressChartInset2"><a href="regulations.php" class="four">Regulations</a></td> <td> <div align="center"> <?php require_once('dbconnect.php'); mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $myusername = $_SESSION['myusername']; $rowalreadyexists = mysql_query("SELECT * FROM `users_subcategories` WHERE `users_subcategories`.`SubCategoryId` = 30 and `users_subcategories`.`username` = '$myusername'") or die(mysql_error()); $rowcount = mysql_num_rows($rowalreadyexists); if (!empty($_SESSION['myusername']) && $subcategory >= 1){ if ($rowcount == 0) { echo (<img src="images/Zerocompletion.gif" alt="0% completed" width="18" height="18" />); } } else echo (<img src="images/Fullcompletion.gif" alt="100% completed" width="18" height="18" />); ?> </div> </td> </tr> ... Link to comment https://forums.phpfreaks.com/topic/114183-change-image-after-user-has-visited/ Share on other sites More sharing options...
ratcateme Posted July 10, 2008 Share Posted July 10, 2008 i am not sure but i think the problem is that if if ($rowcount == 0) { echo (<img src="images/Zerocompletion.gif" alt="0% completed" width="18" height="18" />); } returns false nothing else happens you need to change it to if (!empty($_SESSION['myusername']) && $subcategory >= 1){ if ($rowcount == 0) { echo (<img src="images/Zerocompletion.gif" alt="0% completed" width="18" height="18" />); } else echo (<img src="images/Fullcompletion.gif" alt="100% completed" width="18" height="18" />); } else echo (<img src="images/Fullcompletion.gif" alt="100% completed" width="18" height="18" />); Scott. Link to comment https://forums.phpfreaks.com/topic/114183-change-image-after-user-has-visited/#findComment-587099 Share on other sites More sharing options...
thesaleboat Posted July 11, 2008 Author Share Posted July 11, 2008 Hmm, I am also getting this error and i am an @$$ for not saying this earlier, sorry. Parse error: syntax error, unexpected '<' in weaponsProgChart.php on line 251 this is the first if statement. Link to comment https://forums.phpfreaks.com/topic/114183-change-image-after-user-has-visited/#findComment-587619 Share on other sites More sharing options...
thesaleboat Posted July 11, 2008 Author Share Posted July 11, 2008 <td><div align="center"> <?php require_once('dbconnect.php'); mysql_connect("$host", "$username", "$password")or die("cannot connect"); $myusername = $_SESSION['myusername']; $rowalreadyexists = mysql_query("SELECT * FROM `users_subcategories` WHERE `users_subcategories`.`SubCategoryId` = 33 and `users_subcategories`.`username` = '$myusername'") or die(mysql_error()); $rowcount = mysql_num_rows($rowalreadyexists); if (!empty($_SESSION['myusername'])){ if ($rowcount == 1) { echo '<img src="images/Fullcompletion.gif" alt="100% completed" width="18" height="18" />'; } else echo '<img src="images/0completion.gif" alt="0% completed" width="18" height="18" />'; } else echo '<img src="images/0completion.gif" alt="0% completed" width="18" height="18" />'; ?> </div></td> Got it Sold Out Link to comment https://forums.phpfreaks.com/topic/114183-change-image-after-user-has-visited/#findComment-587734 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.