473,322 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

MySQL server version for the right syntax to use near '' at line 1

2
Does anybody know how solve this error

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 '' at line 1

here is my code

Expand|Select|Wrap|Line Numbers
  1.  <?php
  2. header('Content-type: text/html; charset=UTF-8');
  3. set_time_limit  (60*60); // 60 minutes
  4.  
  5. //-------------------------------------------------------
  6.  
  7. define('IN_PHPBB', true);
  8. $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
  9. $phpEx = substr(strrchr(__FILE__, '.'), 1);
  10. include($phpbb_root_path . 'common.' . $phpEx);
  11. include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
  12. include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
  13. include($phpbb_root_path . 'includes/message_parser.' . $phpEx);
  14.  
  15. /*
  16. function br2nl($string) {
  17.    //$string = preg_replace('/<br.*>$/iU', "\n", $string);
  18.    return preg_replace('/<br.*>/iU', "\n", $string);
  19. }
  20. */
  21.  
  22. $dbms = 'phpbb\\db\\driver\\mysqli';
  23. $dbhost = 'localhost';
  24. $dbport = '';
  25. $dbname = 'rampart_phpb131';
  26. $dbuser = 'rampart_phpb131';
  27. $dbpasswd = 'xxxx';
  28. $table_prefix = 'phpbb_';
  29. $phpbb_adm_relative_path = 'adm/';
  30. $acm_type = 'phpbb\\cache\\driver\\file';
  31. #$dbh = mysql_connect($hostname, $username, $password) or die("Unable to connect to mysql");
  32. $dbh = mysql_connect($dbhost, $dbuser, $dbpasswd) or die("Unable to connect to mysql");
  33. echo "<b>connected to mysql</b><br />\n";
  34. #$selected = mysql_select_db($database, $dbh) or die("Could not select database");
  35. $selected = mysql_select_db($dbname, $dbh) or die("Could not select database");
  36. echo mysql_error();
  37.  
  38. // First count number of posts
  39. $query = "SELECT count(*) FROM ".$table;
  40. echo $query.'<br />';
  41. if ($result = mysql_query($query,$dbh)) {
  42.    $row = mysql_fetch_array($result);
  43.    $rows = $row[0];
  44.    echo $rows.' posts found to convert<br/>';
  45. } else {
  46.    echo 'ERROR'.mysql_error();
  47. }
  48. //$rows = 3;
  49. echo "<hr/>\n";
  50.  
  51. for ($i=2; $i<$rows; $i++) {
  52.    $query = "SELECT post_id, post_text, bbcode_uid, bbcode_bitfield FROM ".$table." LIMIT ".$i.",1";
  53.    //echo $query."<br/><br/>\n";
  54.    if ($result = mysql_query($query,$dbh)) {
  55.       $row = mysql_fetch_array($result);
  56.       $text = $row['post_text'];
  57.       $bbcode = $row['bbcode_uid'];
  58.       $id = $row['post_id'];
  59.  
  60.       if (preg_match("/\[img:[0-9]+:[0-9]+\]/", $text) > 0) {
  61.  
  62.          echo "Update post #".$id.'<br/><br/>';
  63.          //echo '<br/>'.$text.'<br/>bbcode_uid='.$row['bbcode_uid'].'<br/>bbcode_bitfield='.$row['bbcode_bitfield'].'<br/>';
  64.  
  65.          $message_parser = new parse_message();
  66.          $message_parser->bbcode_uid = $row['bbcode_uid'];
  67.          $message_parser->message = $row['post_text'];
  68.  
  69.          $message_parser->decode_message($row['bbcode_uid']);
  70.          $text = $message_parser->message;
  71.  
  72.          //$text = preg_replace("/\[img:[0-9]+:[0-9]+\]/", "[img:".$bbcode."]", $text);
  73.          //$text = preg_replace("/\[\/img]/", "[/img:".$bbcode."]", $text);
  74.  
  75.          //echo '<br/>'.$text.'<br/>';
  76.  
  77.          $message_parser->message = preg_replace("/\[img:[0-9]+:[0-9]+\]/", "[img]", $message_parser->message);
  78.  
  79.          //echo '<br/>'.$text.'<br/>';
  80.  
  81.          $message_parser->parse(true, true, true);
  82.          $text = $message_parser->message;
  83.  
  84.          //echo '<br/>'.$text.'<br/>bbcode_uid='.$message_parser->bbcode_uid.'<br/>bbcode_bitfield='.$message_parser->bbcode_bitfield.'<br/>';
  85.  
  86.          $query = "UPDATE ".$table." SET post_text='".addslashes($text)."',bbcode_bitfield='".$message_parser->bbcode_bitfield."' WHERE post_id=".$id;
  87.          echo $query."<br/>\n";
  88.          if (!mysql_query($query,$dbh)) {
  89.             echo 'ERROR'.mysql_error();
  90.          }
  91.          echo '<hr/>'."\n";
  92.       }
  93.    } else {
  94.       echo 'ERROR'.mysql_error();
  95.    }
  96. }
  97.  
  98. ?>
  99.  
i remove the password in the script above thanks
Feb 3 '17 #1
3 2195
Dormilich
8,658 Expert Mod 8TB
well, obviously one of your SQL statements is incorrect. it would incredibly help if you knew what the failing statement looked like (and I don't mean the PHP code that creates the statement by that)
Feb 6 '17 #2
mckin
2
Hi

here is a screen shot of the failed statement when you called the script from the browser

Feb 6 '17 #3
Dormilich
8,658 Expert Mod 8TB
and you think that statement is correct?
Feb 6 '17 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Carl | last post by:
Can you tell me what is wrong with this syntax ? string select = "UPDATE .. " + "(,,,,,,, ,,,, ,,, , , , ) " + " VALUES (@id,@clientid,@total,@tps,@tvq,@gtotal,@datefac,@datepay,
2
by: PythonistL | last post by:
I have MySql server version: 5.0.22-community-nt. When I try to import data with this command mysql --default-character-set=utf8 mimi < c:\django\mujserver\mimi.sql I will get the error ...
0
by: roamnet | last post by:
hi i created database file with .mdf extention ,sql server as a source and use grid view to display data there're no problem in data retrieve and display,but i want to edit it or insert new...
10
by: bobf | last post by:
I am using a program 'My Contact Table' which is a code generator program. It allows you to easily create a PHP/MySQL web application without writing any code. I am trying to create an additional...
9
by: icemaster451 | last post by:
Hello im making a browser game and have 99% working but iv got one error i cant find / fix and would like to know if anyone can help me where im going wrong heres the error QUERY ERROR: You have an...
43
by: dougancil | last post by:
Can someone please review my code and see where I can be missing information. I get the following error: Line 1: Incorrect syntax near ','. Unclosed quotation mark before the character string '...
1
by: Omendra | last post by:
Hi, I am using SQL Server 2005 and i am using Stored Procedure something like :- I am getting error:- Msg 170, Level 15, State 1, Line 18: Incorrect syntax near 'MAX'. DECLARE @jid AS...
3
by: qdoet | last post by:
I'm newbie and I had a problem on my SQL syntax like this 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...
2
by: Lerato Mphaka | last post by:
Hi, I just migrated a MySQL database from my test server to my production Server with success. This database ia a backend for a .net application Im running. Now the problem is that when I try to...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.