spikereloaded Posted December 5, 2011 Posted December 5, 2011 Hey guys I'm adding a link to users profile in the header.php, but for some reason it isn't getting the userid, it just takes you to a profile page that says incorrect use of file. Heres the code that I've got and i don't think the problems in here, so im guessin its somewhere else on the page, e.g. not calling in the info from the db, but unsure where to put the query?! <a href='viewuser.php?u={$ir['userid']}'><img src='profilebutton.jpg' align='left'></a> Quote
lucky3809 Posted December 5, 2011 Posted December 5, 2011 Don't know your full code but instead of {$ir['userid']} try {$_GET['u']} Quote
spikereloaded Posted December 5, 2011 Author Posted December 5, 2011 thanks lucky but that didnt work either, i think i'm not defining something correctly but not sure what or where it should be. heres the code for the menu bar I've made function menubar(){ global $ir; print "<table width='932px' border='0' cellpadding='0' cellspacing='0' class='table3'> <tr><td bgcolor='#FFFFFF'> <a href='forums.php'><img src='forumsbutton.jpg' align='left'></a> <a href='inventory.php'><img src='inventorybutton.jpg' align='left'></a> <a href='newspaper6.php?action=add'><img src='newspaperbutton.jpg' align='left'></a> <a href='viewuser.php?u={$ir['userid']}'><img src='profilebutton.jpg' align='left'></a> <a href='preferences.php'><img src='settingsbutton.jpg' align='left'></a> <a href='search.php'><img src='searchbutton.jpg' align='left'></a> </td></tr></table>"; } If theres a lot wrong there, take it easy....im new! thanks guys! Quote
bluegman991 Posted December 5, 2011 Posted December 5, 2011 Every thing looks fine. What is the problem? Is it not taking you to the profile, is the link not showing, when on the pages is the profile not showing correctly? Quote
spikereloaded Posted December 5, 2011 Author Posted December 5, 2011 when clicking the profile link, it takes the user to http://murdercountry.com/viewuser.php?u= so it's obviously failing to call in the user id, but i'm not too sure how to call it in as every method i've tried just creates errors or doesnt work?! Quote
Dominion Posted December 5, 2011 Posted December 5, 2011 If your trying to link to that users profile try $userid. Quote
spikereloaded Posted December 5, 2011 Author Posted December 5, 2011 great thanks Dominion that worked great, I'm also trying to display the current hospital count in the header and experienceing the same problem. I'm using $hc but it's not displaying any value?! Quote
Dominion Posted December 5, 2011 Posted December 5, 2011 I think $hc is set inside the menu file, check it's value (I believe it's from a query inside globals.php), if not you will need to add a quick query to count the users in hospital. Quote
spikereloaded Posted December 5, 2011 Author Posted December 5, 2011 ive found the part in the menu page $hc=$set['hospital_count']; But i'm not 100% what to do with it now?! sorry to be a pain! Quote
lucky3809 Posted December 6, 2011 Posted December 6, 2011 if $hc is not working and it shows $hc=$set['hospital_count']; in your code then that would not be the problem look at your query, and see if it is selecting hospital_count field the query should be the one above that part of your code. Should be the query that starts as $set= Quote
Paul Evans Posted December 6, 2011 Posted December 6, 2011 (edited) they keep alot in settings, im curious what version of MC are you using? global $set; echo ' <a href="hospital.php" alt="hospital">Hospital ('.$set['hospital_count'].')</a> | <a href="jail.php" alt="jail">Jail ('.$set['jail_count'].')</a> '; Edited December 6, 2011 by Paul Evans Quote
spikereloaded Posted December 6, 2011 Author Posted December 6, 2011 I'm using v2. Will have a. Look at your suggestions and let you know what happens. Thanks for the info! Quote
spikereloaded Posted December 6, 2011 Author Posted December 6, 2011 So I've had a look and tried a few things but still a little confused as now I'm getting a value appear now....but it's just the letter S. <?php ///code for menu bar function menubar(){ global $db,$userid,$set,$ir,$hc,$c; $set="SELECT * hospital_count, jail_count FROM users"; $hc=$set['hospital_count']; $jc=$set['jail_count']; print "<table width='932px' border='0' bgcolor='#FFFFFF' cellpadding='0' cellspacing='0' >* <tr><td '> <a href='forums.php'><img src='forumsbutton.jpg' align='left'></a> <a href='inventory.php'><img src='inventorybutton.jpg' align='left'></a> <a href='newspaper6.php?action=add'><img src='newspaperbutton.jpg' align='left'></a> <a href='viewuser.php?u=$userid'><img src='profilebutton.jpg' align='left'></a> <a href='preferences.php'><img src='settingsbutton.jpg' align='left'></a> <a href='search.php'><img src='searchbutton.jpg' align='left'></a> </td></tr> <tr><td><center><img src='hospitalbuttonsmall.jpg'>($hc)<img src='jailbuttonsmall.jpg'> ($jc)</center></table>"; } ?><?php print menubar() ?> What am I doing wrong with my query?? Quote
Uridium Posted December 6, 2011 Posted December 6, 2011 $set="SELECT * hospital_count, jail_count FROM users"; <<< these are not in a V2 dbase the use of $set is already defined as a function anyway so get rid of that line Quote
spikereloaded Posted December 6, 2011 Author Posted December 6, 2011 if i delete that line illusion i go back to seeing nothing?! any ideas why thats happening? cheers Quote
Dominion Posted December 6, 2011 Posted December 6, 2011 (edited) if i delete that line illusion i go back to seeing nothing?! any ideas why thats happening? cheers You're not even running the query, but as said above you don't need to run it. Remove the line. $set['jail_count'] and $set['hospital_count']; are set inside globals.php, therefore would only work if that page is included or is set by yourself which as said is not happening here since the query is not running. On a side note - What version is this (v2.0.3 or 2.5) ? Sorry if you've answered already. Not looked at the whole thread. Edited December 6, 2011 by Dominion Quote
Uridium Posted December 6, 2011 Posted December 6, 2011 (edited) remove line 15 and overwrite with <a href='viewuser.php?u={$ir['userid']}'><img src='profilebutton.jpg' align='left'></a><br /> see if that helps Edited December 6, 2011 by illusions Quote
spikereloaded Posted December 7, 2011 Author Posted December 7, 2011 the codes im using are 2.0.2. I cant include globals.php in the header as this returns an error. Plus i cant seem to find the code within globals that defines $hc and $jc?! any ideas what the code starts with in globals? thanks very much Quote
spikereloaded Posted December 8, 2011 Author Posted December 8, 2011 dont worry, decided to place the links back in the main menu as they looked better there...and the code worked there aswell. thanks for the help anyway! Quote
bineye Posted December 8, 2011 Posted December 8, 2011 you really should have got the free upgrade to v2.0.3 (assuming you hold a valid license) as many of the issues were fixed from 2.0.2. to get the update/patch, log into your mccodes.com account and download it from there Quote
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.