where is the error in a query performed with php in this script?
<?php
@ $db=mysql_pconn ect('localhost' , 'database_name' , 'password');
if (!$db)
{
echo 'conneciton eror';
exit;
}
else
{
echo 'connection on!';
}
mysql_select_db ('books'); //books: table created previously.
$query="select * from orders"; //orders: a table that i have
previosly created.
$result=mysql_q uery($query);
$num_results=my sql_num_rows($r esult);
if ($num_results = 0)
{
echo'<br><br>no thing to dispaly';
}
else
{
echo'<br><br>he re are the results: $num_results';
}
?> 7 1226
On Jun 4, 12:36 pm, vinnie <centro.ga...@g mail.comwrote:
where is the error in a query performed with php in this script?
<?php
@ $db=mysql_pconn ect('localhost' , 'database_name' , 'password');
if (!$db)
{
echo 'conneciton eror';
exit;
}
else
{
echo 'connection on!';
}
mysql_select_db ('books'); //books: table created previously.
$query="select * from orders"; //orders: a table that i have
previosly created.
$result=mysql_q uery($query);
$num_results=my sql_num_rows($r esult);
if ($num_results = 0)
{
echo'<br><br>no thing to dispaly';}
else
{
echo'<br><br>he re are the results: $num_results';}
?>
wrong: if ($num_results = 0)
right: if ($num_results == 0)
>
wrong: if ($num_results = 0)
right: if ($num_results == 0)
ok, but why i don't get any results from the query?
Message-ID: <11************ **********@k79g 2000hse.googleg roups.comfrom
vinnie contained the following:
>where is the error?
Here
>if ($num_results = 0)
= is the assignment operator. You will never display any results since
this will always evaluate to true.
Try
if ($num_results <1)
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Message-ID: <11************ *********@m36g2 000hse.googlegr oups.comfrom
vinnie contained the following:
>
>> wrong: if ($num_results = 0)
right: if ($num_results == 0)
ok, but why i don't get any results from the query?
Change this
echo'<br><br>he re are the results: $num_results';
to this
echo '<br><br>here are the results: '.$num_results;
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Change this
echo'<br><br>he re are the results: $num_results';
to this
echo '<br><br>here are the results: '.$num_results;
thanks Geoff, it works perfectly now. But what's the difference? Is
not the same thing?
vinnie wrote:
>Change this echo'<br><br>h ere are the results: $num_results'; to this echo '<br><br>here are the results: '.$num_results;
thanks Geoff, it works perfectly now. But what's the difference? Is
not the same thing?
The difference is that unlike double-quoted strings, single-quoted
strings do not replace variable names inside the quotes with variable
values. The version that works concatenates your string with the value
of $num_results variable.
You could also have written
echo "<br><br>he re are the results: $num_results";
Message-ID: <46********@new s.bihnet.bafrom Denis Gerina contained the
following:
>thanks Geoff, it works perfectly now. But what's the difference? Is not the same thing? The difference is that unlike double-quoted strings, single-quoted strings do not replace variable names inside the quotes with variable values. The version that works concatenates your string with the value of $num_results variable.
What he said.
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Michael Whittaker |
last post by:
Hello!
I have a problem with my php script.
The script's task is to search an IP-Database with ranges as entries
and find, in which range the entered IP is.
OK, I've queried the MySQL-Results of the ranges into an array,
containing the
"IP ==> internalid"
where internalid is the Primarykey of the table from which I can get
|
by: Ravi Shankar |
last post by:
Hi all,
I have a calendar application( like Microsoft Outlook) writtn in
Java.Whenever an event is created, we can set SMS/EMAIL notification. Hence
when an event is created, I am storing that event info and notification time
into a database.Now the notification can be ranging from 5 minutes to say
one day.Hence I need to query the databse every 5 minutes and fetch the data
and do send the notification directly. I understand that such a...
|
by: Keith |
last post by:
I am fairly new to SQL so sorry if this is a really dumb question.
I have a small (still) SQL database, which I am trying to query from an ASP
page.
The field I am querying is of DATETIME data type, and is populated
automatically using the GetDate() function as a default value.
When I try and search on this field, using a date/time in the format
dd/mm/yyyy hh:mm:ss as the search criteria, it fails with the following
|
by: valexena |
last post by:
After a few minutes of querying the database my session disconnects
abruptly. Can somebody help me and tell why can be happening?
--
Posted via http://dbforums.com
|
by: Ron L. |
last post by:
Hi,
Any suggestions for a good intorudction to OLAP querying with MDX?
Thanks,
Ron.
--
Performance Intelligence, Inc.
Spy 4 DB2 - http://www.pireporting.com/spy4db2.html
| |
by: Greg |
last post by:
I am working on a project that will have about 500,000 records in an XML
document. This document will need to be queried with XPath, and records
will need to be updated. I was thinking about splitting up the XML into
several XML documents (perhaps 50,000 per document) to be more efficient but
this will make things a lot more complex because the searching needs to go
accross all 500,000 records. Can anyone point me to some best practices...
|
by: Shane |
last post by:
I wonder if someone has any ideas about the following.
I am currently producing some reports for a manufacturing company who work
with metal.
A finished part can contain multiple sub-parts to make up the finished part.
The sub-parts can also be made up of sub-parts and those sub-parts can also
be made up of sub-parts etc etc.
All parts are contained within the same table and I have a seperate table
|
by: MDB |
last post by:
I'd normally Google for a question like this, and hope to snag a few
examples along with the answer, but this time I can't see to get the
keywords specific enough.
Or I'd ask coworkers, but they're just as new to ASP.NET as I am.
Is it possible to have a dataset filled with all the records in an SQL table
(on the small side, maybe three hundred records total), and then query that
table for subsets of data, e.q. a simple WHERE clause,...
|
by: RajSharma |
last post by:
Hi,
I am facing a problem regarding querying thru a large table having millions of rows.......
Its hanging in between while querying for all those rows
Can anybody suggest me a query regarding :
Querying the database everytime for next 100 records ( that means i need to set up a cursor) till the count of the table rows ends up(take 1 million rows e.g.)
The database is DB2
|
by: =?Utf-8?B?U3VoYXMgVmVuZ2lsYXQ=?= |
last post by:
Hello,
I am facing an issue while querying Active directory using C# code with
system.DirectoryServices namespace.
Here is the path for my LDAP -
"LDAP://CN=XY - C++/Unix and other, OU=Automatic,OU=DLs,DC=domain,DC=com";
I have replaced the / character with\/- but still is giving error while
querying. Please help me to resolve this.
|
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...
| |
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...
|
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,...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |