472,952 Members | 2,116 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,952 software developers and data experts.

"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 2844
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
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
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
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
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
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
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
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
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
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
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.