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

Syntax Problem

I have the following PHP/MySQL code segment

$query2="UPDATE reports
SET fsacars_rep_url = $url_new
WHERE pilot_id = $pid";

echo"$query2";

$result2=mysql_query($query2) or die(mysql_error());

The above code produces the following messages:

The echo of the query shows:
UPDATE reports SET fsacars_rep_url = http://69.72.192.154/
~caa/caa/logbooks/no_rept.txt WHERE pilot_id = 2

When the query runs the following error message is generated:
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
'://69.72.192.154/~caa/caa/logbooks/no_rept.txt WHERE pilot_id = 2' at line
2

What is the proper syntax?

Thanks,
Tom
May 9 '07 #1
4 1388

"Call Me Tom" <no****@devnull.spamcop.netwrote in message
news:z7q0i.9619$pW5.3833@trnddc07...
>I have the following PHP/MySQL code segment

$query2="UPDATE reports
SET fsacars_rep_url = $url_new
WHERE pilot_id = $pid";

echo"$query2";

$result2=mysql_query($query2) or die(mysql_error());

The above code produces the following messages:

The echo of the query shows:
UPDATE reports SET fsacars_rep_url = http://69.72.192.154/
~caa/caa/logbooks/no_rept.txt WHERE pilot_id = 2

When the query runs the following error message is generated:
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
'://69.72.192.154/~caa/caa/logbooks/no_rept.txt WHERE pilot_id = 2' at
line
2

What is the proper syntax?
I don't know but my guess is that you need to put ' ' on your variables,

$query2="UPDATE reports
SET fsacars_rep_url = '$url_new'
WHERE pilot_id = '$pid';";


May 9 '07 #2
At Wed, 09 May 2007 20:26:07 +0000, Call Me Tom let his monkeys type:
I have the following PHP/MySQL code segment

$query2="UPDATE reports
SET fsacars_rep_url = $url_new
WHERE pilot_id = $pid";

echo"$query2";

$result2=mysql_query($query2) or die(mysql_error());

The above code produces the following messages:

The echo of the query shows:
UPDATE reports SET fsacars_rep_url = http://69.72.192.154/
~caa/caa/logbooks/no_rept.txt WHERE pilot_id = 2

When the query runs the following error message is generated:
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
'://69.72.192.154/~caa/caa/logbooks/no_rept.txt WHERE pilot_id = 2' at line
2

What is the proper syntax?

Thanks,
Tom
Tom,

Using strings in MySQL queries, enclose them in quotes:

$query2="UPDATE reports
SET fsacars_rep_url = '$url_new'
WHERE pilot_id = $pid";

// add quotes around $pid as well if it's a character field, not if it's a
numerical value in the db.

HTH
Sh
May 9 '07 #3
Schraalhans Keukenmeester <in*****@invalid.spamwrote in
news:pa****************************@invalid.spam:
At Wed, 09 May 2007 20:26:07 +0000, Call Me Tom let his monkeys type:
>I have the following PHP/MySQL code segment

$query2="UPDATE reports
SET fsacars_rep_url = $url_new
WHERE pilot_id = $pid";

echo"$query2";

$result2=mysql_query($query2) or die(mysql_error());

The above code produces the following messages:

The echo of the query shows:
UPDATE reports SET fsacars_rep_url = http://69.72.192.154/
~caa/caa/logbooks/no_rept.txt WHERE pilot_id = 2

When the query runs the following error message is generated:
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 '://69.72.192.154/~caa/caa/logbooks/no_rept.txt WHERE pilot_id =
2' at line 2

What is the proper syntax?

Thanks,
Tom

Tom,

Using strings in MySQL queries, enclose them in quotes:

$query2="UPDATE reports
SET fsacars_rep_url = '$url_new'
WHERE pilot_id = $pid";

// add quotes around $pid as well if it's a character field, not if
it's a numerical value in the db.

HTH
Sh
Thanks. That solved the problem.

Tom
May 9 '07 #4
Call Me Tom wrote:
Thanks. That solved the problem.
But it will cause another (when $new_url contains a quote mark!)

This should be (more or less) indestructible:

$q2 = sprintf("UPDATE reports SET fsacars_rep_url='%s' WHERE pilot_id=%d;",
mysql_real_escape_string($url_new),
(int)$pid);

--
Toby A Inkster BSc (Hons) ARCS
http://tobyinkster.co.uk/
Geek of ~ HTML/SQL/Perl/PHP/Python/Apache/Linux
May 10 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
24
by: Andrew Koenig | last post by:
PEP 315 suggests that a statement such as do: x = foo() while x != 0: bar(x) be equivalent to while True:
35
by: Moosebumps | last post by:
Does anyone here find the list comprehension syntax awkward? I like it because it is an expression rather than a series of statements, but it is a little harder to maintain it seems. e.g. you...
23
by: C. Barnes | last post by:
I vote for def f(): (body of function) This is backwards compatible (Python <= 2.3 raise SyntaxError), and looks much nicer than @. The only problem is that you can't one-line a...
16
by: George Sakkis | last post by:
I'm sure there must have been a past thread about this topic but I don't know how to find it: How about extending the "for <X> in" syntax so that X can include default arguments ? This would be very...
29
by: shank | last post by:
1) I'm getting this error: Syntax error (missing operator) in query expression on the below statement. Can I get some advice. 2) I searched ASPFAQ and came up blank. Where can find the "rules"...
5
by: NanQuan | last post by:
I'm hoping someone can help me solve this error since I am at a total loss here. Usually I don't bother posting on any forums or groups on the internet and prefer to solve stuff myself but this is...
19
by: Nicolas Fleury | last post by:
Hi everyone, I would to know what do you think of this PEP. Any comment welcomed (even about English mistakes). PEP: XXX Title: Specialization Syntax Version: $Revision: 1.10 $...
20
by: W Karas | last post by:
Would the fear factor for concepts be slightly reduced if, instead of: concept C<typename T> { typename T::S; int T::mem(); int nonmem(); };
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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...
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)...
0
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: 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.