johnecollins
asked on
Get a warning when I use mysqli_fetch_field
I have some code in php with a sql statement
$field = mysql_fetch_field($this->c xn, "select max(my_seqnum) from sequfile")
I get a warning
(!) Warning: mysqli_fetch_field() expects exactly 1 parameter, 2 given in C:\\...\.....\sequfile.cla ss on line 67
max(field name) is an aggragte function so don't understand how I get this warning, can anybody help?
$field = mysql_fetch_field($this->c
I get a warning
(!) Warning: mysqli_fetch_field() expects exactly 1 parameter, 2 given in C:\\...\.....\sequfile.cla
max(field name) is an aggragte function so don't understand how I get this warning, can anybody help?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi gplana.
I have made the connection, and selected the database, I'm sorry I should have made all that clear.
So I am still perplexed as to how select max produces more than one output - that is if I'm reading the warning correctly and the warning is not talking about parameters going in.
thank you for responding
John
I have made the connection, and selected the database, I'm sorry I should have made all that clear.
So I am still perplexed as to how select max produces more than one output - that is if I'm reading the warning correctly and the warning is not talking about parameters going in.
thank you for responding
John
The point is you should use mysql_query function to execute your select, not mysql_fetch_assoc.
And then you should store the result of mysql_query on a variable and use on mysql_fetch_assoc as a single parameter. Please see the example I said before to see the details.
Regards.
Regards.
SELECT MAX will return one and only one row (there can only be one MAX) or it will return zero rows if the table is empty. The php function var_dump() can be used to visualize the row that is returned. It will contain something like this:
$row["my_max"] = string(3) "365"
$row["my_max"] = string(3) "365"
ASKER
gplana,
sorry I had missed that and thank you for sending me your original answer
John
sorry I had missed that and thank you for sending me your original answer
John
ASKER
gplana,
sorry I had missed that and thank you for sending me your original answer
John
sorry I had missed that and thank you for sending me your original answer
John
ASKER
Ray,
thanks for that, most useful, this is is a further development following on from the posting about generating random number keys and I would really like to thank you for that most useful.
thanks for that, most useful, this is is a further development following on from the posting about generating random number keys and I would really like to thank you for that most useful.
Thanks for the points, John. Whenever you see a warning message from PHP it (almost always) contains the name of a function. Look that up on PHP.net and you will find a pretty good explanation of how to use the function. Best, ~Ray
you should enter the query on mysql_query function and before that you should make a connection by using mysql_connect function and select database with mysql_select_db function. See the example on the link I send to you.
Hope it helps.