473,588 Members | 2,471 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with select count(*)

Ben
Hi,

I have a problem with this query:
$link = mysql_connect(" localhost", "root", "pw");
$dbsel = mysql_select_db ('mydb', $link);
$lol='bibi';

$sql = "select count(*) as totuur from studres where where dag>= curdate()
AND logon='" . $lol . "'";
$result = mysql_query($sq l);
$row = mysql_fetch_fie ld($result,0);
// J'ai essayé avec: $row = mysql_fetch_row ($result);
$totu=$row[0];
The error is on line: $row = mysql_fetch_fie ld($result,0):
Warning: mysql_fetch_fie ld(): supplied argument is not a valid MySQL result
resource in c:\Inetpub\wwwr oot\myfile.php on line 74
Thanks
Ben
Dec 19 '05 #1
2 5215
"Ben" <sdvs@qcsq> wrote in message
news:M8******** ************@sc arlet.biz...
Hi,

I have a problem with this query:
$link = mysql_connect(" localhost", "root", "pw");
$dbsel = mysql_select_db ('mydb', $link);
$lol='bibi';

$sql = "select count(*) as totuur from studres where where dag>= curdate()
AND logon='" . $lol . "'";

You have WHERE twice in "...from studres where where dag...", try what
happens if you remove the extra where. This is one of the reasons why sql
keywords should be written in CAPITAL letters. It's easier to spot the error
if you write:
"SELECT COUNT(*) AS totuur FROM studres WHERE WHERE dag>= CURDATE() AND
logon='$lol'"

--
"En ole paha ihminen, mutta omenat ovat elinkeinoni." -Perttu Sirviö
an************* ******@gmail.co m.NOSPAM.invalid
Dec 19 '05 #2
Kimmo Laine wrote:
"Ben" <sdvs@qcsq> wrote in message
news:M8******** ************@sc arlet.biz...
Hi,

I have a problem with this query:
$link = mysql_connect(" localhost", "root", "pw");
$dbsel = mysql_select_db ('mydb', $link);
$lol='bibi' ;

$sql = "select count(*) as totuur from studres where where dag>= curdate()
AND logon='" . $lol . "'";


You have WHERE twice in "...from studres where where dag...", try what
happens if you remove the extra where. This is one of the reasons why sql
keywords should be written in CAPITAL letters. It's easier to spot the error
if you write:
"SELECT COUNT(*) AS totuur FROM studres WHERE WHERE dag>= CURDATE() AND
logon='$lol'"


And if you would have checked the result of the mysql_query() call, you
would have found your problem.

$result = mysql_query($sq l);
if ($result) {
$row = mysql_fetch_fie ld($result,0);
// J'ai essayé avec: $row = mysql_fetch_row ($result);
$totu=$row[0];
}
else
echo "MySQL error: " . mysql_error();
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Dec 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
2125
by: MyaTiX | last post by:
Hi Can someone please help! I am having a problem with a form! I need to be able to pull information from one table when the page loads and update another table after I have made changes but the second time the page loads I want to load the information from the second table and not from the origional location. How do I do something like this?
3
4677
by: Nicolas Payre | last post by:
Hi, I have the following SQL that I want to use to update a table. It doesn't work ! Does someone knows why? ** I Know it could be done easy with a CURSOR FOR LOOP, but still... Thanks for your help. update XSORA1A.XS0011T_STATISTIQUES_UNIX a
6
2737
by: Bill | last post by:
I've created this: SELECT c.ProjectID, Count(c.ID) as 'Registrants', Count(dt.Hits) as 'Submissions' FROM CME_TBL c JOIN (SELECT ProjectID, Count(*) as Hits FROM CME_TBL
3
3539
by: Ian T | last post by:
Hi, I've got what I think (probably incorrectly) should be a simple SELECT : Two colums with data like col1 col2 1 50 1 51 2 50
3
1671
by: Robert | last post by:
Greetings I have been trying to write a script that will list out the size of each user table in a specified DB. I am running into a scoping problem when trying to format my display. I am sure there are several ways to derive the results. My method won't allow me to select count(*) from @tab_var as it barks that I must declare the variable @tab_var.
1
4228
by: Rohit Raghuwanshi | last post by:
Hello all, we are running a delphi application with DB2 V8.01 which is causing deadlocks when rows are being inserted into a table. Attaching the Event Monitor Log (DEADLOCKS WITH DETAILS) here. From the log it looks like the problem happens when 2 threads insert 1 record each in the same table and then try to aquire a NS (Next Key Share) lock on the record inserterd by the other thread. Thanks Rohit
20
2483
by: Development - multi.art.studio | last post by:
Hello everyone, i just upgraded my old postgres-database from version 7.1 to 7.4.2. i dumped out my 7.1 database (with pg_dump from 7.1) as an sql-file with copy-commands and to one file using insert-statements. after initalizing and starting postgres 7.4 on a different port and datadirectory, i tried to import the sql-dump with the copy statements. this import fails, but importing the dump-file with inserts took a long time but was...
4
2121
by: infiniti | last post by:
Hi, I am coming across problems in trying to EFFICIENTLY merge to XML files into one which involves transposing the rows into columns so that I can either generate a single flat xml file or store it in a flat table in the database. The 2 XML files which I have are: <xml> <keyword>
22
12449
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source=" & msDbFilename moConn.Properties("Persist Security Info") = False moConn.ConnectionString = msConnString moConn.CursorLocation = adUseClient moConn.Mode = adModeReadWrite' or using default...same result
58
8045
by: bonneylake | last post by:
Hey Everyone, Well recently i been inserting multiple fields for a section in my form called "serial". Well now i am trying to insert multiple fields for the not only the serial section but also the parts section an i seem to be having trouble. When i try to insert into the parts section i get the error Invalid character value for cast specification. But not sure what i am doing wrong. Here is what i am using to insert. All the sections...
0
7929
marktang
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...
0
7862
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,...
0
8228
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8357
jinu1996
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...
1
7987
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,...
0
8223
tracyyun
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...
0
6634
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
3847
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
1196
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.