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




Deleting A Record From Another Table


I would like my code to delete the relevant confirm_code from the temp_users table but I'm getting the error

Your account has been activatedYou 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 confirm_code = '5f6feb0f5d104c2a6b7ce24d40711f74'' at line 1

My code:




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Deleting A Record.
One last (hopefullly) problem I can't seem to get around for this
program...why isn't this deleting the row i want? It does nothing. Now error
messages either. HELP!

$link = mysql_connect("localhost");
if(! $link)
die("Could not connect to MySQL");

$database = "PC_Store";
mysql_select_db($database)
or die ("could not open $database: ".mysql_error() );

$result = mysql_query("DELETE FROM inventorydata VALUES('$ProductID')");

The $ProductID variable is brought in from a menu choice on a diffrent page,
it is also the primary of the table...so it should delete the whole row
right?

Deleting Record From Mysql
I am just tring to delete on record based on a link generated. The link shows up, the number of the field is shown as deleted when the link is clicked, but the entry ios still in the db. Maybe a problem with how I have the db setup? I only have one field, add_manufacturers, and it is text. It is in a table called manufacturers. Code:

Safely Deleting A Db Record With Php
I hope I'm not OT.

I have the following issue:
I want to delete a record from my db with a php script. Let's say I'm auth'd
and I want to delete the record id 440. With a simple form (get or post), I
send the id to my script and delete the record (DELETE FROM table WHERE
id=some_validated_input).

The problem is if I'm a nasty guy I just write my own form and delete any
record I want (since I'm auth'd) by just sending another id.

Is there any way to make arbitrary record deletion non-trivial in php? I'm
thinking about a hash function to replace the real db id (DELETE FROM table
WHERE record_hash=validated_form_hash), if possible without adding an
awfull lot of server side computation.

Deleting A MYSQL Record From Within An Html Form
Just rebuilt an admin tool in PHP (originally built in asp) for a news section of a site.
The problem is: My delete records php page is set out in an html form, with each news story expressed with a checkbox. normally i'd put a <a href="delete.php?id=<? echo $row->id; ?> </a> alongside the record, but i need to have it work in a form.

What action should the form have, and how do i get the form to process the deletion process with the correct news story checkbox selected?

Checking If A Value Is Not In An Array And Deleting Record From Database
I have been trying to figure this one out and have come up against a brick wall although I know it should be relatively simple. I have a form that passes an array to a php script from a multiple select box that is created dynamically.  If a user deselects an item then I want to delete the record from the database but am having a big problem with it. The table in the dbase is quite simple with just three fields:

id
classid
formid

Basically, the form send through a classid and a formid value and I want to delete any records that have a classid that are not in the form array and have a formid which is passed as a hidden value. I suppose really what I want is to know how to see if a classid is not in the array that is passed.

Deleting From Mysql Table
i'm trying to replace a record in a mysql table but i'm having problems. First i've got a page to store existing film name values using:

<input type="hidden" name="Name" value= "<?printf($row["Name"])?>">

The second page is supposed to delete the existing record by comparing the stored name value with the database name but it only creates a a duplicate record. Here is the code for this: Code:

Deleting One Row From Mysql Table
I want to delete one row of a mysql table, and still to be in the same page, but the page needs to be reloaded and to give me new results Code:

Deleting A Table From A MySQL Database
I've looked at the manual and a few other php resources, but yet I couldn't find a simple and easy way to delete a table using php. I noticed there is a destroy() function within the MySQL class, but I'm not sure how it's used.

Most Popular Record In A Table?
I have a table with lots of entries, eg:

Bob
Fred
Bob
Graham
Bob
Harold
Bob
Frank
William
Fred
Bob

How can I find out which is the most popular name (ie which one appears the most often - in this example 'Bob')?

Deleting Duplicate Entries From MySQL Database Table
The topic is related to MySQL database.

Suppose a table "address" contains the following records

-------------------------------------------------------
| name | address | phone |
-------------------------------------------------------
| mr x | 8th lane | 124364 |
| mr x | 6th lane | 435783 |
| mrs x | 6th lane | 435783 |
| mr x | 8th lane | 124364 |
-------------------------------------------------------

Quote:

Fetching Data From Table Except The First Record
What query needs to be written to fetch the data except the first record, the id is auto increment but if the users delete the first lowest id then second id must not be shown.

$tbl=new Model;
$sSqlQuery="select * from ".ACHIEVEMENTS_TABLE." WHERE achievements_lang='EN' AND 1=1";

Select SECOND Top Record In Table + Mysql
how to get second hightest record in table is there posible in mysql

Return Record Ranking Of A Mysql Table
I have a table consisting of names, and registration dates. I query the db "select * from users order by regdate" I want do another query for a particular user, I am looking for the script to say: user is row 15 of 30.

Last Record Of Table Not Showing Up (3x Array Query)
I ran into some touble with my already pretty confusing project. I finally managed to figure out how I can link 3 tables together and show info from all per cell of a table..
this required a couple of while loops and it works like a charm except I am missing the last record Code:

Print Table (4 Columns 2 Record Sets)
I am trying to print a table of prices. I am storing a retail price and a wholesale price in a table productpackaging which is structured like:

pdpackId
ProductId as int
PackageId as int
Pcode as varchar
RetailPrice as Decimal
SellPrice as Decimal
HoldPrice as Decimal
etc

The Pcode field tells me "RT" for retailer or "WS" for wholesale pricing. I want to query this table and print an html table with 4 columns the first for the retail labels - the 2nd for the retail prices - the 3rd for the wholesale labels and the 4th for the wholesale prices Code:

Selecting/using Multi-table Data How Do You Manage 'current Record'?
I am working on a DB for family data, and in this application the data
spans variable amount of rows in multiple tables (one for the adults
data, one for "family", one for the kids, another for employment
schedule, and another for businesses, etc.). I was thinking on
selecting the entire family (IDs of all the related records) and
storing them in a session array for easy access (from script to
script) as I edit the data, but am wondering if there is a better way;
what other methods do any of you guys have have?

Am I correct in thinking this could be contained in a class? (I kinda
get classes but not all the way yet) And if a class is a good thing
- how is it persistent from script to script?

Batch File Deleting And Folder Deleting
I have a folder in my web site where I used php to create and copy in files. but now I can't delete them easily. The only way I know how that is possible is through php. I get an error the following ftp error:

550 th: Permission denied
I had the chmod() set to 0777 on every file and folder. But I still seem to loss control over the files when I try and do things with them through other means.

I think it is because the user I use to access the files via ftp a diffrent user. So I tryed to add a function with chown() for the new files I was posting and uploading. It didn't work on those new files. so it looks like the only thing I can do is use the unlink() function which deletes the files fine.

The only problem is now I have something like 100 sub directories all with files in them. I need to figure out a way to batch delete them. I can't find a script that goes through and finds all file contents including all sub directories and unlink those things.

I found some that will use a for loop to list out the contents of a folder but it is just files. No sub directories. Any body got any ideas on which functions I should use or know where a script is that I can base mine off of.

I am not sure how to approach this since what I tryed with chown and chmod has failed thus far. I currently have no code and am starting from scratch on this batch flushing of my directory.

Compare Record With Session Variable And Update Record If Different
I'm trying to figure out how to create a session variable from a recordset field value in a mySQL database and compare this with subsequent values from the same field each time the page reloads. When the value of the field changes (as a result of a user update) I want to trigger an event (redirecting to another page). It's probably a very basic PHP function but I am a newbie with this language.


Grab Content From HTML Table And Place Into MySQL Table?
I am in the process of helping a co-worker upgrade some of his old static html pages into dynamic MySQL driven pages. He currently has a lot of pages with huge tables displaying data. Does anyone know if there is a script or class that can convert a table to a .sql file for upload?

Table Background Color Based On Results From MySQL Table
I am trying to get the "Did User Agree" field on a database query to be colored Green for "Agreed" Red for "Disagreed" and Blue for "Agreed (2nd Time)" .. I have my PHP setup to do the query just fine as of right now with alternating column colors, just can't seem to get the colors to work as I am hoping for.  Can anyone help me get the Agreed? table's background color to the colors above? Code:

Outputting A Table Or Form Using SHOW FIELDS FROM Table
In the code the MySQL database was queried using "SHOW FIELDS FROM table" which and the returned results of column names was then use to build an output for a form and a table with php using a series of if statements along the lines of if the returned field name matches something echo a text input field.

I have never seen this done this way before, so I want to get the opinion of the devshed user. Does it seem like an unsual long process to build up a form. Is there a security advantage doing it this way? Has anyone ever done it this way before?

Finding Matches In A Table And Then Moving That Match To Another Table?
Ok, I have a database that has a table called critiera in this table
is to fields on is ID and the other is critiera.

Now I want to filter out all the one that don't apple to the list and
move the one that match to a different database.

I know how to open a connection, close, select

but I don't know how I would inside of a database use another one as
the way to create the list of critieras....

Mysql Fetch_field Gets Table Alias, Not Real Table Name
After a SQL 'select .... from tablename alias'
the mysql_fetch_field function returns a value $result=>table which
will contain the alias, not the actual table name.
Is there a way to get the actual table name ?

I am running mysql 4.1 and php 4.4

Grab Data From A Table, Echo, Then Insert It Into A New Table...
I'm trying to do is count the number of times usernames shows up in a table. I then want to reinsert that information into a different table with the Username in column1 & the occurrences in column2 for every user that is echoed on the page. Code:

Using PHP To Sort Data In MySQL Table 1 By Values In Table 2
I have a MySQL database with 2 tables in it. products and prices.. Products has a field in it called 'prodno'. Prices has a field in it called 'prodid'.

There is one of each item in products and each product has it's own unique 'prodno'

There are multiple instances of each product's pricing in prices.. One for each price.. So if a product had multiple prices depending on quantity it would have an entry for each price.. Example:

id = 1
prodid = 7001
qty = 300
price = 12.5

id = 2
prodid = 7001
qty = 400
price = 15.5

I was wondering if I could query the database getting info from the products table but sort it according to the prices in the prices table.

Kinda like doing a "SELECT * FROM products" ordering it by the lowest price value from each item..

This is all very confusing to me, and I'm the one writing it. Let's try one last time..

Query the database selecting * from products (I plan on using all the info in products) and ordering them by the lowest price for each item in the prices table. I've tried sorting the results of just a basic SELECT * FROM products using Javascript and PHP but with pagination in the results it makes it a bit hard.

Update Table While Insert Data To Another Table
it seem like mine coding din work.
[php]<?

include("checkin.html");
$conn=mysql_connect('localhost','root','') or die ('Could not connect to server');
$today = date("Y.m.d");
mysql_select_db('hms', $conn);

$ok = mysql_query("INSERT INTO check_in(ID,room_no,datein)values ('$ID','$room','$today')", $conn);

if( $ok ){

$up = mysql_query("UPDATE studtable SET checked = 'checkin' where [ID] = '%ID');

if(mysql_affected_rows( $up ) == 1)
{
echo'Checked IN!'
}else { echo'No such student to check in' }}
else { echo'Check In FAILED, please check again'}?>[php]

Deleting
how could i delete everything from a table in a mysql db except for the 10 latest things ?

Deleting All Files
Is it possible to delete all files in a folder using unlink() or something similar?

Deleting The Saved Db The One Before?
I made a script that backups the database as sql file in the server. I mean script writes it into the harddrive, but everytime when i execute the script the harddrive loss another 3 mb. How can i modify the script to delete the one before when i execute it to write the new one?

Need Help With Deleting Records
I'm trying to add a link on the display of a record to delete that record.

The main part of the record is stored in pw_event, then there are several rating fields for that record stored in pw_rate, and there is also several records for the first record stored in pw_whois.

I need to have a link that will deleted everything for that record in all three tables.

Here is my display script:

PHP Code:

Deleting Last Comma
The code below displays pet names like so:

Fido, Bowser, Kittycat, Spot,

and I want to delete only the last comma. I tried 'substr' and 'rtrim' and both of those delete the space and comma between each name, not just the last name as I'd like, so I end up with:
Fido,Bowser,Kittycat,Spot,

How would I delete only the last comma, so that it is this instead?
Fido, Bowser, Kittycat, Spot

Even with trim and substr, I end up with:

Deleting A Session
I want to be able to delete a session so that the next time there's a call to session_start, it creates a new session ID. I don't want to destroy the session variables specifically (though this will be a side-effect of what I'm doing) so I know that session_destroy isn't what I want to do.

I presume I should just delete the session cookie manually. Is there a neater way? And if not, how do I do this?

Deleting A Director
I'm using this code trying to make ato delete a file or folder under w2k, apache.

$direct=split("repadmin.php",$PATH_TRANSLATED);
$file=$direct[0].$filedeleted;
$filesys = eregi_replace("/","",$file);
$delete = @chmod ($filesys, 0775);
unlink("$delete");
header("Location:repadmin.php");
exit;

but return this warning:

Warning: unlink(1) [function.unlink]: No such file or directory in c:program filesapache groupapachehtdocsguonline epositorio epadmin.php on line 94

I checked the whole path and looks good.

Deleting Files
The below should delete files from a dir older than a week. I set the $dtime to 0 to test the script but it deletes nothing. What is wrong? Code:

Deleting Files
I'm using different files to store some arrays to make administration of a very small job-logger very easy. I currently read the file, remove the element to be deleted, delete the whole file, and write the file again without that element. Is there a way to remove a single element out of that file without deleting the whole file?

Deleting Cookies?
For some reason is i set my cookies like this PHP Code:

Deleting A Line
how do i delete from a text file 1 of the following lines

jon|scott
adam|smith <--delete
paul|clark

say i would like to delete the middle line of this txt, in member.txt
what php code or logic would help me accomplish this?

Also i am clicking on a hyperlink that is keeping count of the entries
i have
made. e.g php?record_id =1
php?record_id =2

Deleting Records
I've been trying to delete records since a week and i'm not able to do it. Before with this script, i was doing so many things at a time and i was confused.But, now, i just displaying the records from a table N trying to delete them.Would somebody pls guide me.

I just wanna set the delete flag(i.e, i want to set the RBS_DELETE column to Y or something) when i check a check box to delete it. I've some 5 records displaying on my form and i want to check 3 of them and when i check them and hit submit, i want the RBS_DELETE column to have some value. PHP Code:

Deleting A Row From A Database
I can't fiqure out why my delete function isn't working. I have a listing of rows in my database with an option to delete an individual row at the end: Code:

Deleting A Message
I want a button to delete each message in you inbox wen clicked. im using this that doesn't work, because i coded it Code:

Cookie Not Deleting
login.php:
setcookie('id', $userinfo['id'], time()+60*60*24*31*3 , '/');

logout.php:
setcookie('id', '', time()-60*60*24*2);

Any idea why it is not deleting my cookie?

Deleting Posts
How can I delete my previous post?  It's showing up in Google when I search for the url referenced in my previous post (if I put the name here, it will show this post, too).  If I can't delete it, can I make it so that Google can't pick it up?

Deleting Files
I'm trying to modify this script to remove files that end with %enlarged.jpg or %enlarged.gif or %enlarged.png, can someone help with the if statement, I've tried several things, of which, nothing is working: Code:

Deleting Folder
is there anyway of deleteing a folder and deleting all of its contents with it?
i know that with rm_dir needs to folder to be emptied

Deleting The Pages!!!
I wanted the php files in my computer to be protected.If someone copies them and use in different machines,how can the php code find that the code is running in nextmachine. Is there any idea,that I delete the files using the unlink() method,when they are stored/run in next machine.

Deleting Using Checkboxes
im wanting to delete multiple things from a database using checkboxes, now i know how to use checkboxes in php etc. my question is would this be done using a basic while loop? i mean would i query all the things and then do

while ($check_box == 'ON')
{
do the delete script
}

or is there something more to it?

Deleting A Line From.txt
it writes the line or lines to be deleted correctly into issues_deleted.txt which is line fwrite($file_contents_deleted, $value);

and when it refreshes the line still exists in banip.txt it does echo out the line as well just doesnt remove it from banip.txt anyone know why? Code:

Deleting From Sql Database
I have used this script I made to delete files from a server and simultaneously remove information about the file from a database. I have uploaded the same script to a new website and it no longer works. The file does get deleted but the database line doesn't get removed. I can tell where it's going wrong by the error custom error message 'echo'ed on the page ("your file was only partially uploaded"), but I really don't know why.

Deleting Files
I have some script that takes an album id and deletes that album and the specific photos in that album. The code does run. The problem is that an error message i set to echo appears saying error deleting photo once the page automatically refreshes. When i check the image folder the images actually have been deleted. Code:


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