Ask a Question related to PHP Development, Design and Development.
-
luckyrye #1
MySql query help
Hey,
I am trying to retrive information from a database using the
'Mysql_fetch_assoc' function, but the problem is.. it is just
one row of data from the table, not an array, so it generates an
error. What function do u use/ What do i need to do to just get that
one row?
thankx.
// error
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL
result resource in ********* on line 23
//
<!-- my code segment !-->
<?
query = "SELECT * FROM users WHERE user =
'user' LIMIT 1";
result = mysql_query(query);
record = mysql_fetch_assoc(query);
{
fname = record["fname"];
lname = record["lname"];
mname = record["mname"];
position = record["position"];
}
?>
<!-- end my code-->
----------------------------------------
The post originated from PHP Freaks:
----------------------------------------
[url]http://www.phpfreaks.com[/url]
[url]http://www.phpfreaks.com/forums[/url]
luckyrye Guest
-
Is this a MySQL Query bug?
I wrote a SQL script in MySQL Query, and saved it as script.sql, but when I executed it in windows command line "mysql -h localhost -u root... -
MySQL Query Cache Not Working: MySQL 5 / Windows XP
Please excuse this post if you've already read it on mailing.database.mysql - i just discovered these other groups. future posts will be... -
MYSQL query: AND OR?
This will probably sound stupid. How would you do a MYSQL query that was to evaluate if either condition A or B was meet? And if so, in what... -
Query log for mySQL?
Is there a simple way to create a query log for mySQL? I've been asked^h^h^h^h^h told to add a layer of auditing on an existing application. It's... -
mysql/php query
I have a question about (i think) joining. If I have a table in a database that has this info: key - name - favorite 1 - john - 2 2 - ... -
Chris Hope #2
Re: MySql query help
luckyrye wrote:
From your example this is wrong:> I am trying to retrive information from a database using the
> 'Mysql_fetch_assoc' function, but the problem is.. it is just
> one row of data from the table, not an array, so it generates an
> error. What function do u use/ What do i need to do to just get that
> one row?
$result = mysql_query($query);
$record = mysql_fetch_assoc($query);
It should be like this:
$result = mysql_query($query);
$record = mysql_fetch_assoc($result);
--
Chris Hope
The Electric Toolbox - [url]http://www.electrictoolbox.com/[/url]
Chris Hope Guest
-
luckyrye #3
Re: MySql query help
Ooops, i get careless sometimes. sry bout that.
----------------------------------------
The post originated from PHP Freaks:
----------------------------------------
[url]http://www.phpfreaks.com[/url]
[url]http://www.phpfreaks.com/forums[/url]
luckyrye Guest



Reply With Quote

