Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

Error when output "introtext" from mysql? [Solved]

Codes here !

Moderators: macek, egami, gesf

Error when output "introtext" from mysql? [Solved]

Postby Zemerak » Wed Jun 27, 2012 3:07 pm

Hello! I can't figure out how to input an HTML content into a module...
This one does't work (but the query works on phpmyadmin)

Code: Select all
<? php
$SQL = 'SELECT introtext FROM 'jmo_content' WHERE Id=127';
$result = $mysql_query($sql) ;
$row = mysql_fetch_assoc($result);
print_r($row);
?>    


Output = error!
Any advice?

Thanks a lot!


Answer:
The graal: a code to display any content from joomla database into php module jumi


`<?php $db =& JFactory::getDBO();
$query = "SELECT introtext FROM #__content WHERE Id=127";
$db->setQuery($query);
$text= $db->loadResult(); ?>`

`<?php echo $text; ?>`
Last edited by Zemerak on Thu Jun 28, 2012 7:32 am, edited 1 time in total.
Zemerak
New php-forum User
New php-forum User
 
Posts: 5
Joined: Wed Jun 27, 2012 2:58 pm

Re: Error when output "introtext" from mysql?

Postby johnj » Wed Jun 27, 2012 11:51 pm

Post the full error message. also, you are saving the query as $SQL and then using it as $sql.
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: Error when output "introtext" from mysql?

Postby Zemerak » Thu Jun 28, 2012 1:25 am

Hi John!
Thanks so much for your reply!

Code: Select all
also, you are saving the query as $SQL and then using it as $sql.


Well no! I do not want to save or change anything in the db I just want to display a single things (I want to output an HTML content "introtext" inside a joomla modul that support php). Well I was going on the wrong side, I m completely lost....

Parse error: syntax error, unexpected T_VARIABLE in /homez.420/kmxsiksf/rscmovement.org/modules/mod_jumi/tmpl/default.php(12) : eval()'d code on line 4


Thanks a lot for your reply!
Zemerak
New php-forum User
New php-forum User
 
Posts: 5
Joined: Wed Jun 27, 2012 2:58 pm


Return to mySQL & php coding

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.