douyi1899 2009-10-27 08:42
浏览 77
已采纳

Joomla,Mysql错误

I have uploaded a page with the code below to my joomla root directory.

<?php
$value = trim($_POST['opts']);

if ($value){ 
$db = "my_db";
$link = mysql_connect('localhost',$me,$my_password);

if(!$link) die("Error 1 ".mysql_error());

mysql_select_db($db);

 **$query =  "SELECT introtext,fulltext FROM jos_content WHERE title='$value' ";** 

 $result = mysql_query($query);

 **if(!$result) die("Error 2 ".mysql_error());**

 $obj = mysql_fetch_array($result);

 $obj_f = $obj[0];

 $lenght = strlen($obj_f);
 $header2 = strpos($obj_f, "Did you know");
 $header3 = strstr($obj_f, "Summary");

$third_part = $header3; 
$first_part = substr($obj_f, 0, ($header2 - 1));
$second_part = substr($obj_f, $header2,((strpos($obj_f, "Summary")) - $header2) );             
 }
?>

the problem is that when i change my select(http://sanatural.co.za/sanp/test.php) i get this error message: Error 2 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'fulltext FROM jos_content WHERE title='Arthritis'' at line 1

The code highlighted in bold is where i think the problem might be. Please help.

  • 写回答

2条回答 默认 最新

  • dsmvovm27249 2009-10-27 08:48
    关注

    Fulltext is a mysql keyword and you must escape it. Replace:

    $query = "SELECT introtext,fulltext FROM jos_content WHERE title='$value' ";
    

    with

    $query = "SELECT `introtext`,`fulltext` FROM jos_content WHERE title='$value' ";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法