Chezshire Posted July 26, 2008 Share Posted July 26, 2008 I'm a newb who has been slowly hammering on this code for about two weeks, and its' almost doing what I want. I just have two things left to make happen, and bother are 'almost' happening. I just need some help getting over the hump 1. I'd like the correct image to display which is of the listed model. 2. I'd like the highlight codename to like to the character bio. Currently, the images display as broken links and when i click on the codename at this url http://www.xpg.us/rules/model2links.php, i get the following error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/content/z/a/n/zanland/html/xpg/cerebra/display.php on line 23 and Error! There is no Cerebra record with that id number. Please check the link you used to access this page and try again, or check the Cerebra main page for the record you're looking for. I want to make sure that I am making this clear when I say I am very much a complete numb who stepped in to try and take on the coding of a site when our coder left because of work/time constraints (And I very much wish him the best:) <td valign="top" width="75"> <?php $sql = "SELECT id, modelname, codename FROM cerebra ORDER BY modelname"; $result = mysql_query($sql) or trigger_error(mysql_error,E_USER_ERROR); while($row = mysql_fetch_assoc($result)){ //here's the key. Use a while loop to repeat through the code $thisID = $codename["id"]; $modelName= getModelName($thisID); $modelName = getChar($char_ID); echo "<p class='fineprint'>"; echo '<img src="/cerebra/images/'.$char_id.'.jpg" width="60" height="75" border=" 2px" bordercolor="#415582" '; echo '<b> '.$row['modelname']; echo ' </b>as <a href="/cerebra/display.php?id=$char_ID">'.$row['codename']; echo '</a>'; echo '<hr color="#050F1D" size="2">'; //these two lines (or any lines up to the closing brace) will be repeated for each row returned by the query } ?> </td> As always any help is tremendously appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/116727-solved-displaylink-problem/ Share on other sites More sharing options...
webref.eu Posted July 26, 2008 Share Posted July 26, 2008 A very quick comment from me. If you click on say AMPHIBIUS you get taken to: http://www.xpg.us/cerebra/display.php?id=$char_ID but what you should be getting taken to is something like: http://www.xpg.us/cerebra/display.php?id=52984 or whatever IDs actually exist. So in your code, $char_ID is not getting processed by php properly, i.e. it's not within php tags, and instead it's being read as plaintext. Rgds Quote Link to comment https://forums.phpfreaks.com/topic/116727-solved-displaylink-problem/#findComment-600198 Share on other sites More sharing options...
webref.eu Posted July 26, 2008 Share Posted July 26, 2008 I think the end of this line is where the problem may be: echo ' </b>as <a href="/cerebra/display.php?id=$char_ID">'.$row['codename']; Rgds Quote Link to comment https://forums.phpfreaks.com/topic/116727-solved-displaylink-problem/#findComment-600199 Share on other sites More sharing options...
Chezshire Posted July 26, 2008 Author Share Posted July 26, 2008 Thank you for the reply Webrer.eu, Your right in paraphrasing what it is that I am wanting to do, I'm just not sure how to write the code to do that. I'm very new to all of this and very far over my head - but learning so it's good (frustrating but good) I looked at the line of code you suggest, but the only difference i see in it, and the line I wrote is that the command to remove the 'bold type' is no longer present. I tried it, and i got the same result sadly. Ideally, if you click on AMPHIBIUS' name, it would take you to 'http://www.xpg.us/cerebra/display.php?id=1275' which is his individual character page. Any thoughts? Although your suggestion helped me to clean my code up a touch, its' still not working the way i'd like, but it's a line shorter so thats something <td valign="top" width="75"> <?php $sql = "SELECT id, modelname, codename FROM cerebra ORDER BY modelname"; $result = mysql_query($sql) or trigger_error(mysql_error,E_USER_ERROR); while($row = mysql_fetch_assoc($result)){ //here's the key. Use a while loop to repeat through the code $thisID = $codename["id"]; $modelName= getModelName($thisID); $modelName = getChar($char_ID); echo "<p class='fineprint'>"; echo '<img src="/cerebra/images/'.$char_id.'.jpg" width="60" height="75" border=" 2px" bordercolor="#415582" '; echo '<i> '.$row['modelname']; echo ' as <a href="/cerebra/display.php?id=$char_ID">'.$row['codename'].'</a>'; echo '<hr color="#050F1D" size="2">'; //these two lines (or any lines up to the closing brace) will be repeated for each row returned by the query } ?> </td> Quote Link to comment https://forums.phpfreaks.com/topic/116727-solved-displaylink-problem/#findComment-600263 Share on other sites More sharing options...
MFHJoe Posted July 26, 2008 Share Posted July 26, 2008 Change this line: echo ' as <a href="/cerebra/display.php?id=$char_ID">'.$row['codename'].'</a>'; To this: echo ' as <a href="/cerebra/display.php?id='.$char_ID.'">'.$row['codename'].'</a>'; That should get things working better. Basically, in PHP, you're not supposed to put variables ($char_ID) in single quotes. Either put them in double quotes or do it like I did. Quote Link to comment https://forums.phpfreaks.com/topic/116727-solved-displaylink-problem/#findComment-600266 Share on other sites More sharing options...
DarkWater Posted July 26, 2008 Share Posted July 26, 2008 I don't see you set $char_id anywhere. Also, where is $codename['id'] coming from? You set $thisID to it. Quote Link to comment https://forums.phpfreaks.com/topic/116727-solved-displaylink-problem/#findComment-600268 Share on other sites More sharing options...
Chezshire Posted July 26, 2008 Author Share Posted July 26, 2008 Thank you for the guidance MFHjoe, I had a solution earlier (which is currently used on the live page of the site while I try to work out the solution that I want to work out on this dummy page). Your solution is cleaner then mine was I think as it's doing in one line what i was doing with three i believe. Unfortunately, I'm still stuck with people going to the cerebra to then select the character rather then going directly to the character. So I need to 'set the character'? as Darkwater is imply. And in answer to Darkwater, I believe that codename, along with model name and id are all coming from my initial sql query (Detailed below) $sql = "SELECT id, modelname, codename FROM cerebra ORDER BY modelname"; $result = mysql_query($sql) or trigger_error(mysql_error,E_USER_ERROR); while($row = mysql_fetch_assoc($result)){ //here's the key. Use a while loop to repeat through the code I beleive that that is where i'm getting the general info, but As i've said before, I'm very new with little real idea of what I'm doing - I have some PHP for dummy books and things like that by my side and I'm just working on this stuff to distract me while I deal with having brain cancer (the term chemo & denial will be the name of my autobiography if i ever write one - laughs) Thanks for the help! I'm still stuck, but thanks to your help i'm stuck in a more elegant position Quote Link to comment https://forums.phpfreaks.com/topic/116727-solved-displaylink-problem/#findComment-600287 Share on other sites More sharing options...
DarkWater Posted July 26, 2008 Share Posted July 26, 2008 $row contains all the query information, not $codename. Look at your while(). Try using $row['id'] and then $thisID instead of $code_id. =P Quote Link to comment https://forums.phpfreaks.com/topic/116727-solved-displaylink-problem/#findComment-600292 Share on other sites More sharing options...
Chezshire Posted July 26, 2008 Author Share Posted July 26, 2008 Scratching my head at what your saying there Darkwater. I tried this and got an error, so I don't think i understand what it is your communicating (i'm really a newb) echo ' as <a href="/cerebra/display.php?id='.$row['codename'].'">'</a>'; Thanks for the guidance - i'm trying to google to see if i can do a better job of devining what it is your saying. Quote Link to comment https://forums.phpfreaks.com/topic/116727-solved-displaylink-problem/#findComment-600304 Share on other sites More sharing options...
DarkWater Posted July 26, 2008 Share Posted July 26, 2008 Use $row['id'] instead of $row['codename']. And what error did you get? Quote Link to comment https://forums.phpfreaks.com/topic/116727-solved-displaylink-problem/#findComment-600306 Share on other sites More sharing options...
Chezshire Posted July 26, 2008 Author Share Posted July 26, 2008 Thank you Darkwater - Now i've gotten the dread 'T-String' error: Parse error: parse error, unexpected T_VARIABLE, expecting ',' or ';' in /home/content/z/a/n/zanland/html/xpg/rules/model2links.php on line 43 Which is in reference to this line: echo ' as <a href="/cerebra/display.php?id='.$char_ID.'">'$row['id'].'</a>'; vs not erroring when I use this line: echo ' as <a href="/cerebra/display.php?id='.$char_ID.'">'.$row['codename'].'</a>'; Full code is: <?php $sql = "SELECT id, modelname, codename FROM cerebra ORDER BY modelname"; $result = mysql_query($sql) or trigger_error(mysql_error,E_USER_ERROR); while($row = mysql_fetch_assoc($result)){ //here's the key. Use a while loop to repeat through the code $thisID = $codename["id"]; $modelName= getModelName($thisID); $modelName = getChar($char_ID); echo "<p class='fineprint'>"; echo '<img src="/cerebra/images/'.$char_id.'.jpg" width="60" height="75" border=" 2px" bordercolor="#415582" '; echo '<i> '.$row['modelname']; echo ' as <a href="/cerebra/display.php?id='.$char_ID.'">'$row['id'].'</a>'; echo '<hr color="#050F1D" size="2">'; //these two lines (or any lines up to the closing brace) will be repeated for each row returned by the query } ?> I am a cluck Thanks for the guidance. Googling and books to see if i can better understand what your saying Quote Link to comment https://forums.phpfreaks.com/topic/116727-solved-displaylink-problem/#findComment-600311 Share on other sites More sharing options...
Chezshire Posted July 26, 2008 Author Share Posted July 26, 2008 I kept tinkering, and I revised line 43 and was able to remove the t-string, but now i'm getting a new special result as show by checking the URL: http://www.xpg.us/rules/model2links.php Shows the Model Names as character IDs, but still takes you to the main selection page www.xpg.us/cerebra.php instead of to the characters page http://www.xpg.us/cerebra/display.php?id=1275 This is what i had which is how i want it to look: http://www.xpg.us/rules/model3links.php but when you click the first character I want it to take you to http://www.xpg.us/cerebra/display.php?id=1275 not www.xpg.us/cerebra.php thanks for the help - not sure what i'm not understanding/doing wrong still, but thank you thank you thanks you! Quote Link to comment https://forums.phpfreaks.com/topic/116727-solved-displaylink-problem/#findComment-600316 Share on other sites More sharing options...
Chezshire Posted July 26, 2008 Author Share Posted July 26, 2008 Update, when i click on the url, the browser goes to 'http://www.xpg.us/cerebra/display.php?id=' but it doesn't make the connect to http://www.xpg.us/cerebra/display.php?id=1275 so it then defaults to http://www.xpg.us/cerebra.php So at this time, The codename displays as the ID, and when clicked doesn't make the full connection so the browser defaults sadly to the main selection name rather then to the specific page i was hoping for. I shall keep trying - if anyone has ideas, suggestions, guidance, a good metal frying pan they can use to hit some common sense/logic into my head with, i'd appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/116727-solved-displaylink-problem/#findComment-600320 Share on other sites More sharing options...
MFHJoe Posted July 26, 2008 Share Posted July 26, 2008 Change line: echo ' as <a href="/cerebra/display.php?id='.$char_ID.'">'$row['id'].'</a>' to echo ' as <a href="/cerebra/display.php?id='$row['id'].'">'$row['codename'].'</a>'; and change line: echo '<img src="/cerebra/images/'.$char_id.'.jpg" width="60" height="75" border=" 2px" bordercolor="#415582" '; to echo '<img src="/cerebra/images/'.$row['id'].'.jpg" width="60" height="75" border=" 2px" bordercolor="#415582" '; See if that makes things work. Quote Link to comment https://forums.phpfreaks.com/topic/116727-solved-displaylink-problem/#findComment-600324 Share on other sites More sharing options...
Chezshire Posted July 26, 2008 Author Share Posted July 26, 2008 THanks MFHJoe, I tried as you suggested and i got the following error: Parse error: parse error, unexpected T_ECHO, expecting ',' or ';' in /home/content/z/a/n/zanland/html/xpg/rules/model2links.php on line 43 I believe that this means that I need another ',' or ';' somewhere in the code for this page, but I'm sure sure where so i'm currently puzzling away and trying random hunt and pecks to see if i can get lucky This is how i executed the code: <?php $sql = "SELECT id, modelname, codename FROM cerebra ORDER BY modelname"; $result = mysql_query($sql) or trigger_error(mysql_error,E_USER_ERROR); while($row = mysql_fetch_assoc($result)){ //here's the key. Use a while loop to repeat through the code $thisID = $codename["id"]; $modelName= getModelName($thisID); $modelName = getChar($char_ID); echo "<p class='fineprint'>"; // displays image - incorrectly echo '<img src="/cerebra/images/'.$row['id'].'.jpg" width="60" height="75" border="2px" bordercolor="#415582"' echo '<i> '.$row['modelname']; echo ' as <a href="/cerebra/display.php?id='$row['id'].'">'$row['codename'].'</a>'; // makes thin bar echo '<hr color="#050F1D" size="2">'; //these two lines (or any lines up to the closing brace) will be repeated for each row returned by the query } ?> Quote Link to comment https://forums.phpfreaks.com/topic/116727-solved-displaylink-problem/#findComment-600332 Share on other sites More sharing options...
MFHJoe Posted July 26, 2008 Share Posted July 26, 2008 Sorry, I rushed that one a bit. echo ' as <a href="/cerebra/display.php?id='$row['id'].'">'$row['codename'].'</a>'; to echo ' as <a href="/cerebra/display.php?id='.$row['id'].'">'.$row['codename'].'</a>'; EDIT: Sorry, one more: You need a semicolon at the end of this line: echo '<img src="/cerebra/images/'.$row['id'].'.jpg" width="60" height="75" border="2px" bordercolor="#415582"' Quote Link to comment https://forums.phpfreaks.com/topic/116727-solved-displaylink-problem/#findComment-600334 Share on other sites More sharing options...
Chezshire Posted July 26, 2008 Author Share Posted July 26, 2008 Nothing to Apologize for MFHJoe - Your oops are infinitely better then my best attempts (i'm like a touch above understanding 'cut and paste' I tried to execute your suggestion, and i think I did it correctly, but I received the same error: Parse error: parse error, unexpected T_ECHO, expecting ',' or ';' in /home/content/z/a/n/zanland/html/xpg/rules/model2links.php on line 43 THis it the current state of my dumb assed code <?php $sql = "SELECT id, modelname, codename FROM cerebra ORDER BY modelname"; $result = mysql_query($sql) or trigger_error(mysql_error,E_USER_ERROR); while($row = mysql_fetch_assoc($result)){ //here's the key. Use a while loop to repeat through the code $thisID = $codename["id"]; $modelName= getModelName($thisID); $modelName = getChar($char_ID); echo "<p class='fineprint'>"; // displays image - incorrectly echo '<img src="/cerebra/images/'.$row['id'].'.jpg" width="60" height="75" border="2px" bordercolor="#415582"' echo '<i> '.$row['modelname']; echo ' as <a href="/cerebra/display.php?id='.$row['id'].'">'.$row['codename'].'</a>'; // makes thin bar echo '<hr color="#050F1D" size="2">'; //these two lines (or any lines up to the closing brace) will be repeated for each row returned by the query } ?> Once again thank you thank you thank you! Quote Link to comment https://forums.phpfreaks.com/topic/116727-solved-displaylink-problem/#findComment-600345 Share on other sites More sharing options...
MFHJoe Posted July 26, 2008 Share Posted July 26, 2008 EDIT: Sorry, one more: You need a semicolon at the end of this line: echo '<img src="/cerebra/images/'.$row['id'].'.jpg" width="60" height="75" border="2px" bordercolor="#415582"' You missed that one . That should hopefully fix it. Try that. And your code's fine mate, I'm probably confusing it even more to be honest. Quote Link to comment https://forums.phpfreaks.com/topic/116727-solved-displaylink-problem/#findComment-600350 Share on other sites More sharing options...
Chezshire Posted July 26, 2008 Author Share Posted July 26, 2008 Thank you MFHJoe - you're completely Brill! And thanks Darkwater for you the assistance too - your both spiffy and nice and my page is working and i'm doing a happy little dance. Evidently I'm the maxwell smart of programming (missed it by that much ( Thank you thank you thank you! Quote Link to comment https://forums.phpfreaks.com/topic/116727-solved-displaylink-problem/#findComment-600367 Share on other sites More sharing options...
MFHJoe Posted July 26, 2008 Share Posted July 26, 2008 Thank you MFHJoe No problem at all. Evidently I'm the maxwell smart of programming (missed it by that much ( Trust me mate, it happens to everyone. And it'll happen again . Quote Link to comment https://forums.phpfreaks.com/topic/116727-solved-displaylink-problem/#findComment-600370 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.