Hi all,
I'm working on my first php+mysql program.
I have a mysqld running and there's a DB named "example" with a table
"tbl". Here it is:
--------------
mysql> use example;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select * from tbl;
+------+----------+----------+----------------+
| idx | UserName | LastName | FreeText |
+------+----------+----------+----------------+
| 2 | Rafi | Ton | Just a test |
| 1 | li | ken | Just two tests |
| 3 | ghjgj | jhn | Jus tests |
+------+----------+----------+----------------+
3 rows in set (0.00 sec)
---------------
When I tried to apply the following sample program, strange result came
to me. Let me show you the script.
---------------
<html>
<head><title>We b Database Sample Index</title>
</head>
<body bgcolor=#ffffff >
<h2>Data from tbl</h2>
<?
mysql_connect() or die ("Problem connecting to DataBase");
$query = "select * from tbl";
$result = mysql_db_query( "example", $query);
if ($result) {
echo "Found these entries in the database:<br><p ></p>";
echo "<table width=90% align=center border=1><tr>
<td align=center bgcolor=#00FFFF >User Name</td>
<td align=center bgcolor=#00FFFF >Last Name</td>
<td align=center bgcolor=#00FFFF >Domain Name</td>
<td align=center bgcolor=#00FFFF >Request Date</td>
</tr>";
while ($r = mysql_fetch_arr ay($result)) {
$idx = $r["idx"];
$user = $r["UserName"];
$last = $r["LastName"];
$text = $r["FreeText"];
echo "<tr>
<td>$idx</td>
<td>$user</td>
<td>$last</td>
<td>$text</td>
</tr>";
}
echo "</table>";
} else {
echo "No data.";
}
</body>
</html>
---------------
I ran this php page in IE and only to get "No data." as the result,
while I was expecting a list of my table contents. I cannot find the
error I made, actually I almost copied this script from some book.
Please help me to check it.
Any suggestion would be appreciated.
Best, zhy 4 1686 21********@gmai l.com ÐÉÛÅÔ: Hi all,
I'm working on my first php+mysql program. I have a mysqld running and there's a DB named "example" with a table "tbl". Here it is: -------------- mysql> use example; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A
Database changed mysql> select * from tbl; +------+----------+----------+----------------+ | idx | UserName | LastName | FreeText | +------+----------+----------+----------------+ | 2 | Rafi | Ton | Just a test | | 1 | li | ken | Just two tests | | 3 | ghjgj | jhn | Jus tests | +------+----------+----------+----------------+ 3 rows in set (0.00 sec) ---------------
When I tried to apply the following sample program, strange result came to me. Let me show you the script. --------------- <html> <head><title>We b Database Sample Index</title> </head> <body bgcolor=#ffffff > <h2>Data from tbl</h2>
<? mysql_connect() or die ("Problem connecting to DataBase"); $query = "select * from tbl"; $result = mysql_db_query( "example", $query);
I ran this php page in IE and only to get "No data." as the result, while I was expecting a list of my table contents. I cannot find the error I made, actually I almost copied this script from some book. Please help me to check it. Any suggestion would be appreciated.
mysql_db_query
Send a MySQL query (PHP 3, PHP 4 , PHP 5)
resource mysql_db_query ( string database, string query [, resource
link_identifier ] )
Note:
This function has been deprecated since PHP 4.0.6. Do not use this
function. Use mysql_select_db () and mysql_query() instead.
On Wed, 22 Jun 2005 05:29:09 -0700, 21novembre wrote: mysql_connect() or die ("Problem connecting to DataBase"); $query = "select * from tbl"; $result = mysql_db_query( "example", $query);
Go to the mysql_* section on http://www.php.net
COPY AND PASTE THE CODE EXAMPLES EXACTLY. Change the names.
Problem solved.
No point in reinventing the wheel. Plus the php.net site's examples
include some error checking and whatnot that your script desperately needs.
later...
--
JDS | je*****@go.away .com
| http://www.newtnotes.com
DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/
Change:
echo "No data.";
To:
echo "No data. And here is why: ";
echo mysql_error();
Notice how $result is evaluating to false, this is because the query
failed. According to the PHP manual mysql_query() (or mysql_db_query( ))
returns false on failure. Anyway, use mysql_select_db () and
mysql_query() instead.
Thank you, everybody. It works!! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: josh dismukes |
last post by:
/// Were having serious problems with this script it's basically the
map script allowing player movement but the problem is in the QUERY
and if statements on the cell type. Any help will be much appreciated
thanks you
<?php
session_start ();
require_once "connect.php";
|
by: Shufen |
last post by:
Hi,
I'm a newbie that just started to learn python, html and etc. I have
some questions to ask and hope that someone can help me on.
I'm trying to code a python script (with HTML) to get values from a
html form that consists of about 10 checkbox and a textbox where user
have to key in a value to perform a search.
From python tutors, I...
|
by: news-server.tampabay.rr.com |
last post by:
Hi,
Below is a stock script I found which controls a framed environment.
My problem is that if a URL has a query string attached, that string
does not pass through. Can someone please let me know if and
hopefully how, it will be possible to carry a query string through?
This first part here is in the default.asp framed page.
<SCRIPT...
|
by: Greg Schumacher |
last post by:
Running PHP v5.0.4 (compiled by www.entropy.ch) and mysql 5.0.16 on Mac
OS X 10.4.3. When I run the simple test script below the first query
sent from PHP to MySQL is successful but the second is not. sp_select is a
simple one-line script that performs "select * from test". If I replace
the call to the stored procedure with a select that does...
|
by: newhaven_lad |
last post by:
Please could someone help,
I have a Perl cgi script which works perfectly when run in a dos prompt, it connects to a database on my laptop and inserts a record. But when I use the internet browser to run the script it doesn't insert the record in the database or display any messages past the following line.
...
| |
by: octangle |
last post by:
This code is attempting to find records that have a RegJrnID that does
not occur more than one time in the table.
The reason that I want to find records with non-duplicated RegJrnID
values is to create "reversal" records for these such that the reversal
record has identical values for every column except the TaxableAmount
which will contain...
|
by: so many sites so little time |
last post by:
the table is head the colunm is called body
<?php //show_site.php
// This script retrieves blog entries from the database.
// Address error handing.
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);
// Connect and select.
|
by: fienen |
last post by:
I am working on a script to handle a search query. In some instances,
the query could come through as "isbn:%20#############" (where %20 is
an encoded space and the colon is optional). Basically I want to
strip off the ISBN portion and leave just the numbers if that is the
case.
Orignally I was trying
$value = $_GET;
if...
|
by: thatcollegeguy |
last post by:
Below are my 3php and 2js files.
I create a table using ajax/php and then want to change the values in the tables add(+ number for teamid) id's for each specific td in the table. I don't know if I have the entirely wrong approach, but my code is below. Any or all help is appreciated!
What currently happens is that the getdivision.php...
|
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...
|
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...
| |
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. ...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
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...
| |