473,466 Members | 1,290 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Getting value from existing query

Hi all, now if I've understood the code below correctly, if I add the
line;

$session_dean_id = $hResult('dean_id');

At the bottom I will create a new variable named '$session_dean_id'
which will have the value grabbed from the table 'iUser' from the
'dean_id' column. Am i right or way off?

Many thanks
$sQuery = "
Select iUser, dean_id
From tblUsers
Where sGUID = '$sGUID'";
$hResult = mysql_query($sQuery, $hDB);
if(!mysql_affected_rows($hDB)) {
// No match for guid
header('Location: ../login.php?refer='.urlencode($PHP_SELF.'?'.$HTTP_SE RVER_VARS['QUERY_STRING']));
}
Jul 17 '05 #1
3 1523
In article <86**************************@posting.google.com >,
ki*****@aol.com (none) wrote:
Hi all, now if I've understood the code below correctly, if I add the
line;

$session_dean_id = $hResult('dean_id');

At the bottom I will create a new variable named '$session_dean_id'
which will have the value grabbed from the table 'iUser' from the
'dean_id' column. Am i right or way off?

Many thanks
$sQuery = "
Select iUser, dean_id
From tblUsers
Where sGUID = '$sGUID'";
$hResult = mysql_query($sQuery, $hDB);
if(!mysql_affected_rows($hDB)) {
// No match for guid
header('Location:
../login.php?refer='.urlencode($PHP_SELF.'?'.$HTTP_SE RVER_VARS['QUERY_STRING']
));
}

No, it should be:

if (mysql_num_rows($hResult) == 0) {

// mysql_num_rows is for SELECT queries
// mysql_affected_rows for UPDATE, INSERT and DELETE queries

// no match for guid

} else {

list($iuser, $session_dean_id) = mysql_fetch_row($hResult);
}

JP

--
Sorry, <de*****@cauce.org> is een "spam trap".
E-mail adres is <jpk"at"akamail.com>, waarbij "at" = @.
Jul 17 '05 #2
Jan Pieter Kunst <de*****@cauce.org> wrote in message news:<de***************************@news1.news.xs4 all.nl>...
In article <86**************************@posting.google.com >,
ki*****@aol.com (none) wrote:
Hi all, now if I've understood the code below correctly, if I add the
line;

$session_dean_id = $hResult('dean_id');

At the bottom I will create a new variable named '$session_dean_id'
which will have the value grabbed from the table 'iUser' from the
'dean_id' column. Am i right or way off?

Many thanks
$sQuery = "
Select iUser, dean_id
From tblUsers
Where sGUID = '$sGUID'";
$hResult = mysql_query($sQuery, $hDB);
if(!mysql_affected_rows($hDB)) {
// No match for guid
header('Location:
../login.php?refer='.urlencode($PHP_SELF.'?'.$HTTP_SE RVER_VARS['QUERY_STRING']
));
}

No, it should be:

if (mysql_num_rows($hResult) == 0) {

// mysql_num_rows is for SELECT queries
// mysql_affected_rows for UPDATE, INSERT and DELETE queries

// no match for guid

} else {

list($iuser, $session_dean_id) = mysql_fetch_row($hResult);
}

JP

Right, i'm a little lost. The query code I grabbed from a login script
which checks if the user is logged in when accessing the page. I
wanted to get the 'dean_id' value at the same time this is happening
on each page by 'dean_id' to the query and creating a new variable
from it.

Are you saying then that the code I have used from an example I saw on
the net is wrong?

Many thanks.
Jul 17 '05 #3
In article <86**************************@posting.google.com >,
ki*****@aol.com (none) wrote:
Are you saying then that the code I have used from an example I saw on
the net is wrong?


What I'm saying is that in this code fragment:

$sQuery = "
Select iUser, dean_id
From tblUsers
Where sGUID = '$sGUID'";

$hResult = mysql_query($sQuery, $hDB);

if(!mysql_affected_rows($hDB)) {

}

mysql_affected_rows() is not used correctly. See
<http://nl.php.net/manual/en/function.mysql-affected-rows.php> for the
official word.

JP

--
Sorry, <de*****@cauce.org> is een "spam trap".
E-mail adres is <jpk"at"akamail.com>, waarbij "at" = @.
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Randell D. | last post by:
Folks, I have a table of addresses and a seperate table with contact names - All addresses tie to one or more names - I would like to keep track of the number of names 'belonging' to an address...
2
by: Megan | last post by:
Hi everybody- I have 2 tables, Hearings and Rulings. Both have primary keys called, CaseID, that are autonumbers. I don't want both tables to have the same autonumber. For example, if Hearings...
4
by: New Guy | last post by:
I'm trying to work with a system that somebody else built and I am confounded by the following problem: There is a table of payments and a table of charges. Each client has charges and payments...
5
by: Thelma Lubkin | last post by:
I have a form/subform with the common one-to-many relationship. The form allows user to display records and move to other records via the selector, to add,delete, and edit them, with the related...
1
by: kamleshsharmadts | last post by:
I am using Ajax with struts in web application. from jsp i am calling a function of ajax.js onclick of a button. code of that call function which calling from jsp given as below:- ...
33
by: JamesB | last post by:
I am writing a service that monitors when a particular app is started. Works, but I need to get the user who is currently logged in, and of course Environment.UserName returns the service logon...
12
by: magmike | last post by:
Accidentally deleted a record. Anyway to get it back? If not, I know the ID number - which is an autonumber field. Because of the related data from other tables, would I be able to create a new...
1
by: raghuvendra | last post by:
Hi I have a jsp page with 4 columns: namely Category name , Category order, Input field and a submit button. All these are aligned in a row. And Each Category Name has its corresponding Category...
9
Catalyst159
by: Catalyst159 | last post by:
I have a form which is used to calculate residential Floor Area Ratio (FAR). The form is structured into seven parts as follows: Part A: Maximum FAR and Floor Area: Part B: Gross Floor Area of...
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
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,...
0
jinu1996
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...
1
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...
0
agi2029
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.