Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.