php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12829 PHP parser gets confused
Submitted: 2001-08-18 18:32 UTC Modified: 2001-08-18 19:11 UTC
From: bart at usbmis dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.0.6 OS: Linux
Private report: No CVE-ID: None
 [2001-08-18 18:32 UTC] bart at usbmis dot com
1	$sq = "SELECT * FROM TLinks WHERE LinkID = 1";
2	$result = mysql_query($sq)
3			or die ("Error- Could not run Query: $sq!\nError (" . mysql_errno() . ") - " . mysql_error());
4	
5	if ($row = mysql_fetch_array($result))
6	{
7		$link = $row['Link'];
8		$origins =  $row["Origins"];
9
10		$q = "UPDATE TLinks SET Origins = " . $origins + 1 . " WHERE LinkID = 1";
11		$r3 = mysql_query($q)
12			or die ("Error- Could not run Query: $q!\nError (" . mysql_errno() . ") - " . mysql_error());
13
14	}


The above lines cause the following error:
  
Error- Could not run Query: 1 WHERE LinkID = '01a_gennote'! Error (1064) - You have an error in your SQL syntax near '1 WHERE LinkID = '01a_gennote'' at line 1

Please note that the error happends with reference to the SELECT query on line 2.


SOLUTION

To solve the problem, I had to remove '+ 1' following the '$origins' on line 10.  The following code executes without any errors.

1	$sq = "SELECT * FROM TLinks WHERE LinkID = 1";
2	$result = mysql_query($sq)
3			or die ("Error- Could not run Query: $sq!\nError (" . mysql_errno() . ") - " . mysql_error());
4	
5	if ($row = mysql_fetch_array($result))
6	{
7		$link = $row['Link'];
8		$origins =  $row["Origins"];
9
10		$q = "UPDATE TLinks SET Origins = " . $origins . " WHERE LinkID = 1";
11		$r3 = mysql_query($q)
12			or die ("Error- Could not run Query: $q!\nError (" . mysql_errno() . ") - " . mysql_error());
13
14	}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-18 19:11 UTC] sniper@php.net
This works: ($origins+1) 
Not a bug.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC