blueman378 Posted December 25, 2007 Share Posted December 25, 2007 hi guys i have this problem i just noticed that the link prints the name perfect however it only prints the first word of the name in the actual url, and this causes it to on any names that are longer than one word to instead of having a link like beat em up its just beat, this would be fine but it means that this code <?php //gameform global $database; $q = "SELECT cName FROM " . gsubcat . " ORDER BY `cName` ASC "; $result = $database->query($q) or die("Error: " . mysql_error()); /* Error occurred, return given name by default */ $num_rows = mysql_numrows($result); ?> | <?php while( $row = mysql_fetch_assoc($result) ) { echo "<a href=".$row[cName].".php>".$row['cName']."</a> | "; } ?> does not work as the .php is not printed on any links longer than one word Link to comment https://forums.phpfreaks.com/topic/83090-solved-a-mysql-link-charecter-error/ Share on other sites More sharing options...
raku Posted December 25, 2007 Share Posted December 25, 2007 It may be because there is a space character in the url. You could try a function that replaces whitespace with an underscore after the name is retrieved from the database so that nothing needs to be changed in the data. Link to comment https://forums.phpfreaks.com/topic/83090-solved-a-mysql-link-charecter-error/#findComment-422699 Share on other sites More sharing options...
blueman378 Posted December 25, 2007 Author Share Posted December 25, 2007 or possibly change it with %20, do you think that would solve it? Link to comment https://forums.phpfreaks.com/topic/83090-solved-a-mysql-link-charecter-error/#findComment-422701 Share on other sites More sharing options...
raku Posted December 25, 2007 Share Posted December 25, 2007 It might, but an underscore may look cleaner in your URL. You could just also merge them, then have php split the string at the next capital letter. Link to comment https://forums.phpfreaks.com/topic/83090-solved-a-mysql-link-charecter-error/#findComment-422702 Share on other sites More sharing options...
kenrbnsn Posted December 25, 2007 Share Posted December 25, 2007 Put the value of the URL in quotes. That will automatically cause the browser to encode the space. <?php echo '<a href="' . $row[cName] . '.php">' . $row['cName'] . '</a> | '; ?> Ken Link to comment https://forums.phpfreaks.com/topic/83090-solved-a-mysql-link-charecter-error/#findComment-422703 Share on other sites More sharing options...
blueman378 Posted December 25, 2007 Author Share Posted December 25, 2007 thanks ken that worked Link to comment https://forums.phpfreaks.com/topic/83090-solved-a-mysql-link-charecter-error/#findComment-422704 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.