Jump to content

mysql error


digitalgod

Recommended Posts

hey guys,

trying to figure out why this query is giving me an error..

[code]
mysql_query("SELECT * FROM " . $prefix . "users WHERE created >= ".$_SESSION['last_login']." ORDER BY id") or die(query_error());
[/code]

"created" is formatted in DATETIME and so is $_SESSION['last_login'] but I keep getting this error

[quote]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 '16:46:09 ORDER BY id' at line 1[/quote]

any ideas?
Link to comment
https://forums.phpfreaks.com/topic/15931-mysql-error/
Share on other sites

Strings in MySQL need to be delimitied by quotes. Try:
[code]<?php
$q = "SELECT * FROM " . $prefix . "users WHERE created >= '".$_SESSION['last_login']."' ORDER BY id");
$rs = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error());
?>[/code]

Ken
Link to comment
https://forums.phpfreaks.com/topic/15931-mysql-error/#findComment-65445
Share on other sites

[code]mysql_query("SELECT * FROM " . $prefix . "users WHERE created >= ".$_SESSION['last_login']." ORDER BY id") or die(query_error());[/code]
$select  = "SELECT * FROM users, WHERE
atleast explain what the $prefix is, and for what
if you are trying to pass a variable to check the name
like a variable as what you are selecting
it should be
"SELECT * FROM '$prefix', users WHERE created >= '$_SESSION[last_login]';";  The only thing you need for the session is $_SESSION[last_login] surrounded by single quotes.
Link to comment
https://forums.phpfreaks.com/topic/15931-mysql-error/#findComment-65447
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.