Hi,
I'm doing a table insert and have a question about mysql_affected_ rows().
The following code works. It correctly inserts the row and
mysql_affected_ rows() returns 1 as it should do.
$sql = "INSERT INTO member (company, username, password, cookie,
session, ip) VALUES ('$company', '$user', '$pass', 'fakecookie',
'fakesession', '192.168.1.1')" ;
$result = mysql_query($sq l) or MyDie("Error: ".mysql_error() );
// Determine success:
// mysql_affected_ rows returns the number of affected rows on
// success, and -1 if the last query failed.
$rowsAffected = mysql_affected_ rows();
However the final line, the call to mysql_affected_ rows, used to have
$result as an argument, like this:
$rowsAffected = mysql_affected_ rows($result);
Which as far as I can tell is correct. When I use that line, the row gets
inserted correctly, but the call to mysql_affected_ rows() fails, with the
following error message:
"Warning: mysql_affected_ rows(): supplied argument is not a valid
MySQL-Link resource in /home/fakeuser/public_html/test/adduser.php on line
104"
I don't understand why it is not a valid link resource. The almost
identical code, but making a 'select' query and not doing an 'insert',
works fine when checking with 'mysql_num_rows ($result)'.
Obviously this is not critical, since I've got it working, but in the
interests of increasing my understanding can someone explain this problem
to me please.
Many thanks. 5 2021
"Warning: mysql_affected_ rows(): supplied argument is not a valid
MySQL-Link resource in /home/fakeuser/public_html/test/adduser.php on
line 104"
PHP Manual:
For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning
resultset, mysql_query() returns a resource on success, or FALSE on error.
For other type of SQL statements, UPDATE, DELETE, DROP, etc,
mysql_query() returns TRUE on success or FALSE on error.
So: Because TRUE is not a Resource, which is expected.
Ha, that was easy.
Indeed, mysql_affected_ rows() does NOT expect the return value of
mysql_query(), but the connection resource: http://de2.php.net/manual/en/functio...ected-rows.php
So, to but it in a nutshell: RTFM!
Jonas Werres emailed this:
>"Warning: mysql_affected_ rows(): supplied argument is not a valid MySQL-Link resource in /home/fakeuser/public_html/test/adduser.php on line 104"
PHP Manual:
For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning
resultset, mysql_query() returns a resource on success, or FALSE on error.
For other type of SQL statements, UPDATE, DELETE, DROP, etc,
mysql_query() returns TRUE on success or FALSE on error.
So: Because TRUE is not a Resource, which is expected.
Ha, that was easy.
Indeed, mysql_affected_ rows() does NOT expect the return value of
mysql_query(), but the connection resource: http://de2.php.net/manual/en/functio...ected-rows.php
So, to but it in a nutshell: RTFM!
Oh, I'm so sorry! I did RTFM, but *obviously* not very effectively.
Thanks for the help.
Feeling humbled and very sorry.
On Nov 12, 8:15 pm, MS <No.Way.J...@No .Spam.Thank.You .comwrote:
Jonas Werres emailed this:
"Warning: mysql_affected_ rows(): supplied argument is not a valid
MySQL-Link resource in /home/fakeuser/public_html/test/adduser.php on
line 104"
PHP Manual:
For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning
resultset, mysql_query() returns a resource on success, or FALSE on error.
For other type of SQL statements, UPDATE, DELETE, DROP, etc,
mysql_query() returns TRUE on success or FALSE on error.
So: Because TRUE is not a Resource, which is expected.
Ha, that was easy.
Indeed, mysql_affected_ rows() does NOT expect the return value of
mysql_query(), but the connection resource: http://de2.php.net/manual/en/functio...ected-rows.php
So, to but it in a nutshell: RTFM!
Oh, I'm so sorry! I did RTFM, but *obviously* not very effectively.
Thanks for the help.
Feeling humbled and very sorry.
Well, you shouldn't feel humbled and very sorry, but only sorry.
Don't exaggerate :)
Darko emailed this:
On Nov 12, 8:15 pm, MS <No.Way.J...@No .Spam.Thank.You .comwrote:
>Jonas Werres emailed this:
>>>"Warning: mysql_affected_ rows(): supplied argument is not a valid MySQL-Link resource in /home/fakeuser/public_html/test/adduser.php on line 104" PHP Manual: For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or FALSE on error. For other type of SQL statements, UPDATE, DELETE, DROP, etc, mysql_query () returns TRUE on success or FALSE on error. So: Because TRUE is not a Resource, which is expected. Ha, that was easy. Indeed, mysql_affected_ rows() does NOT expect the return value of mysql_query() , but the connection resource: http://de2.php.net/manual/en/functio...ected-rows.php So, to but it in a nutshell: RTFM!
Oh, I'm so sorry! I did RTFM, but *obviously* not very effectively.
Thanks for the help.
Feeling humbled and very sorry.
Well, you shouldn't feel humbled and very sorry, but only sorry.
Don't exaggerate :)
Ok, I take the humbled bit back. I'm just sorry. ;-)
MS wrote:
Jonas Werres emailed this:
>>"Warning: mysql_affected_ rows(): supplied argument is not a valid MySQL-Link resource in /home/fakeuser/public_html/test/adduser.php on line 104"
PHP Manual: For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or FALSE on error. For other type of SQL statements, UPDATE, DELETE, DROP, etc, mysql_query( ) returns TRUE on success or FALSE on error.
So: Because TRUE is not a Resource, which is expected. Ha, that was easy.
Indeed, mysql_affected_ rows() does NOT expect the return value of mysql_query( ), but the connection resource: http://de2.php.net/manual/en/functio...ected-rows.php
So, to but it in a nutshell: RTFM!
Oh, I'm so sorry! I did RTFM, but *obviously* not very effectively.
Thanks for the help.
Feeling humbled and very sorry.
Don't worry about it. This area of mysql can be confusing. So many of
the calls take a result from mysql_query(), and you would think that
this one would, also.
But alas, it's (one of) the exception(s) to the "rule". :-)
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== === This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ben |
last post by:
Hi all,
I want to store unique data about my page visit. This is done using
cookie value. In my database, the page name and cookie value(ip
address) are both primary keys. This ensures unique entry. The
following code works fine:
$query = "INSERT INTO counter SET page='$currentfile',
uid='$cookie_val',
referer='$ref', count = 1, accesstime='$fileatime' ON
DUPLICATE KEY
UPDATE referer='$ref', count=count+1,
|
by: Stevey |
last post by:
I have the following XML file...
<?xml version="1.0"?>
<animals>
<animal>
<name>Tiger</name>
<questions>
<question index="0">true</question>
<question index="1">true</question>
</questions>
|
by: nospam |
last post by:
Ok, 3rd or is it the 4th time I have asked this question on Partial Types,
so, since it seems to me that Partial Types is still in the design or
development stages at Microsoft, I am going to ask it differently.
FOUR QUESTIONS:
The background:
I got three (3) files
|
by: Ekqvist Marko |
last post by:
Hi,
I have one Access database table including questions and answers. Now
I need to give answer id automatically to questionID column. But I
don't know how it is best (fastest) to do?
table before
rowID answID qryrow questionID datafield
1591 12 06e 06e 06e question
1593 12 06f 06f 06f question
1594 12 answer to the question 06f
|
by: glenn |
last post by:
I am use to programming in php and the way session and post vars are past
from fields on one page through to the post page automatically where I can
get to their values easily to write to a database or continue to process on
to the next page.
I am now trying to learn ASP to see if we can replace some of our
applications that were written in php with an ASP alternative. However,
after doing many searches on google and reading a couple...
| |
by: Rider |
last post by:
Hi, simple(?) question about asp.net configuration..
I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm
first start application the follow message shown.
=========
Server Error in '/QuickStartv20' Application.
--------------------------------------------------------------------------------
Configuration Error
Description: An error occurred during the processing of a configuration file
|
by: Jeff |
last post by:
In the function below, can size ever be 0 (zero)?
char *clc_strdup(const char * CLC_RESTRICT s)
{
size_t size;
char *p;
clc_assert_not_null(clc_strdup, s);
size = strlen(s) + 1;
|
by: Tyno Gendo |
last post by:
Two questions in a row.. I'm on a roll :)
When i perform UPDATEs in my admin system, I'm checking for success by
using mysql_affected_rows() and this works fine if data is changed and
updated.
However, if a user submits an admin page without chaning any details,
the SQL executes fine, but mysql_affected_rows() returns 0 as MySQL is
clever enough to work out that nothing changed.
|
by: Sandman |
last post by:
Hi,
So I read the manual where it says to use mysql_affected_rows() for
everything except SELECT and SHOW, and use mysql_num_rows() for those
two, which actually return a result.
However, I wrote this little script below where I find that
mysql_num_rows() returns exactly the same output in the case of
SELECT, as mysql_affected_rows(). In the case of the INSERT,
mysql_num_rows() does not return anything.
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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: 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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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: 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.
| |