0

I have a query on my PHP code:

$result = mysqli_query($con,"UPDATE operasyonkayitlari SET tarihgun=FROM_UNIXTIME(UNIX_TIMESTAMP(NOW())-28800, "%Y.%m.%d"), tezgah='".$_REQUEST['tezgah']."', operatoradi='".$_REQUEST['operator']."', ayarepoch=UNIX_TIMESTAMP(NOW()), durum='AYARDA' where isemri='".$_REQUEST['isemri']."' and operasyonno='".$_REQUEST['operasyonno']."'");

Look at this closely:

FROM_UNIXTIME(UNIX_TIMESTAMP(NOW())-28800, "%Y.%m.%d")

The characters with % symbol gives me this syntax error:

Parse error: syntax error, unexpected '%' in C:\wamp\www\ayarabasla.php on line 4

How did I write the query with % symbols?

2
  • 1
    i see this kind of 'errors' more and more on SOF, don't you guys do some debugging? Don't you have a editor with highlightning? And whats even more wired, the error is displayed but you can't see it? Commented Oct 19, 2014 at 16:45
  • I was using NotePad for writing this. I was looking a good PHP IDE. They said me phpStorm is good but it's too slow and not free for me. Do you advice some good PHP ide? Commented Oct 19, 2014 at 16:52

1 Answer 1

3

The syntax highlighter show your error. It's a quote issue. Escape your inner double quotes:

$result = mysqli_query($con,"UPDATE operasyonkayitlari SET tarihgun=FROM_UNIXTIME(UNIX_TIMESTAMP(NOW())-28800, \"%Y.%m.%d\"), tezgah='".$_REQUEST['tezgah']."', operatoradi='".$_REQUEST['operator']."', ayarepoch=UNIX_TIMESTAMP(NOW()), durum='AYARDA' where isemri='".$_REQUEST['isemri']."' and operasyonno='".$_REQUEST['operasyonno']."'");

You can use single quotes, too:

$result = mysqli_query($con,"UPDATE operasyonkayitlari SET tarihgun=FROM_UNIXTIME(UNIX_TIMESTAMP(NOW())-28800, '%Y.%m.%d'), tezgah='".$_REQUEST['tezgah']."', operatoradi='".$_REQUEST['operator']."', ayarepoch=UNIX_TIMESTAMP(NOW()), durum='AYARDA' where isemri='".$_REQUEST['isemri']."' and operasyonno='".$_REQUEST['operasyonno']."'");
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! I couldn't see my quote error becouse I was using NotePad :) I think I should use some good IDE.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.