logicopinion Posted September 29, 2007 Share Posted September 29, 2007 Hello EveryBody. i am trying to print out couple of DATA from DB. here is code: <?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("mynews") or die(mysql_error()); $query = "SELECT * FROM newsdb"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)) { print "<table cellpadding=0 cellspacing= width=100%>"; print "<tr><td>"; echo $row['date']; print "</td></tr>"; print "<tr><td>"; echo $row['title']; print "</td></td>"; print "<tr><td>"; echo "<a href=\"read_news.php?cid=$row['news']\">more...</a>"; print "</td></td>"; print "</table>"; } ?> but the BOLD text you see above is an URL which must show Full Content of that News.. it gives me an error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\xampp\htdocs\mynews\read_news.php on line 26 what is wrong with that ? Please Help. Thank You. Link to comment https://forums.phpfreaks.com/topic/71147-php-url-help/ Share on other sites More sharing options...
logicopinion Posted September 29, 2007 Author Share Posted September 29, 2007 is someone willing to help me please? Link to comment https://forums.phpfreaks.com/topic/71147-php-url-help/#findComment-357796 Share on other sites More sharing options...
Wuhtzu Posted September 29, 2007 Share Posted September 29, 2007 use the [ code ][ /code ] tags when you post your code and please let us know which line is 26 Link to comment https://forums.phpfreaks.com/topic/71147-php-url-help/#findComment-357800 Share on other sites More sharing options...
hemlata Posted September 29, 2007 Share Posted September 29, 2007 Hello, Replace your code print "<tr><td>"; echo "<a href=\"read_news.php?cid=$row['news']\">more...[/url]"; print "</td></td>"; with the following.. print "<tr><td>"; echo "<a href='read_news.php?cid=".$row['news'] ."'>more...</a>"; print "</td></td>"; Hope this will solve your issue. Regards, Link to comment https://forums.phpfreaks.com/topic/71147-php-url-help/#findComment-357801 Share on other sites More sharing options...
logicopinion Posted September 29, 2007 Author Share Posted September 29, 2007 when i mouseover more... button it prints all the text from news column in DB on the status bar in IE & FF i want it to show full text when i press MORE button but it does not.. page stays the same Link to comment https://forums.phpfreaks.com/topic/71147-php-url-help/#findComment-357803 Share on other sites More sharing options...
Wuhtzu Posted September 29, 2007 Share Posted September 29, 2007 I always try to avoid having to escape " (double quotes) when printing / echoing html: <?php echo '<tr><td>'; echo '<a href="read_news.php?cid=' . $row['news'] . '">more...</a>'; echo '</td></td>'; ?> So if you are printing / echoing double quotes use single quotes to define the strings and the other way round. Link to comment https://forums.phpfreaks.com/topic/71147-php-url-help/#findComment-357804 Share on other sites More sharing options...
Wuhtzu Posted September 29, 2007 Share Posted September 29, 2007 That must be because $row['new'] contains the "article" and not the ID of the article.... Don't you have a column called ID? $row['id'] Link to comment https://forums.phpfreaks.com/topic/71147-php-url-help/#findComment-357806 Share on other sites More sharing options...
logicopinion Posted September 29, 2007 Author Share Posted September 29, 2007 yes i have AUTO_INCREMENT primary key (id) and now i replaced $row['news'] with $row['id'] and it does such thing when i press more button URL looks Like http://localhost/mynews/read_news.php?cid=8 http://localhost/mynews/read_news.php?cid=9 etc... but it does not print any data anyway. the page stays same.. should i add here something like $cid= &$_REQUEST['cid']; if (!file_exists($go.".php)) { include "body.php"; next;} else { if (isset($cid) && $cid!='body') { include "$cid.".php"; } else { include "body.php"; }} Link to comment https://forums.phpfreaks.com/topic/71147-php-url-help/#findComment-357808 Share on other sites More sharing options...
logicopinion Posted September 29, 2007 Author Share Posted September 29, 2007 this is body.php CODE: <?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("mynews") or die(mysql_error()); $query = "SELECT * FROM newsdb ORDER BY id DESC LIMIT 0, 30"; $result = mysql_query($query) or die(mysql_error()); print "<table cellpadding=0 cellspacing= width=100% width=700>"; while($row = mysql_fetch_array($result)) { print "<tr><td bgcolor= #FFF8DC style=\"BORDER-BOTTOM:1px #1E90FF solid;\">"; echo $row['date']; print "</td></tr>"; print "<tr><td>"; echo $row['title']; print "<br><br>"; print "</td></td>"; print "<tr><td align=right>"; echo "<a href='read_news.php?id=".$row['id'] ."'>დაწვრილებით</a>"; print "<br><br>"; print "</td></td>"; } print "</table>"; ?> and this is read_news.php CODE: <?php $id= &$_REQUEST['id']; if (isset($id) && $id!='body') { echo "$id"; } else { include "body.php"; } ?> and everything works Fine.. when i press more button it goes to specified ID .. but instead of FULL TEXT it Prints ID expl: 12 so i see i requested it to find if there is any id set and print it out but instead of and id i want to to PRINT out FULL TEXT wich is Stored in the same DB in a Column Named NEWS.. what should i do? Link to comment https://forums.phpfreaks.com/topic/71147-php-url-help/#findComment-357832 Share on other sites More sharing options...
logicopinion Posted September 29, 2007 Author Share Posted September 29, 2007 any suggestation ?? :-\ Link to comment https://forums.phpfreaks.com/topic/71147-php-url-help/#findComment-357840 Share on other sites More sharing options...
hemlata Posted September 29, 2007 Share Posted September 29, 2007 Hello, In 'read_news.php', instead of echoing id, get the related record for this id from the database and display that. So.. modify the code as per the comments below... <?php $id= &$_REQUEST['id']; if (isset($id) && $id!='body') { // connect to the DB // Get the records from table 'newsdb' where id = $id // display 'news_details' } else { include "body.php"; } ?> Hope this will solve your issue. Regards, Link to comment https://forums.phpfreaks.com/topic/71147-php-url-help/#findComment-357852 Share on other sites More sharing options...
logicopinion Posted September 29, 2007 Author Share Posted September 29, 2007 i am done man thanks a lot this is code : ?php $id= &$_REQUEST['id']; if (isset($id) && $id!='body') { mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("mynews") or die(mysql_error()); $query = "SELECT * FROM newsdb WHERE id='id'"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)) { echo $row['news']; } } else { include "body.php"; } ?> Link to comment https://forums.phpfreaks.com/topic/71147-php-url-help/#findComment-357862 Share on other sites More sharing options...
logicopinion Posted September 29, 2007 Author Share Posted September 29, 2007 and one more thing PLEASE. i insert long text into DB and when php prints it out... there is some text written but now Whole for example i insert: wow, my script is working perfectly, but there is some lil error around and when i desplay it it shows like this : wow, my script is working perfectly, bu? i actually USE UTF-8 for my language (Georgian) Link to comment https://forums.phpfreaks.com/topic/71147-php-url-help/#findComment-357868 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.