473,480 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

"select" query dies, not sure why

$sql = 'INSERT INTO fs_usermetadata (' . substr(trim($cols), 0,
strrpos(trim($cols), ',')) .
') VALUES (' . substr(trim($values), 0, strrpos(trim($values),
',')) . ')';

if (!mysql_query($sql)) {
$hasSubmittedUser = 0;
$errorMsg .= $font . '<font color=cc0000><li>Could not insert record
into db</li></font>' .
'</font><p>';
}

if ($hasSubmittedUser) {
// THIS BLOCK WILL ENSURE THAT THE ID WILL BE PASSED AND ALL DATA
GATHERED FOR EDITING
// OF RECENTLY SUBMITTED INFORMATION
$willEditUser = 1;
$sql = 'SELECT fs_userid FROM fs_usermetadata ' .
'WHERE fs_username = \'' . $fs_username . '\' ' .
' AND fs_password = \'' . $fs_password . '\' ';
$query = mysql_query($sql) or die('Could not run updated data select
query: ' . $sql);
while ($row = mysql_fetch_array($query, MYSQL_ASSOC)) $id =
$row["fs_userid"];
}

On occasions the "select" query will die for no apparent reason. The
"insert statement" is nullified and not done either. However, upon the user
hitting the back browser button and resubmitting both work fine and then
continue to work fine for an indeterminate amount of time.

Perhaps I'm missing something here: what I'm trying to do is insert a new
record and immediately obtain the id column field value from the new record.

Thanks
Phil
Jul 16 '05 #1
3 2872
In article <9z91b.4614$xf.592@lakeread04>, Phil Powell
<so*****@erols.com> wrote:
$sql = 'INSERT INTO fs_usermetadata (' . substr(trim($cols), 0,
strrpos(trim($cols), ',')) .
') VALUES (' . substr(trim($values), 0, strrpos(trim($values),
',')) . ')';

if (!mysql_query($sql)) {
$hasSubmittedUser = 0;
$errorMsg .= $font . '<font color=cc0000><li>Could not insert record
into db</li></font>' .
'</font><p>';
}

if ($hasSubmittedUser) {
// THIS BLOCK WILL ENSURE THAT THE ID WILL BE PASSED AND ALL DATA
GATHERED FOR EDITING
// OF RECENTLY SUBMITTED INFORMATION
$willEditUser = 1;
$sql = 'SELECT fs_userid FROM fs_usermetadata ' .
'WHERE fs_username = \'' . $fs_username . '\' ' .
' AND fs_password = \'' . $fs_password . '\' ';
$query = mysql_query($sql) or die('Could not run updated data select
query: ' . $sql);
while ($row = mysql_fetch_array($query, MYSQL_ASSOC)) $id =
$row["fs_userid"];
}

On occasions the "select" query will die for no apparent reason. The
"insert statement" is nullified and not done either. However, upon the user
hitting the back browser button and resubmitting both work fine and then
continue to work fine for an indeterminate amount of time.

Perhaps I'm missing something here: what I'm trying to do is insert a new
record and immediately obtain the id column field value from the new record.

Thanks
Phil

What kind of error handling are you doing? You aren't using
Dreamweaver are u?
Jul 16 '05 #2
No this is all freehand, cannot afford Dreamweaver.. error handling is a bit
dodgy since it's not set up on the hosting service other than what you throw
in your die() statements and mysql_error().

Phil

"E-Star" <un*******@linuxmail.org> wrote in message
news:210820031419197203%un*******@linuxmail.org...
In article <9z91b.4614$xf.592@lakeread04>, Phil Powell
<so*****@erols.com> wrote:
$sql = 'INSERT INTO fs_usermetadata (' . substr(trim($cols), 0,
strrpos(trim($cols), ',')) .
') VALUES (' . substr(trim($values), 0, strrpos(trim($values),
',')) . ')';

if (!mysql_query($sql)) {
$hasSubmittedUser = 0;
$errorMsg .= $font . '<font color=cc0000><li>Could not insert record into db</li></font>' .
'</font><p>';
}

if ($hasSubmittedUser) {
// THIS BLOCK WILL ENSURE THAT THE ID WILL BE PASSED AND ALL DATA
GATHERED FOR EDITING
// OF RECENTLY SUBMITTED INFORMATION
$willEditUser = 1;
$sql = 'SELECT fs_userid FROM fs_usermetadata ' .
'WHERE fs_username = \'' . $fs_username . '\' ' .
' AND fs_password = \'' . $fs_password . '\' ';
$query = mysql_query($sql) or die('Could not run updated data select
query: ' . $sql);
while ($row = mysql_fetch_array($query, MYSQL_ASSOC)) $id =
$row["fs_userid"];
}

On occasions the "select" query will die for no apparent reason. The
"insert statement" is nullified and not done either. However, upon the user hitting the back browser button and resubmitting both work fine and then
continue to work fine for an indeterminate amount of time.

Perhaps I'm missing something here: what I'm trying to do is insert a new record and immediately obtain the id column field value from the new record.
Thanks
Phil

What kind of error handling are you doing? You aren't using
Dreamweaver are u?

Jul 16 '05 #3
I refined the code to the following:

$sql = 'INSERT INTO fs_usermetadata (' . substr(trim($cols), 0,
strrpos(trim($cols), ',')) .
') VALUES (' . substr(trim($values), 0, strrpos(trim($values),
',')) . ')';

if (!mysql_query($sql)) {
$hasSubmittedUser = 0;
$errorMsg .= $font . '<font color=cc0000><li>Could not insert record
into db: ' .
mysql_error() . '</li></font></font><p>';
} else {
$willEditUser = 1; // BE SURE TO SWITCH MODE TO EDIT UPON SUCCESSFUL
INSERT TO EDIT NEW USER
$id = mysql_insert_id(); // OBTAIN ID IMMEDIATELY AFTER INSERT QUERY
$tableHTML .= "\n<p>${font}<font color=000099>New User: <b>" .
$fs_user_firstname .
' ' . $fs_user_lastname . '</b> added to the
database</font></font><p>';
}

So far everything seems stable.

Phil
"E-Star" <un*******@linuxmail.org> wrote in message
news:210820031419197203%un*******@linuxmail.org...
In article <9z91b.4614$xf.592@lakeread04>, Phil Powell
<so*****@erols.com> wrote:
$sql = 'INSERT INTO fs_usermetadata (' . substr(trim($cols), 0,
strrpos(trim($cols), ',')) .
') VALUES (' . substr(trim($values), 0, strrpos(trim($values),
',')) . ')';

if (!mysql_query($sql)) {
$hasSubmittedUser = 0;
$errorMsg .= $font . '<font color=cc0000><li>Could not insert record into db</li></font>' .
'</font><p>';
}

if ($hasSubmittedUser) {
// THIS BLOCK WILL ENSURE THAT THE ID WILL BE PASSED AND ALL DATA
GATHERED FOR EDITING
// OF RECENTLY SUBMITTED INFORMATION
$willEditUser = 1;
$sql = 'SELECT fs_userid FROM fs_usermetadata ' .
'WHERE fs_username = \'' . $fs_username . '\' ' .
' AND fs_password = \'' . $fs_password . '\' ';
$query = mysql_query($sql) or die('Could not run updated data select
query: ' . $sql);
while ($row = mysql_fetch_array($query, MYSQL_ASSOC)) $id =
$row["fs_userid"];
}

On occasions the "select" query will die for no apparent reason. The
"insert statement" is nullified and not done either. However, upon the user hitting the back browser button and resubmitting both work fine and then
continue to work fine for an indeterminate amount of time.

Perhaps I'm missing something here: what I'm trying to do is insert a new record and immediately obtain the id column field value from the new record.
Thanks
Phil

What kind of error handling are you doing? You aren't using
Dreamweaver are u?

Jul 16 '05 #4

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

Similar topics

23
5638
by: ian justice | last post by:
Before i post actual code, as i need a speedyish reply. Can i first ask if anyone knows off the top of their head, if there is a likely obvious cause to the following problem. For the moment i've...
2
3373
by: Vic Spainhower | last post by:
Hello, I am new to php and MySQL and I'm attempting to run a select query on a MySQL database which is working fine except prior to displaying the table with the results from the select query it...
16
2458
by: lkrubner | last post by:
Are there any benchmarks on how much an extra, unneeded VARCHAR, CHAR, INT, BIGINT, TEXT or MEDIUMTEXT slows down a database call with MySql? PostGre info would also be useful. I'm trying to...
4
12483
by: Nuno | last post by:
Is there any SQL Error? Or I have to use Select case in VB code to control SQL instead. Thank you for any ans. Nuno
1
4148
by: Andrew McNab | last post by:
Hi folks, I have a problem with an MS Access SQL query which is being used in an Access Report, and am wondering if anyone can help. Basically, my query (shown below) gets some records from a...
1
8589
by: Mr.KisS | last post by:
Hi, In my aspx page i use a stocked procedure and in this procedure, there is a SELECT query. And whene the aspx page calls the procedure i get this exception : ...
5
2540
by: Henning M | last post by:
Hi all, I having some problems with Access and selecting records between dates.. When I try this in access, it works fine!! "Select * from Bilag Where Mdates Between #1/1/2006# And...
4
2313
by: saniac | last post by:
I am working on a little project using pysqlite. It's going to be exposed on the web, so I want to make sure I quote all incoming data correctly. However, I've run into a brick wall trying to use...
6
2072
by: jhaxo | last post by:
I am maintaining an asp page that builds a select query as a plain old string and executes it using oracle odbc. There is basically too much code to change over to stored proccedures or other nice...
0
7037
marktang
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,...
0
7034
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
5324
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,...
1
4768
isladogs
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...
0
4472
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
2990
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...
0
2976
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1294
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 ...
1
558
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.