Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Delete From Many Tables


I am trying to delete rows from a mySQL DB that consists of multiple tables. I am trying to use a function PHP Code:




View Complete Forum Thread with Replies

Related Forum Messages:
MySQL - Delete Across Two Tables. OT
i cant find the MySQL newsgroup, however i am
hoping to pick up on some expert advice from php/mysql gurus here. I'm
having some trouble performing a delete across two tables.

The tables i have are:

questionnaires (id, name);

questionnaire_questions (questionnaires_id, id, name, qf_type)

The questionnaire_questions table contains a list of questions for a
specific questionnaire (indicated by the questonnaires_id). I would
like to remove a questionnaire, and when doing so all corresponding
questionnaire_questions who have matching id's (questionnaires.id =
questionnaire_questions.questionnaires_id).

I have this statement, however it only works if a questionnaire has
questions... however i would like it to delete even if no questions
exist for that specific questionnaire. The SQL i am using is:

delete questionnaires, questionnaire_questions FROM questionnaires,
questionnaire_questions WHERE questionnaires.id =
questionnaire_questions.questionnaires_id AND questionnaires.id =
THE_QUESTIONAIRE_TO_DELETE_ID

View Replies !
Want To DELETE Row FROM Multiple Tables
I'm looking to delete a single row from multiple tables where they all share a common column name, primaryKey, and a common value - $POST_[primaryKey]. Here is the code:

$query="DELETE FROM assetinfo, emplhistory, income, newuser, preliminfo, primarydata, reoinfo, residencehistory WHERE primaryKey='$_POST[primaryKey]'";
            
            $result=mysqli_query($connection, $query) or die (mysqli_error($connection). "                                 <br> Could't run DB Query to Delete Borrower");

And here is the error msg I'm getting:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE primaryKey='jarreola2'' at line 1
Could't run DB Query to Delete Borrower

Is my query valid? Any other ideas on how to delete a row from multiple tables?

View Replies !
Delete From 2 Tables (join)
How are we all doing this fine day

small problem "man do i hate joins"

I have two tables "categories" and "links"

Links carry the cid field from categories.

PHP Code:

View Replies !
Code Loop Through The Array And Delete Everything From Each Of The Tables
Will this code loop through the array and delete everything from each of the tables for a particular user. PHP Code:

$tables = array (
"user",
"user_info",
"foo",
"bar"
);
foreach ($tables as $value) {
DELETE * FROM $value WHERE user=$username
echo 'user deleted from '.$value;
}

Also is there a better way to delete all user info across multiple tables? This seems as if it could be quite inefficient.

View Replies !
Script To Read/write/amend/delete On The Tables In A Mysql Db
Running on a unix box and looking for a good (free!) php script I can use to read/write/amend/delete on the tables in a mysql db. Been searching for a while but can seem to find one with a good web front end to use.

View Replies !
Delete Record - When The Delete Link Is Clicked The Next Page Is Blank And Nothing Is Deleted.
This is my "delete.php" and this "todo/delete.php?id=64" an example of a link to it generated from the index.php page. When the delete link is clicked the next page is blank and nothing is deleted. What have I done wrong?

<?
include("dbinfo.inc.php");

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$id="delete from todo where id='$id'";
mysql_query($id);

mysql_close();
?>

View Replies !
Mysql Delete - $query = Mysql_query("DELETE
how would i do the following ?

$query = mysql_query("DELETE notes, datestamp, abs_value, ID FROM absence_mgt  WHERE datestamp='$date' AND ID='$vtc_login' ") or die(mysql_error());
im just getting "Unknown table 'notes' in MULTI DELETE" ?

View Replies !
Generating Multiple Alternating Columns And/or Tables Within Tables
I am having a little bit of trouble generating the code for a table with 2 columns. The columns contain tables within themselves. Not sure why as that part was an existing design. Here is the output so far and it is correct but not how i want it to be (i'll explain) Code:

View Replies !
MySQL 'SHOW TABLES' Doesn't Show Temporary Tables?
I have a function call which creates a temporary table in MySQL, and then a second function call which operates on that temporary table.

I was hoping to do something like this in the second function call to ensure that the table was in fact actually created:

if (mysql_num_rows(mysql_query("SHOW TABLES LIKE 'my temp table name'")))
// do something
else
//error

However, apparently the MySQL SHOW TABLES statement doesn't show temporary tables. Is there another query that I can use to show temporary MySQL tables so I can do this check?

View Replies !
Delete From $var
Is it not possilbe to have a variable for the table name in a delete statement (mysql database). inside an if this button is hit statement I have:

$sql = "delete from $type where id_num='$number'";
mysql_query($sql);
echo "$sql";

when it echos $sql it doesnt have the $type var where the table name should be, it just leaves that blank.

View Replies !
Delete A Row
This should be simple enough but for some reason it's not working. The $name is a number which is being posted across when the user clicks submit. I want the PHP to then access the Database with this number and use it to delete the staff ID (which is a PK).

With this code I get the error:

Warning: ociparse(): supplied argument is not a valid OCI8-Connection resource in /homedir/ilex-s01/jmsuther/public_html/DeleteStaff.php on line 16

Warning: ociexecute(): supplied argument is not a valid OCI8-Statement resource in /homedir/ilex-s01/jmsuther/public_html/DeleteStaff.php on line 17
;

The code is:

$name = $_POST["staffnodelete"];
IF ($staffnodelete=="" )
{print "You selected $name - for deletion ";}

putenv("TNS_ADMIN=/u1/oracle/Products/shu10g/network/admin");
$con = OCILogon("username","password","10g");

$query = "DELETE FROM staff WHERE staffno = $name";
$query = $query_post [$name];
$stmt = ociparse($conn, $query);
ociexecute ($stmt);

View Replies !
How To Delete
how to delete mysql row at php with checkbox?

View Replies !
Not Able To Delete
I've written a script to display all records in a database table and allow the user to select a record for deletion by entering it's ID number into a form at the bottom of the page.

When they click on the Submit button, it refreshes the page & shows the entire record that they selected and it asks if they're sure that they want to delete it.

There's 2 radio buttons that that allow them to select either "Yes" or "No". Everything is working fine up to that point. Where I run into problems is that no matter whether they choose yes or no, the record does not get deleted.

View Replies !
Delete Row
I am having a little problem with the following row to delete a row from my table. This script works fine on my home testing server but as soon as I put it onto my main web server it does not work and gives me an SQL syntax error. PHP Code:

mysql_select_db($database, $connect);
$sql = "DELETE FROM prices WHERE id=$id";
mysql_query($sql) or die(mysql_error());

View Replies !
Row Delete
what i am trying to do is delete all rows except for the last 20 rows, anyone know how this can be done?

basically i am keeping track of profile views so i know what members lasts seen who... my questin is how do i delete all but that last 2o for each $Member?

View Replies !
Delete
In one part of a review site i am making it allows top level users to make reviews witch includes uploading a picture and then changing the name to [name of review].[whatever], also it allows people to edit the review and change the picture, how exactly would i go about getting rid of the old picture so that i dont have to do hours of clean up.

View Replies !
Delete From Dir....
I have a field named 'path' in my db that has the exact same number(path) as its counterpart folder under cart/zips.

So my path in my db might be &#65533;', and in cart/zips you'd have the folder 23423423. There is a corresponding session with each 'path' row. Based on the session, I want to retrieve the path name and delete its counterpart folder name (and all it's sub-files it may contain).

The delete_all_from_dir function below is deleting the whole zips folder when I only want it to delete the path folder below it and its contents. Code:

View Replies !
How To Delete Fields
I would delete with php, all record of a table mysql where the seven left chars of the field is equal to the data in input($seven_chars).

I have used the the belowe istrucrion but it do not work.how can I do?

mysql_query ("DELETE FROM my_table WHERE substr(myfield,0,7)=$seven_chars");

View Replies !
Delete A Line In PHP
What i want to do is to open a file read the file Select a particular line from the file and delete that line and close the file. How to do it in PHP.

View Replies !
Can't Delete Cookie
Right I am quite new to php but have managed to create a simple log in/log out thing with cookies. All was working fine and as expected until I added a new section of the site. The new section stores another cookie (latest message user has read) so that next time they visit the site it will highlight the 'new' messages.
However since adding this I can no longer log out.

View Replies !
Can't Delete Cookie, Help Please~
Page1: <? setcookie("book_id", $book_id ); ?>

Page2: <? setcookie ("book_id", $book_id, time() - 3600); ?>

Can't delete cookie at once but reload page 2 two times
how to delete $book_id cookie without reload?

View Replies !
Cookie Won't Delete
I'm trying to setup a simple user authenication for my site. I'm using cookies to pass the credentials between pages. But the function header() is giving me problems logging in and logging out. As you can see in the code below, I try to redirect the user to a page after setting or deleting the cookies. The scripts redirect okay, but the user never logs in and never logs out correctly. The scripts works correctly (logging in & logging out) only if I comment out the header() function.

Here's my code for setting the cookie (login.php):

View Replies !
Delete All Replicated Except One
I ran PHP codes that creating tables and inserting records to tables., But something happened, someone of them is inserted more than once.

aa1345 | Ninsonoto
aa1345 | Ninsonoto
aa1348 | Ayumi Tohina
aa1348 | Ayumi Tohina
aa1348 | Ayumi Tohina

There are thousands of records there. So I think i have to write a script that able to delete all the replicated except one..
e.g : Delete four of aa1348 records.

View Replies !
Delete New Lines
I would like to delete the new lines, I mean the, so Itried this:
str_replace($row['facts_conten t'], &quot;
&quot;, &quot;&quot;) ;
But the new lines are still there, how can I do?

View Replies !
Can't Delete From Table!
I'm not to familiar to php and sql. I have this assignment to read from database in a table and I HAVE TO be able to push a button causing one costumer to vanish. something to do with id = $id... can anyone help me... and help me fast!

This is my code:

View Replies !
What Is The Best Way To Delete File ...?
I have script that allows a user to upload a txt file for processing, filtering, to save bandwidth,instead of user reuploading the file everytime he/she does a new process on the same file, i save the file to the server, and process from that file. What I want to be able to do is, when the user uploads a new file, or leaves the site, this temp file is automatically deleted (saves disk space).

View Replies !
SQL Insert And Delete?
Anyone know if there's a way to call a query but remove whatever you grabbed from the database, or would I have to do a query to retrieve what i needed, then follow it up with a delete on the same query results?

View Replies !
Delete An Object ?
I use OOP with PHP4 and i don't understand something.

I have 2 classes VISIT & PLANNING like that:

class clVISIT {
var $when;
var $where;

//constructor
function clVISIT($_when,$_where) {
$this->when = $_when;
$this->where = $_where;
}
}

class clPLANNING {
var $who;
var $visit = array();

//constructor
function ClPLANNING($_who) {
$this->who = $_who;
for ($i=0;$i<10;$i++) { $visit = new clVISIT("foo".$i , "foobar".$i ) ; }
}

}

Ok, in the last constructor, we can see that i create new clVISIT
object. My question is: how can i delete some of them in the same
constructor ? is there a word like "new" but to delete ?

View Replies !
Delete Script
PHP and MySQL and I'm having some problems getting
this script to work. I can't get this to work and I don't understand
why. I don't get an error or anything, it almost seems like the page
refreshes. I went to the phpmyadmin and the row is still in the
database. The $_GET parts work perfectly in another script and the SQL
statement works when I insert hard values in it. Any thoughts would be
greatly appreciated. Thanks in advance.

<form method="POST" action="<?php print $_SERVER['PHP_SELF']; ?>">
<table>

<tr><td colspan="2" align="center">Yes <?php
input_radiocheck('radio','yes_no', $defaults, 'yes'); ?No <?php
input_radiocheck('radio','yes_no', $defaults, 'no'); ?>
</td></tr>

<tr><td colspan="2" align="center"><?php input_submit('save','Add'); ?>
</td></tr>

</table>
<input type="hidden" name="_submit_check" value="1"/>
</form>

<?php

function process_form() {

// Access the global variable $db inside this function
global $db;

$isbn = $_GET['isbn'];
$artist_name = $_GET['artist_name'];
$album_title = $_GET['album_title'];

if ($_POST['yes_no'] == 'yes') {

$delete_sql = "DELETE FROM lounge WHERE isbn = $isbn AND artist_name =
'$artist_name' AND album_title = '$album_title'";
// Delete the record
$db->query($delete_sql);
print "The record was deleted";
} else {
print "The record was not deleted";
}
}

?>

View Replies !
Delete File();
I was wondering if php4 has a built in function that could delete a file. In my case I need my php to delete a picture. (jpg, gif) Does php4 have the ability to delete an exsiting file? Something like this?? delete_image("../images/somePic.jpg");

View Replies !
Delete A File
How do i delete a file from my server with php?

View Replies !
Delete Not Working
Can someone tell me why this delete isn't working:

$strSQL = "DELETE FROM tblMine";

$rsEmpty = mysql_query($strSQL);

I just can't get it work.

View Replies !
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_Login, $_SESSION['Login']);
$result = mssql_query($query, $Login);
...
}

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

As an example of code that works (in the same file)
function addToCatalog($cat_id, $cat_name) {
$query = "INSERT INTO CatalogNames (sCatalogID, sCatalogName) " .
"VALUES ('" . $cat_id . "', '" . $cat_name . "')";
mssql_select_db($database_Login, $_SESSION['Login']);
$result = mssql_query($query, $_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.

View Replies !
Delete From Array
let's say I have an array $letters(a,b,c,d,e,f) is there a function that will remove 'd' from the middle. I'm looking for something like array_delete($letters,'d');

View Replies !
Confirm Delete
The below code updates information in a table. I'm trying to add some type of validation to confirm that the user wants to continue with the update. The javascript is not doing what I want it to it makes the page white then I get a header error. Code:

View Replies !
Records Won't Delete
mysql_query("DELETE FROM guestbook WHERE id = '$recnum'"); It works fine on my local server but it doesn't delete records on the remote server. any ideas?

View Replies !
Trying To Delete Rows.
I am trying to use php to delete rows for a mysql database table, i am using the following code with $journeyIDToUse being a number that represents a automaticly incrementing primary key.

$toDelete = "DELETE FROM journeyData WHERE journeyID='$journeyIDToUse'";
mysql_query($toDelete);

This fails to delete the row. I have tried changing $journeyIDToUse to a number and that worked so i thought that the variable might be at fault but the following query works so that rules that out

$searchString = "SELECT * FROM journeyData WHERE journeyID='$journeyIDToUse'";
$result = mysql_query($searchString);
$row = mysql_fetch_array($result);

View Replies !
Delete Query
Here’s what I’m trying to do:

- Output the last 60 results in my db - works
- Delete a record – does not work

Can anyone see why my delete query won’t work?

It seems to have two problems:

1)   It does not delete a record
2)   The header re-direct says can’t modify header information Code:

View Replies !
Delete Old Timestamp
I want to delete all timstamp entried older than 2 days.

This fails to delete do anything and there is no error.
The field name is date and table name is logbook

$sql="Delete from logbook where TIMESTAMPDIFF(DAY, 'date', NOW()) > 2 " ;

View Replies !
Delete Specific Row Out Of 3
Say i have three rows:

row1
row2
row3

How do i make a mysql query to delete a specific row out of the 3 only? So say i wanted to delete row2 from the 3.. ?

View Replies !
Can't Delete Cookies
For some strange reason I can't seem to delete cookies.  First it kept adding a new cookie a dot in front of the host when I set an already existing one with a negative expiry but now nothing happens at all.

The code I'm using (with the domain changed) is:

setcookie( "member_id", "4", time()-3600, "/", "www.mysite.net" );

The cookie remains unchanged and I have no idea why.  The name, value, path, and host are correct but I still get nothing.  I also tried:

setcookie( "member_id", "", time()-3600);

Again to no avail.  It doesn't work on IE or FF.

PHP version is   4.4.7
OS is Linux
No error messages are displayed

View Replies !
Delete Folder FTP
I am trying to delete a folder and all of its contents (folders, files) through ftp. I am trying to modify a script for deleting it locally. I don't get any errors with this, but nothing happens. Can someone point me in the right direction? Code:

View Replies !
Delete From Table
I get this error not sure what's wrong?

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'VALUES ('mortalsombat@hotmail.com')' at line 3 Code:

View Replies !
Delete File
How do I delete a file with PHP?

View Replies !
Delete And Refresh
I have this code that I am using to delete records from the database. It is deleting the records alright but the display out put is not reflected immediately after clicking to the delete button. I have to refresh the page or click on the button again for the record to disappear. Code:

View Replies !
Delete File With Php
Im a little new in php, and just made a site where u can upload pictures, but how can i make it possible to delete pictures as well.

View Replies !
Delete After A Priod
i want to delete the users which hasn't activate their accounts , i send them through e-mail the activation link , if they do not click the link for example for 10 days, then their information in database will be deleted. how can i apply that ? (for the time they've signed up i've used mysql "now()" function)

View Replies !
Delete Record
i have this code for my site that will connect to my database and grab all my members there id email and ip the problem is that it dont have a button where you can select a member and delete that member can anyone help me with this?i want to add a button and a check box so if i check off a member and click a delete button it will delete that member here is the code:

View Replies !
Auto Delete
This script was meant to delete a file after X days...in this case I wanted it to delete files that were older than 1 day except .htaccess. what the script is doing is deleting everything in the specified folders except htaccess even though the files are less than a day old. any suggestions? Code:

View Replies !
Delete Image
I have a folder on the server which contains images. I like to delete the images which only thier name start with "wc_106" the file name might look like ( wc_106_xxxxxx.jpg , wc_106_yyyyy.jpg , wv_dddd.jpg ), but I only want to delete the ones having a prefix "wc_106".

View Replies !
Delete Question
I know this is going to sound dumb but I need to know how to do a delete by date

I am using date type Y-m-d 0000-00-00

I want to delete all from tabe anything 6 months or older
But I also need to use it as a varible like: Code:

View Replies !
How Do I Delete A Folder?
I want to delete a folder on the server using php code. I can only find the code to delete files from the server and not the folder with files. I searched Google and php.com but all I get is:

#$myFile = "filetodlete";
#unlink($myFile);

---------------------------------

#$myFile = "filetodelete";
#ftp_delete($myFile);

Is there something I can change or a other code I can use to delete folders?

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved