I have been trying to run this MySQL query using PHP:
SELECT id, trans_type, remote_addr, DATE_FORMAT(tim e, '%M %e, %Y %r') as time
FROM transactions WHERE client_id = " . $client_id . " ORDER BY time asc
and I am getting this error message:
MySQL Error number: 1064: You have an error in your SQL syntax near 'ORDER BY time asc' at line 2
I added the "as time" in hopes it wasn't seeing the 'DATE_FORMAT()' field as the time field.
Does anyone have any advice?
Thanks in advance,
Rick Barnes 2 3076
Rick wrote: I have been trying to run this MySQL query using PHP:
SELECT id, trans_type, remote_addr, DATE_FORMAT(tim e, '%M %e, %Y %r') as time FROM transactions WHERE client_id = " . $client_id . " ORDER BY time asc
and I am getting this error message:
MySQL Error number: 1064: You have an error in your SQL syntax near 'ORDER BY time asc' at line 2
I added the "as time" in hopes it wasn't seeing the 'DATE_FORMAT()' field as the time field.
Does anyone have any advice?
Thanks in advance,
Rick Barnes
Sorry I just noticed this only happens when there are no records...this error occurs before I can
check the value of the returned query handle...how can this be avoided without running 2 queries?
One to check for any records and the other to run if there are any? I currently use:
"$result = mysql_query($qu ery)or die("MySQL Error number: " . mysql_errno() . ": " . mysql_error().
"\n");
Should I leave this out so I can test the returned handle's value ($result)?
TIA,
RB
time is an SQL reserved word
try:
SELECT id, trans_type, remote_addr, DATE_FORMAT(tim e, '%M %e, %Y %r')
as my_time
FROM transactions WHERE client_id = " . $client_id . " ORDER BY my_time asc
Hope this helps
Richard
Rick wrote: Rick wrote:
I have been trying to run this MySQL query using PHP:
SELECT id, trans_type, remote_addr, DATE_FORMAT(tim e, '%M %e, %Y %r') as time FROM transactions WHERE client_id = " . $client_id . " ORDER BY time asc
and I am getting this error message:
MySQL Error number: 1064: You have an error in your SQL syntax near 'ORDER BY time asc' at line 2
I added the "as time" in hopes it wasn't seeing the 'DATE_FORMAT()' field as the time field.
Does anyone have any advice?
Thanks in advance,
Rick Barnes
Sorry I just noticed this only happens when there are no records...this error occurs before I can check the value of the returned query handle...how can this be avoided without running 2 queries? One to check for any records and the other to run if there are any? I currently use:
"$result = mysql_query($qu ery)or die("MySQL Error number: " . mysql_errno() . ": " . mysql_error(). "\n");
Should I leave this out so I can test the returned handle's value ($result)?
TIA,
RB This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Johan den Boer |
last post by:
Hi,
What is wrong with this code ?
SELECT DATE_FORMAT( myfield, GET_FORMAT( TIMESTAMP, 'EUR' ) ) FROM T_TABLE;
regards
Johan
|
by: Jimmy |
last post by:
Hi,
I'm new to MySQL and I have qustion regarding to CAST and Date_Format
functions. I'm trying to convert a column 'Time' varchar(50) to
datetime datatype by "select date_format(cast(time as datetime),
'%m/%Y') from yo where id = 1" but the data returns incorrectly. For
example, the id 1 the time is '28-4-2004-4:11' once I ranthe query,
the return data is 04/2028. Looks like MySQL treated 28 as the year.
What can I do to make it...
|
by: sang |
last post by:
Hai
I want to change the date format at the time of inserting the record.
i done it but one error in the insertion.
The query is
insert into mytable(update) values(date_format( '2006-10-09','%d%m%y');
Query OK
but in the out put it will be in the form of '2009-10-06' ie in the date field 20 is added
|
by: sang |
last post by:
Sir
My table name ss with the field cur_date data type varchar()
show create table ss;
+-------+-----------------------------------------------------------------------
---------------------------+
| Table | Create Table
|
+-------+-----------------------------------------------------------------------
|
by: sang |
last post by:
Hi
In my table the date format is changed to 06-feb-2007.The query i execute is
select date_format(col.name,"%e-%b-%Y") from tablename;
This is worked well in local but in the web it will give the error. If we change the %b to %m ,its worked as both local and web also .but i want the date in format of 06-feb-2007. What can i do for this .Please any one help to do that in web.
Thanks in Advance
Sang
| |
by: adamalton |
last post by:
I am trying to take a date in the format "YYYY-MM-DD" and get from it the month as a word (e.g. July) and the day as a 2 digit number (e.g. 24).
I am trying to use the date_format function, (new as of php 5.2) but I can't get it to work...
$date = "2007-06-22 00:00:00";
//I also tried $date = "2007-06-22"; but that didn't work either
//I also tried adding strtotime($date); but that didn't help!
$month = date_format($date , 'F');
|
by: laverdir |
last post by:
<?
$query = "SELECT " . $this->tabela3 . ".id, " . $this->tabela3 .
".naziv, " . $this->tabela3 . ".spisatelj, " . $this->tabela3 .
".najava, " . " DATE_FORMAT(" . $this->tabela3 . ".vrijeme_stavljanja,
'%e. %c. %Y. %k:%i') FROM " . $this->tabela3 . ", " . $this->tabela2 .
" AS xref WHERE " . $this->tabela3 . ".id=xref.spis_id AND
xref.vrsta_id=" . $this->DB->quote($vrsta) . " ORDER BY " .
$this->tabela3 . ".vrijeme_stavljanja DESC";
?>
|
by: docscsi |
last post by:
Dear all
I'm quite new to mysql. My aim is to select a date format field by
returning only the month and day number of it (e.g. date = 11 12). I
got this statement and I could not get out how to get rid of the
error:
SELECT `email`, `raum`, DATE_FORMAT('date',`%c %d`) as date FROM
`logger`;
|
by: ann86 |
last post by:
Hello,
I am a newbie to PHP and I am working on a site that was created by someone else. The server was updated yesterday so now I am getting the error
Fatal error: Cannot redeclare date_format(). I know that this is built in with PHP 5 but I need to know how to fix it without getting another error message saying that my cookies are disabled. Can anyone please help me?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |