close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

SQL query not working; but works using Navicat

Thread began 5/07/2018 5:28 am by msbannister373603 | Last modified 5/08/2018 1:32 pm by Ray Borduin | 1753 views | 10 replies |

msbannister373603

SQL query not working; but works using Navicat

I get this error message from my sql query:


Parse error: syntax error, unexpected 'BB' (T_STRING), expecting ']' in /home3/tbmvent1/public_html/desk/build/webassist/mysqli/rsobj.php(246) : eval()'d code on line 3

The following sql query works when I run the query Navicat; I get the correct answer. However, when I run the query within your recordset I get the error mentioned above. Do you see anything that is keeping the page from loading and the query from running. Thx


<?php
$pab = new WA_MySQLi_RS("pab",$Connections,1);
$pab->setQuery("(SELECT
(SELECT COUNT(pa) as pabpct FROM bat WHERE (teamID = ? ) AND
(
(result = 'BB') OR
(result = 'HBP') OR
(result = '1B') OR
(move_run = '1') OR
(xbh = '1') OR
(OB = '1') OR
(result = 'Bunt') OR
(result = '2B') OR
(result = '3B') OR
(result = 'HR') OR
(result = 'SC-Fly') OR
(result = 'D3-Safe') OR
(result = 'SC-BNT') OR
(rbi > '0') OR
(result = 'ROE-No Out')
)) / (SELECT COUNT(pa) FROM bat))");
$pab->bindParam("i", "".(isset($_GET['teamID'])?$_GET['teamID']:"") ."", "-1"); //colname
$pab->execute();
?>

Sign in to reply to this post

Ray BorduinWebAssist

If you open up rsobj.php what version is listed on the top of the page? Can I get FTP access and a URL to debug the page directly? I don't see the problem, but I'm sure I can figure it out if I was able to play with the code.

Sign in to reply to this post
Did this help? Tips are appreciated...

msbannister373603

Originally Said By: Ray Borduin
  If you open up rsobj.php what version is listed on the top of the page? Can I get FTP access and a URL to debug the page directly? I don't see the problem, but I'm sure I can figure it out if I was able to play with the code.  
Sign in to reply to this post

Ray BorduinWebAssist

You gave me the Database connection information. I'll need the FTP connection information so I can update the files.

Sign in to reply to this post
Did this help? Tips are appreciated...

msbannister373603

Originally Said By: Ray Borduin
  You gave me the Database connection information. I'll need the FTP connection information so I can update the files.  
Sign in to reply to this post

Ray BorduinWebAssist

The issue is that you are doing a complex calculation and not giving it a name, so it is trying to return the column name as the calculation and that has the '-' character that is a math operator and that throws the whole thing off.

The solution is to use AS to assign a name to your calculated result like:

$pab->setQuery("SELECT
((SELECT COUNT(pa) as pabpct FROM bat WHERE (teamID = ? ) AND
(
(result = 'BB') OR
(result = 'HBP') OR
(result = '1B') OR
(move_run = '1') OR
(xbh = '1') OR
(OB = '1') OR
(result = 'Bunt') OR
(result = '2B') OR
(result = '3B') OR
(result = 'HR') OR
(result = 'SC-Fly') OR
(result = 'D3-Safe') OR
(result = 'SC-BNT') OR
(rbi > '0') OR
(result = 'ROE-No Out')
)) / (SELECT COUNT(pa) FROM bat)) AS totpabpct");

That way it returns your calculated number as a column named: totpabpct

before it was trying to create a column named: "((SELECT COUNT(pa) as pabpct FROM bat WHERE (teamID = ? ) AND
(
(result = 'BB') OR
(result = 'HBP') OR
(result = '1B') OR
(move_run = '1') OR
(xbh = '1') OR
(OB = '1') OR
(result = 'Bunt') OR
(result = '2B') OR
(result = '3B') OR
(result = 'HR') OR
(result = 'SC-Fly') OR
(result = 'D3-Safe') OR
(result = 'SC-BNT') OR
(rbi > '0') OR
(result = 'ROE-No Out')
)) / (SELECT COUNT(pa) FROM bat))"

Which almost was allowed if not for the "-" characters in it.

Sign in to reply to this post
Did this help? Tips are appreciated...

msbannister373603

Still getting the same error.

Sign in to reply to this post

Ray BorduinWebAssist

You have two recordsets with the same SQL statement. I think you updated the wrong one so I'm not sure what the second SQL statement used to say. The one I gave you was to replace line 258, but it looks like you replaced line 282.

What was the old SQL statement on line 282? I can advise you on how to update that one too but I don't know what it was originally at this point.

Sign in to reply to this post
Did this help? Tips are appreciated...

msbannister373603

This post has been deleted.

msbannister373603

Awesome. As always you are correct. I need to TRIM the leading 0 and use FORMAT to have only 3 numbers. May take me a while. Lol. any quick ideas? Thx

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...