Jump to content

Recommended Posts

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 :D

 

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!

Link to comment
https://forums.phpfreaks.com/topic/116727-solved-displaylink-problem/
Share on other sites

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

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 :D

<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>

 

 

 

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.

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 ;)

 

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.

 

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

 

 

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!

 

 

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.

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.

 

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
	}

	?>

 

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"'

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!

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.

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!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.