473,378 Members | 1,280 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,378 software developers and data experts.

missing (semi-colon); before statement error

110 100+
I'm getting a "missing ; before statement" error in javacript

I'm surprised i wasn't able to find anything about this on this site.
I am not sure why I'm getting this error, everything looks fine to me.

I thought it might be because of special characters in the variable field, but "\"ing them out didn't fix the issue.

I am building the javascript page via php. The offending output line is the first line
(I've included a few more lines incase it is a following line that is actually causing the error.

Expand|Select|Wrap|Line Numbers
  1. var searchStr = 539103&less%5B%5D=19224&less%5B%5D=512470&less%5B%5D=355349;
  2. seed = 539103;
  3. var num = 1;
  4. var start = 1;
  5. var numResults = 8;
  6.  
  7.  
the start of the php page which creates this string is

Expand|Select|Wrap|Line Numbers
  1. include '../includes/dbconnect.php';
  2. Header("content-type: application/x-javascript");
  3.  
  4.  
  5.  
  6.  
  7. $seed=  $_GET["seed"];
  8. $seed2 = $seed;
  9. $start= $_GET["start"];
  10. $results = $_GET['results'];
  11. $num = @$_GET['num'];
  12.  
  13. $query = "SELECT DISTINCT(sid), rate FROM votes WHERE start = '$seed' LIMIT 0,3";
  14. $result = mysql_query($query);
  15.  
  16. while ($row=mysql_fetch_array($result)){
  17.     $sid = $row['sid'];
  18.     $rate = $row['rate'];
  19.  
  20.     if($rate == 50){
  21.     $seed2 = "$seed2&less%5B%5D=$sid";
  22.     } if($rate == 25) {
  23.     $seed2 = "$seed2&more%5B%5D=$sid";
  24.     }
  25. }
  26.  
  27. echo "var searchStr = $seed2;\n";
  28. echo "seed = $seed;\n";
  29. if ($num != ''){
  30. echo "var num = $num;\n";
  31. } else {
  32. echo "var num = 0;\n";
  33. }
  34. echo "var start = $start;\n";
  35.  
  36. echo "var numResults = $results;\n";
  37. ?>
  38.  
  39.  
  40. function getSearchStrVote(sid, rate) {
  41.     var searchStrNew = searchStr;
  42.     if (rate == '50'){
  43.     searchStrNew = searchStrNew+"&more%5B%5D="+sid;
  44.     }
  45.     if (rate == '25') {
  46.     searchStrNew = searchStrNew+"&less%5B%5D="+sid;
  47.     carousel.scrollNext();
  48.     }    
  49.     searchStr = searchStrNew;
  50. }
  51.  
platform is winxp - firefox & ie 6&7. I haven't tried on mac.
Nov 12 '07 #1
3 8570
mrhoo
428 256MB
var searchStr = 539103&less%5B%5D=19224&less%5B%5D=512470&less%5B% 5D=355349

The javascript interpreter expected to find the end of a line in that expression-
If this is a string, wrap it in single or double quotes.
Nov 12 '07 #2
pedalpete
110 100+
I figured it was something simple like that, but i still have no idea why I would put this var in quotes when I don't quote the rest of them.

Anyway, thanks for the help. that's awesome.
Nov 12 '07 #3
gits
5,390 Expert Mod 4TB
I figured it was something simple like that, but i still have no idea why I would put this var in quotes when I don't quote the rest of them.

Anyway, thanks for the help. that's awesome.
hi ...

the reason is that in case you don't enclose it in quotes the interpreter tries to identify it unsuccessful as a number ... due to the special chars in it ... or as a variable-name ... unsuccessful too ... due to the special chars too :) ... in case it is a string you have to use the quotes that literally creates a new string ...

kind regards
Nov 12 '07 #4

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

Similar topics

2
by: jannordgreen | last post by:
I am using Winxp and Ms Access 2003. I get this error message: error 3137, Missing semicolon (;) at end of SQL statement when I run this code: Dim I As Integer For I = 0 To...
4
by: erika | last post by:
I am trying to run the following update query in code. UPDATE TableTest SET STATUS = "A" WHERE (Code <> "X") AND (Code <> "J") ORDER BY DOB; I am getting an error, "Missing Semicolon (;) at...
6
by: BaWork | last post by:
I have the following to insert a new record: <% .. Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open "DSN=qqqqq;" SQLStmt = "INSERT INTO tbl_qqqqqq (main_cat, cat_fee, fee_amount)...
8
sammyboy78
by: sammyboy78 | last post by:
I'm trying to create a class "WeeklyPay" that contains the methods that class "WeeklyPayTest" will use to compute the weekly pay of an employee when the user inputs employee name, hours worked, and...
4
by: liz0001 | last post by:
Hi, I am getting this error when I try to run my code: Missing semicolon (;) at end of SQL statement However, there is a semicolon at the end of my statement. Here is the statement: INSERT...
3
by: DontB3 | last post by:
Hi, I'm new in this forum, and i hope someone can help. I'm creating an automatic application that transfer a database from Access -> DBF -> Oracle. When My App try to execute Insert SQL...
1
by: macracan | last post by:
I'm wondering what was the rationale that caused gcc to only have a warning (disabled by default!!) to signal the following: int a() {}; // intentionally no statements int main() {...
4
ILtech
by: ILtech | last post by:
So this is my code. I get the error missing return statement, but I don't see where. Any suggestions would be greatly appreciated. (I realize there are probably some other issues in this code as...
1
by: Annie Soomro | last post by:
Getting "missing return statement" error for following code: import java.sql.*; public class DatabaseManager{ public static int add(String user,String password)throws Exception{ ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.