Jump to content

PHP/SQL Not grabbing more than 1 word?


danp

Recommended Posts

:facepalm: I'm stumped on this one.

 

    I found a really simple "skeleton" if you will for a roleplaying game in PHP on the internet.

When you go to fight a monster in the drop-down menu in fight.php, and the monster has two or more words for a name, the whole name of the monster does not carry over to the battle.php script, just the first name. I've tried all kinds of formattings and have actually seen similar problems in other people's scripts. Any advice or tips to get this working? I'd appreciate it, and thank you in advance.

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/184046-phpsql-not-grabbing-more-than-1-word/
Share on other sites

The HTML being output by the following line is invalid -

 

echo "<option value=$monster_name[$x]>$monster_name[$x]</option>";

 

The value='...' attribute needs to be enclosed in quotes to make valid HTML (and in fact everyone should be validating their resulting web pages at the w3.org validators to insure that they contain valid HTML/CSS.)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.