simzam Posted December 17, 2010 Share Posted December 17, 2010 i cannot figure out why my first result is not displaying properly it successfully shows all results but me first myurl.com/other.php?id=2 now showing any thing kindly help to solved this problem! it seems like problem is in variable $http$ids but dunno how to combine them to get result $Ids always b numeric number <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); $http = "myurl.com/other.php?id=" ; $conn=odbc_connect('greeting','',''); if (!$conn) {exit("Connection Failed: " . $conn);} $sql="SELECT * FROM mytable"; $rs=odbc_exec($conn,$sql); if (!$rs) {exit("Error in SQL");} echo "<table border= 1><tr>"; echo "<th>ID</th>"; echo "<th>Like</th>"; echo "<th>title</th></tr>"; while (odbc_fetch_row($rs)) { $ids=odbc_result($rs,"ID"); $title=odbc_result($rs,"title"); echo "<tr><td>$ids</td>"; echo "<td><fb:like href=\"$http$ids\" layout=\"button_count\" show_faces=\"false\" width=\"100\" font=\"tahoma\" colorscheme=\"dark\"></fb:like> </td>"; echo "<td>$title</td></tr>"; } echo "</table>"; odbc_close($conn); ?> Quote Link to comment https://forums.phpfreaks.com/topic/221992-problem-displaying-result/ Share on other sites More sharing options...
MatthewJ Posted December 17, 2010 Share Posted December 17, 2010 $http.$ids . (dot) concatenates strings in php Quote Link to comment https://forums.phpfreaks.com/topic/221992-problem-displaying-result/#findComment-1148707 Share on other sites More sharing options...
simzam Posted December 17, 2010 Author Share Posted December 17, 2010 $http.$ids it show result like other.php?id=.2 Quote Link to comment https://forums.phpfreaks.com/topic/221992-problem-displaying-result/#findComment-1148716 Share on other sites More sharing options...
MatthewJ Posted December 17, 2010 Share Posted December 17, 2010 actually, the code highlighting threw me off, I thought you had closed out the string... it should work how you intend if the vars hold the right data, what does the output look like if you just echo it to the page (removing the dot of course)? Quote Link to comment https://forums.phpfreaks.com/topic/221992-problem-displaying-result/#findComment-1148742 Share on other sites More sharing options...
DavidAM Posted December 17, 2010 Share Posted December 17, 2010 echo "<td><fb:like href=\"$http$ids\" layout=\"button_count\" show_faces=\"false\" width=\"100\" font=\"tahoma\" colorscheme=\"dark\"></fb:like> </td>"; Since you are trying to combine variables INSIDE of a double-quoted string, the dot (".") concatenation is not the answer. You need to separate the variables with curly-braces so PHP will know that they are two separate variables. echo "<td><fb:like href=\"{$http}{$ids}\" layout=\"button_count\" show_faces=\"false\" width=\"100\" font=\"tahoma\" colorscheme=\"dark\"></fb:like> </td>"; Quote Link to comment https://forums.phpfreaks.com/topic/221992-problem-displaying-result/#findComment-1148746 Share on other sites More sharing options...
simzam Posted December 17, 2010 Author Share Posted December 17, 2010 I dunno when id=2 my link wouldn't work but all other links work perfectly 3,4,5,6....... what happened to 2 other.php?id=2 Quote Link to comment https://forums.phpfreaks.com/topic/221992-problem-displaying-result/#findComment-1148755 Share on other sites More sharing options...
MatthewJ Posted December 17, 2010 Share Posted December 17, 2010 Do you have an item with an id of "2" in the database? Not just "there should be" but if you list all of the table contents, do you have an id=2? Quote Link to comment https://forums.phpfreaks.com/topic/221992-problem-displaying-result/#findComment-1148771 Share on other sites More sharing options...
simzam Posted December 17, 2010 Author Share Posted December 17, 2010 there is only 2 fields in database ID AND Title yes ID=2 and title = sometext and all links work fine but when it comes to id=2 link not seem to b OK but now i changed ID to Link and it start working but i wanted to know why it didn't not worked with ID Quote Link to comment https://forums.phpfreaks.com/topic/221992-problem-displaying-result/#findComment-1148787 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.