473,789 Members | 2,781 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

delete from database

I have code that does not delete from a database. The same code (cut an
paste in the same file, but different function and having a different query)
works. So, of course, I tested the query interactively. I echoed the query
and did a cut and paste when interactively connect to the database. That
one worked so it isn't the query since interactively it is seeing exactly
the same thing as the code produces.

Here is the code:

function deleteCatalog($ catalog) {
$query = "DELETE FROM CatalogNames WHERE sCatalogID='" . $catalog . "'";
mssql_select_db ($database_Logi n, $_SESSION['Login']);
$result = mssql_query($qu ery, $Login);
...
}

The $query echos:
DELETE FROM CatalogNames WHERE sCatalogID='CMP '

As an example of code that works (in the same file)
function addToCatalog($c at_id, $cat_name) {
$query = "INSERT INTO CatalogNames (sCatalogID, sCatalogName) " .
"VALUES ('" . $cat_id . "', '" . $cat_name . "')";
mssql_select_db ($database_Logi n, $_SESSION['Login']);
$result = mssql_query($qu ery, $_SESSION['Login']);
...
}
The second and third lines are identical (cut and pasted) as in other places
in the same code. In fact, it is only in this file that I do all the
database work. Every other function works. This is the only delete,
however.

Any ideas?

Shelly
Mar 1 '06 #1
11 1730
Sheldon Glickler wrote:
I have code that does not delete from a database. The same code (cut an
paste in the same file, but different function and having a different query)
works. So, of course, I tested the query interactively. I echoed the query
and did a cut and paste when interactively connect to the database. That
one worked so it isn't the query since interactively it is seeing exactly
the same thing as the code produces. $result = mssql_query($qu ery, $Login);
$result = mssql_query($qu ery, $_SESSION['Login']);


Looking at the query function in your two functions gives this main
difference. As deleteCatalog() hasn't the variable $Login assigned any value,
it will be the same as Null which isn't a valid resource link definer, either
you change the function to use the following line
$result = mssql_query($qu ery);

or

$result = mssql_query($qu ery, $_SESSION['Login']);

//Aho
Mar 1 '06 #2

"J.O. Aho" <us**@example.n et> wrote in message
news:46******** ****@individual .net...
$result = mssql_query($qu ery, $Login);
$result = mssql_query($qu ery, $_SESSION['Login']);


Looking at the query function in your two functions gives this main
difference. As deleteCatalog() hasn't the variable $Login assigned any
value, it will be the same as Null which isn't a valid resource link
definer, either you change the function to use the following line


Cut and paste error when writing this orogonal post. Here is the latest and
greatest for the two and the results are still that the delete doesn't work
and the insert does.

$query = "DELETE FROM CatalogNames WHERE sCatalogID='" . $catalog . "'";
mssql_select_db ($database_Logi n, $_SESSION['Login']);
$result = mssql_query($qu ery, $_SESSION['Login']);
$query = "INSERT INTO CatalogNames (sCatalogID, sCatalogName) " .
"VALUES ('" . $cat_id . "', '" . $cat_name . "')";
mssql_select_db ($database_Logi n, $_SESSION['Login']);
$result = mssql_query($qu ery, $_SESSION['Login']);
Mar 1 '06 #3
Sheldon Glickler wrote:
"J.O. Aho" <us**@example.n et> wrote in message
news:46******** ****@individual .net...
$result = mssql_query($qu ery, $Login);
$result = mssql_query($qu ery, $_SESSION['Login']);

Looking at the query function in your two functions gives this main
difference. As deleteCatalog() hasn't the variable $Login assigned any
value, it will be the same as Null which isn't a valid resource link
definer, either you change the function to use the following line


Cut and paste error when writing this orogonal post. Here is the latest and
greatest for the two and the results are still that the delete doesn't work
and the insert does.


Okey, then lets look at the $_SESSION['Login'], how do you set it and do you
really store that in a session and reuse it? How do you make the mssql_connect() ?
//Aho
Mar 1 '06 #4
On Tue, 28 Feb 2006 21:06:58 -0500, Sheldon Glickler wrote:
I have code that does not delete from a database. The same code (cut an
paste in the same file, but different function and having a different query)
works. So, of course, I tested the query interactively. I echoed the query
and did a cut and paste when interactively connect to the database. That
one worked so it isn't the query since interactively it is seeing exactly
the same thing as the code produces.

Here is the code:

function deleteCatalog($ catalog) {
$query = "DELETE FROM CatalogNames WHERE sCatalogID='" . $catalog . "'";
mssql_select_db ($database_Logi n, $_SESSION['Login']);
$result = mssql_query($qu ery, $Login);
...
}

The $query echos:
DELETE FROM CatalogNames WHERE sCatalogID='CMP '

As an example of code that works (in the same file)
function addToCatalog($c at_id, $cat_name) {
$query = "INSERT INTO CatalogNames (sCatalogID, sCatalogName) " .
"VALUES ('" . $cat_id . "', '" . $cat_name . "')";
mssql_select_db ($database_Logi n, $_SESSION['Login']);
$result = mssql_query($qu ery, $_SESSION['Login']);
...
}
The second and third lines are identical (cut and pasted) as in other places
in the same code. In fact, it is only in this file that I do all the
database work. Every other function works. This is the only delete,
however.

Any ideas?

Shelly


Some error handling *might* shed some light onto the problem???

Mar 1 '06 #5
$query = "DELETE FROM CatalogNames WHERE sCatalogID='" . $catalog . "'";
mssql_select_db ($database_Logi n, $_SESSION['Login']);
$result = mssql_query($qu ery, $_SESSION['Login']);
$query = "INSERT INTO CatalogNames (sCatalogID, sCatalogName) " .
"VALUES ('" . $cat_id . "', '" . $cat_name . "')";
mssql_select_db ($database_Logi n, $_SESSION['Login']);
$result = mssql_query($qu ery, $_SESSION['Login']);


I think it unlikely that you can reliably cache and reuse a database
resource between sessions. You should create a new session with each
invocation of the script.

---
Steve

Mar 1 '06 #6

"J.O. Aho" <us**@example.n et> wrote in message
news:46******** ****@individual .net...
Sheldon Glickler wrote:
"J.O. Aho" <us**@example.n et> wrote in message
news:46******** ****@individual .net...
$result = mssql_query($qu ery, $Login);
$result = mssql_query($qu ery, $_SESSION['Login']);
Looking at the query function in your two functions gives this main
difference. As deleteCatalog() hasn't the variable $Login assigned any
value, it will be the same as Null which isn't a valid resource link
definer, either you change the function to use the following line


Cut and paste error when writing this orogonal post. Here is the latest
and greatest for the two and the results are still that the delete
doesn't work and the insert does.


Okey, then lets look at the $_SESSION['Login'], how do you set it and do
you really store that in a session and reuse it? How do you make the
mssql_connect() ?


Yes, I do store it and it is there. It worked for all the others.

$hostname_Login = "localhost" ;
$database_Login = "the database name";
$username_Login = "the username";
$password_Login = "the password";
$apbLogin = mssql_pconnect( $hostname_Login , $username_Login ,
$password_Login ) or die(mysql_error ());


Mar 1 '06 #7

"Steve" <Th*****@Aint.V alid> wrote in message
news:pa******** *************** *****@Aint.Vali d...
On Tue, 28 Feb 2006 21:06:58 -0500, Sheldon Glickler wrote:
I have code that does not delete from a database. The same code (cut an
paste in the same file, but different function and having a different
query)
works. So, of course, I tested the query interactively. I echoed the
query
and did a cut and paste when interactively connect to the database. That
one worked so it isn't the query since interactively it is seeing exactly
the same thing as the code produces.

Here is the code:

function deleteCatalog($ catalog) {
$query = "DELETE FROM CatalogNames WHERE sCatalogID='" . $catalog .
"'";
mssql_select_db ($database_Logi n, $_SESSION['Login']);
$result = mssql_query($qu ery, $Login);
...
}

The $query echos:
DELETE FROM CatalogNames WHERE sCatalogID='CMP '

As an example of code that works (in the same file)
function addToCatalog($c at_id, $cat_name) {
$query = "INSERT INTO CatalogNames (sCatalogID, sCatalogName) " .
"VALUES ('" . $cat_id . "', '" . $cat_name . "')";
mssql_select_db ($database_Logi n, $_SESSION['Login']);
$result = mssql_query($qu ery, $_SESSION['Login']);
...
}
The second and third lines are identical (cut and pasted) as in other
places
in the same code. In fact, it is only in this file that I do all the
database work. Every other function works. This is the only delete,
however.

Any ideas?

Shelly


Some error handling *might* shed some light onto the problem???


I have an

if (!$result)
print the error including the query

That is how I got the query that I copied and used interactively
successfully. Everything before that looked fine.
Mar 1 '06 #8

"Steve" <go*********@na stysoft.com> wrote in message
news:11******** **************@ z34g2000cwc.goo glegroups.com.. .
$query = "DELETE FROM CatalogNames WHERE sCatalogID='" . $catalog .
"'";
mssql_select_db ($database_Logi n, $_SESSION['Login']);
$result = mssql_query($qu ery, $_SESSION['Login']);
$query = "INSERT INTO CatalogNames (sCatalogID, sCatalogName) " .
"VALUES ('" . $cat_id . "', '" . $cat_name . "')";
mssql_select_db ($database_Logi n, $_SESSION['Login']);
$result = mssql_query($qu ery, $_SESSION['Login']);


I think it unlikely that you can reliably cache and reuse a database
resource between sessions. You should create a new session with each
invocation of the script.


This is one session where it works on one and fails on the other. I use a
mssql_pconnect, but I will try making a new connection.
Mar 1 '06 #9

"Sheldon Glickler" <sh*******@bell south.net> wrote in message
news:tO******** **********@bign ews7.bellsouth. net...
$hostname_Login = "localhost" ;
$database_Login = "the database name";
$username_Login = "the username";
$password_Login = "the password";
$apbLogin = mssql_pconnect( $hostname_Login , $username_Login ,
$password_Login ) or die(mysql_error ());
cut and paste error. make that $Login = mssql_pconnect( $hostname_Login , $username_Login ,


I thought I changed removed all the apb's for the posting. Missed one The
original has it all there. I just wanted to make it as neutral as possible
for posting.
Mar 1 '06 #10

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

Similar topics

1
8906
by: Andrew DeFaria | last post by:
I created the following .sql file to demonstrate a problem I'm having. According to the manual: If |ON DELETE CASCADE| is specified, and a row in the parent table is deleted, then InnoDB automatically deletes also all those rows in the child table whose foreign key values are equal to the referenced key value in the parent row. However:
2
11802
by: Bob Ganger | last post by:
Hello, I am working on a project using SQL Server 2000 with a database containing about 10 related tables with a lot of columns containing text. The total current size of the database is about 2 Gig. When I delete data from the database, it takes a lot of system resources and monopolizes the database so that all other query requests are slow as mud! Ideally, I would like to be able to issue delete commands to the database on a...
7
1727
by: Mike & Dyan | last post by:
I was able to figure out how to insert new data into my database. But for some reason and a lot of reading I can't seem to figure out how to delete any data. My app is going to be used for tracking info on vehicles. My app is MDI with 3 children. 1 is for selecting a car(already in the database) and input info.Then you can add that car and info to the database. Another is used for just adding or deleting a car to the database. The 3rd...
9
10667
by: Robert Schneider | last post by:
Hi to all, I don't understand that: I try to delete a record via JDBC. But I always get the error SQL7008 with the error code 3. It seems that this has something to do with journaling, since the table from which I want to delete has two foreign keys that references two other tables and it is also referenced by another table. But this shouldn't be a problem, since I set the commit mode to none (or *none) at all places where this makes...
3
2102
by: John Rivers | last post by:
Hello, I think this will apply to alot of web applications: users want the ability to delete a record in table x this record is related to records in other tables and those to others in other tables etc. in other words we must use cascade delete to do
13
2870
by: forbes | last post by:
Hi, I have a user that used the Query Wizard to create a query in Access. Now she claims that her master table is missing all the data that was excluded from the query. Can you create anything other than a select query using the Wizard? What do you think happened to her data? I am working remotely until Friday, so I can't get down to her office and check out what she did.
6
3859
by: polocar | last post by:
Hi, I'm writing a program in Visual C# 2005 Professional Edition. This program connects to a SQL Server 2005 database called "Generations" (in which there is only one table, called "Generations"), and it allows the user to add, edit and delete the various records of the table. "Generations" table has the following fields: "IDPerson", NamePerson", "AgePerson" and "IDParent". A record contains the information about a person (his name, his...
3
3428
by: bluez | last post by:
I want to design a webpage where user can search the data from the database and list out the related records. Each of the record got a delete button which allow user to delete the record. Filename : search_student.php <?php include("../user_access/user_access_control.php"); include("../Database/database.php"); $searchStudentControl = new Access_user;
36
5112
by: pearl146 | last post by:
Hi, I have some database files (.MDF, .LDF,...) on the server. When I try to delete them, the warning "Cannot delete file: There has been a sharing violation. The source or destination file may be in use." appears. Since I am new to the environment I don't know where the files come from and where they might be used.
10
2066
by: pythonnoob | last post by:
Hello everyone. New to python as well as this forum, but i must say ive learned a but already reading through some posts. Seems to be a pretty helpful community here. Before i post a question ill give you a little background. I have done programming in the past in Basic, VB, and a little C. I am not much of a programmer, its more of a hobby/curiosity. The following code is not mine, i am trying to modify a template of a mock database....
0
9666
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10408
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10199
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 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...
1
10139
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,...
0
9983
tracyyun
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...
1
7529
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 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...
0
6769
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();...
2
3700
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.