Hello
I get the following error
"Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
result resource in path/user-groups.php on line 25" (line 25 is the
one with a *)
with
@require(dirname(__FILE__) . '/../../config_php/config.php');
$query ="select * from users where " . "user_name " ."like" . "%" .
$_POST['username'] . "%";
$link = mysql_connect(
$conf['sql']['host'],
$conf['sql']['user'],
$conf['sql']['pass']
) or die ("cannot make connection to {$conf['sql']['db']}");
if (mysql_select_db($conf['sql']['db'],$link)) {
$result = mysql_query($query, $link);
while ($row = mysql_fetch_array($result)) { //*
echo $row['user_name'] . " " . $row['group1'] ."<br>";
}
}
why?!
is it because there is only 1 record for each user_name?
Cheers
Geoff 4 1216
Geoff Cox wrote:
Hello
I get the following error
"Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
result resource in path/user-groups.php on line 25" (line 25 is the
one with a *)
with
@require(dirname(__FILE__) . '/../../config_php/config.php');
$query ="select * from users where " . "user_name " ."like" . "%" .
$_POST['username'] . "%";
$link = mysql_connect(
$conf['sql']['host'],
$conf['sql']['user'],
$conf['sql']['pass']
) or die ("cannot make connection to {$conf['sql']['db']}");
if (mysql_select_db($conf['sql']['db'],$link)) {
$result = mysql_query($query, $link);
while ($row = mysql_fetch_array($result)) { //*
echo $row['user_name'] . " " . $row['group1'] ."<br>";
}
}
why?!
is it because there is only 1 record for each user_name?
Cheers
Geoff
No, it's because your mysql_query had an error.
ALWAYS check the results of ANY mysql call. In this case:
if (!$result)
echo mysql_error();
will show you your problem.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attglobal.net
==================
Geoff Cox <gc**@freeuk.notcomwrote:
Hello
I get the following error
"Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
result resource in path/user-groups.php on line 25" (line 25 is the
one with a *)
with
@require(dirname(__FILE__) . '/../../config_php/config.php');
$query ="select * from users where " . "user_name " ."like" . "%" .
$_POST['username'] . "%";
$link = mysql_connect(
$conf['sql']['host'],
$conf['sql']['user'],
$conf['sql']['pass']
) or die ("cannot make connection to {$conf['sql']['db']}");
if (mysql_select_db($conf['sql']['db'],$link)) {
$result = mysql_query($query, $link);
while ($row = mysql_fetch_array($result)) { //*
echo $row['user_name'] . " " . $row['group1'] ."<br>";
}
}
Two observations: (1) like '%foo%' (the apostrophes are required).
You show: like%foo%
(2) Dangerous to use raw POST in a query, see: http://php.net/function.mysql-real-escape-string
--
Charles
On Mon, 11 Aug 2008 19:37:38 -0400, Jerry Stuckle
<js*******@attglobal.netwrote:
>Geoff Cox wrote:
>Hello
I get the following error
"Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in path/user-groups.php on line 25" (line 25 is the one with a *)
with
@require(dirname(__FILE__) . '/../../config_php/config.php');
$query ="select * from users where " . "user_name " ."like" . "%" . $_POST['username'] . "%";
$link = mysql_connect( $conf['sql']['host'], $conf['sql']['user'], $conf['sql']['pass'] ) or die ("cannot make connection to {$conf['sql']['db']}");
if (mysql_select_db($conf['sql']['db'],$link)) {
$result = mysql_query($query, $link);
while ($row = mysql_fetch_array($result)) { //* echo $row['user_name'] . " " . $row['group1'] ."<br>"; } }
why?!
is it because there is only 1 record for each user_name?
Cheers
Geoff No, it's because your mysql_query had an error.
ALWAYS check the results of ANY mysql call. In this case:
if (!$result)
echo mysql_error();
will show you your problem.
it did indeed!
thanks Jerry.
Cheers
Geoff
On Mon, 11 Aug 2008 23:35:10 -0500, Charles Polisher
<cp*****@nonesuch.comwrote:
>Geoff Cox <gc**@freeuk.notcomwrote:
>Hello
I get the following error
"Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in path/user-groups.php on line 25" (line 25 is the one with a *)
with
@require(dirname(__FILE__) . '/../../config_php/config.php');
$query ="select * from users where " . "user_name " ."like" . "%" . $_POST['username'] . "%";
$link = mysql_connect( $conf['sql']['host'], $conf['sql']['user'], $conf['sql']['pass'] ) or die ("cannot make connection to {$conf['sql']['db']}");
if (mysql_select_db($conf['sql']['db'],$link)) {
$result = mysql_query($query, $link);
while ($row = mysql_fetch_array($result)) { //* echo $row['user_name'] . " " . $row['group1'] ."<br>"; } }
Two observations: (1) like '%foo%' (the apostrophes are required). You show: like%foo% (2) Dangerous to use raw POST in a query, see: http://php.net/function.mysql-real-escape-string
thanks for both ideas - is working now!
Cheers
Geoff This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Lenz Grimmer |
last post by:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
MySQL 4.0.14, a new version of the popular Open Source/Free Software
Database, has been released. It is now available in source and binary...
|
by: Stefan Hinz |
last post by:
Degan,
jumping in to try and solve some problems that look pretty obvious to
me ...
> #options for default service (mysqld2)
> (mysqld2)
It should be , not (mysqld2).
|
by: Donald Tyler |
last post by:
Then the only way you can do it that I can think of is to write a PHP script
to do basically what PHPMyAdmin is trying to do but without the LOCAL in
there.
However to do that you would need to...
|
by: Annie Xie |
last post by:
1> anyone has a compiled tarball for mysql new version (-4.0 up) for
solaris 2.6 can be shared? The OS was patched latest.
2> I'm trying build it, configure w/o any problem. However, when dong...
|
by: jmlynn |
last post by:
Help!
I installed MySQL 4.0.20C and it works if I started it with
mysqld --console
However, if I do the following:
mysqld --install
net start MySQL
|
by: Adam Smith |
last post by:
I have a dedicated server running 'FreeBSD 4.9 STABLE' at a hosting
site. They have done some default installations, presumably from the CVS
ports package ??. Herein lies the problem, "I do not...
|
by: Juan Antonio Villa |
last post by:
Hello, I'm having a problem replicating a simple database using the binary
log replication, here is the problem:
When the master sends an update to the slave, an example update reads as
follows:...
|
by: cwho.work |
last post by:
Hi!
We are using apache ibatis with our MySQL 5.0 database (using innodb
tables), in our web application running on Tomcat 5. Recently we
started getting a number of errors relating to...
|
by: Bruce A. Julseth |
last post by:
I have the following code
$Host = "localhost";
$User = "Fred";
$Database = "house";
$Password = "mypw"
echo "before mysqli<br />Host: " . $Host . "<br />" . $User . "<br />" .
$Database;
|
by: alex |
last post by:
I've converted a latin1 database I have to utf8. The process has been:
# mysqldump -u root -p --default-character-set=latin1 -c --insert-ignore
--skip-set-charset mydb mydb.sql
# iconv -f...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
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...
|
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...
|
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...
|
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,...
| |