Solved

PHP/MYSQL - Query is empty error. =/

Posted on 2007-03-27
7
1,626 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

911 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now