Solved

PHP/MYSQL - Query is empty error. =/

Posted on 2007-03-27
7
1,630 Views
Last Modified: 2013-12-13
Hello everyone. I'm having a bit of a dumbfounded moment here. For some reason, this script below which simply inserts 2 fields to the mysql db is giving a "query is empty" error.

$_SESSION['auth']="yes";
$logname = $_POST['fusername'];
$_SESSION['logname'] = $logname;
$today = date("Y-m-d h:m:s");
$sql = "INSERT INTO Member (loginName, loginTime) VALUES ('$logname', '$today')";
echo "$logname, $today"; // to see if there's a variable issue both variables echo correctly.
mysql_query($sq1) or die(mysql_error());

I've looked over this short code many dozens of times, but I just can't seem to figure it out.
I've used this same code, to directly insert them via phpmyadmin and it works fine.

Thanks in advance.
0
Comment
Question by:enyceexdanny
  • 4
  • 3
7 Comments
 
LVL 24

Accepted Solution

by:
glcummins earned 50 total points
ID: 18802669
$sql = "INSERT INTO Member (loginName, loginTime) VALUES ('$logname', '$today')";
echo "$logname, $today"; // to see if there's a variable issue both variables echo correctly.
mysql_query($sq1) or die(mysql_error());

Looks like the query is stored in '$sql' (ESS-QUE-ELL), but mysql_query is trying to call '$sq1' (ESS-QUE-ONE)
0
 
LVL 24

Expert Comment

by:glcummins
ID: 18802680
The eyes get a little blurry after too many hours of coding and debugging, no? :)
0
 

Author Comment

by:enyceexdanny
ID: 18802700
oh my.... You're right!
Haha, I feel extremely silly at the moment.

Anyways, thanks for the awesome quick response as always from ee. ^_^
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

Author Comment

by:enyceexdanny
ID: 18802715
Yeah. It actually looks identical.. I had to copy and paste that "1" into google. =)
0
 

Author Comment

by:enyceexdanny
ID: 18802746
maybe it's time to change the code font in zend.. lowercase L and 1 look exactly identical!.=O
0
 
LVL 24

Expert Comment

by:glcummins
ID: 18802767
I've tried fiddling on my end with other fonts that would differentiate better, but I always end up back at a monospace fixed font, because I think I can read the rest of the code better. If you find a font that works well for you, let me know! :)
0
 

Author Comment

by:enyceexdanny
ID: 18802981
Proggy clean seems pretty decent.
http://www.tactile3d.com/tristan/
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Convert html page to a php post email form automatically? 10 53
Why do people dis php? 5 47
php convert date format 3 21
How would I do this...? 2 27
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This article discusses four methods for overlaying images in a container on a web page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question