Find Out If The Delete Query Was Succesful
I'm running some UPDATE/DELETE x WHERE x=y type queries on my db from php. Is there a way to find out if the delete was succesful or if there was some kind of error i.e there were no instances of x=y in the table.
View Complete Forum Thread with Replies
Related Forum Messages:
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 !
How To Code Add,find,delete Buttons
Hello, I am new to PHP and Postgres. I am creating a page that displays a form to allow entry of details about a piece of equipment. The form is intially blank. I want to have 3 buttons: Add, Find, Delete. It shows only one piece of eqipment at a time. The user can fill the form out, press Add and it will insert into the database. Or they can enter the equipment ID, click Find and then modify or delete (by pressing the Delete button) the returned record. I am able to create the form and the SQL but I am not sure how to have the buttons fire to execute the PHP code for each functionality (Insert, Find, Delete, Update). Can someone point me to a resource that shows how to do this?
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 !
Sql Query For Find All Records Have Same Id
Lets suppose I have a table like this one idid_1id_2 date_time 110110002006-07-04 11:25:43 21021001 2006-07-04 11:26:43 310110052006-07-04 11:27:43 410310002006-07-04 11:25:43 I want to find all records have same id_1, but different id_2 and have difference in time less than 5 minutes. In this case this is record 1 and record 3. How can I do this ?
View Replies !
Delete Query Successful
How can I test whether a delete query on any other query for that matter has been successful deleting a record. I tried below but it does'nt return if the query deleted a record. $deletequery= "DELETE FROM details WHERE id='$line[id]' AND orderid='$orderid' AND location='".LOCATION."'"; mysql_query($deletequery) or die(ErrorDB($realname)) ; $message = (!$deletequery) ? 'ERROR' : "<font color='#FF0000'>DONE</font>"; echo "$message<br>";
View Replies !
Mysql Query : Delete From *
When I use phpmyadmin, and run this sql query, it will tell me that it affected X amount of rows (lets say 10). However, when i run my script, it doesnt' tell me that. Code:
View Replies !
Simple Delete Query
This code should delete a row from the database where ID = ID however it doesn't seem to be doing its job PHP Code: <? if(isset($_GET['id'])) { Â Â Â Â Â Â Â Â $query = "DELETE FROM mynews WHERE id = '" . $_GET['id'] . "'"; Â Â Â Â mysql_query($query); Â Â Â Â echo "<p align='center'>Deleted</p>"; Â Â Â Â } else { Â Â Â Â Â echo "<p align='center'>Not Deleted</p>"; } ?>
View Replies !
Query To Find The Largest Number
I've got a table (MySQL) with a field called: 'java_num'. It's a varchar(4). It's going to have a number in that field anywhere from 001 to 999. How can I make a query in PHP that searches through that field and finds the largest number?
View Replies !
Delete Query Not Working As Expected
I have 2 different php forms. One makes sure that a user has chosen an unique user name (below): $query_rsApp = "SELECT * FROM users where UserName=".$Registered." "; This Select query works right every time (as far as I can tell). I have a form that I want to use to delete user records. This Delete query works fine if the username and password are both numeric... But if the username or password is text, it returns the error "UNKNOWN FIELD 'whatever'" where whatever is my search criteria that I am trying to use.
View Replies !
Delete Query Takes HOURS
why on EARTH would this query: Code: DELETE FROM `test_zip_assoc` WHERE id > 100000 take an entire day when there are 10 million records in this database: Code: +--------------+------------------+------+-----+---------------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------------+------------------+------+-----+---------------+----------------+ | id | int(12) unsigned | | PRI | NULL | auto_increment | | f_id | int(12) unsigned | | | 0 | | | zip | varchar(5) | | | | | | lat_radians | decimal(12,11) | | MUL | 0.00000000000 | | | long_radians | decimal(12,11) | | MUL | 0.00000000000 | | +--------------+------------------+------+-----+---------------+----------------+
View Replies !
Find And Replace Query Variable In URI String
I am trying to find and replace the query variable relating to the session id "sid=". This is the portion of the script that has to find out where the sid= is in the string and replace it with an updated version that contains the session id. It is not finding "?s=" nor "&s=" when I run it any of the following urls. http://www.mysite.com/?func=home&sid= http://www.mysite.com/index.php?func=home&sid= http://www.mysite.com/?sid=&func=home http://www.mysite.com/index.php?sid=&func=home I commented out the parts which do not have a bearing on the basic string search function. PHP Code:
View Replies !
How Do Format Query To Find All Rows With The Same Email
I have a table looking like this: ID | email | other 14 |11@11.com |other 15 |22@22.com |other 16 |11@11.com |other 17 |33@33.com |other 18 |44@44.com |other 19 |11@11.com |other How do I format my query to find all rows with the same email if the only variable I have is the ID? Ie. if I know ID 14, all three rows with email "11@11.com" should be returned.
View Replies !
Query - Find All The Fields In The Stories Table
i have this query and i have been googleing for what i want it to do but didnt have any look. the below query is almost what i want it to do, what i want the query to do is find all the fields in the stories table that has a username = $ui_name BUT doesnt have *-comment in the page field $ui_posts_q = "select * from stories where writer = '$ui_name' and page like '%-comment'"; so basicly the type of thing im want to do is this $ui_posts_q = "select * from stories where writer = '$ui_name' and page not like '%-comment'";
View Replies !
Query Mysql To Find 'missing' Data
Every week users are required to enter data about a specific store/shop into the mysql database. I want to query the database to find out who hasn't done it, and output it in a csv file. Code:
View Replies !
Find A Word In A Variable And Replace It With Mysql Query
i want to make and build a site service. and i have this code on my template: <--Beginsite--> <--title--> <--textbody--> <--date--> <--ensite--> well i have this informations in mysql and i want to create the script with php to find this codes in $template and going to a loop and replace them to 10 times.
View Replies !
Loop Through Summary Query Resultset And Find The Summarized Field For A Particular ID
I figured out how to have nested do/while loops to display related items in a heirarchical structure like below. However, I want to show the heading "related books" ONLY IF there are related books. So I did a summary results set of the related books table but I'm not sure how to loop through or fetch the summary record to check if there are any records. If so, display heading, if not, do not display. Code:
View Replies !
Delete Query - Error In Your SQL Syntax; Check The Manual That Corresponds To Your MySQL Server
I have tried to make a delete query but it won't work it gives me a syntax error but I'm unsure where i have gone wrong.... this is what i have got at the moment: Quote$Deletesoldhouses = "DELETE * FROM soldhouses WHERE SoldHouseID = '$HouseID'"; mysql_query($Deletesoldhouses) or die(mysql_error()); Can any one see what i did 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 '* FROM soldhouses WHERE SoldHouseID = '1'' at line 1
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 !
Use Query Result Field As Query Key For New Query..
$query  = "SELECT ProjID, UserID, ProjDesc, file, OrigProj, OrigUser, ProjDate FROM projects"; $result = mysql_query($query); I would like to take the field 'UserID', and utilise it for a Query statement to my users table in my database, to read and fill in information to my table, which looks like this: PHP Code:
View Replies !
Execute An Update Query Based On The Results Of A Select Query
I'm trying to execute an update query based on the results of a select query... This doesn't work - any ideas? This is the code I'm trying to get to run (it updates all products which are set to arrive by a certain date if that date has arrived or passed - and there are products that should and should not be updated in the db this is being tested with...): Code:
View Replies !
Turn Select Query Result Into Hyperlink To Other Query
I have a query which gives results of selecting coursenames from a table called trainingtopics but this does so in a continuous bulk of text without any breaks between each record. my question how do I create line breaks between each record and also how can I force each query result to become a hyperlink which when clicked runs another query that gives details of that course. <?php $user = "root"; $host = "localhost"; $password = ""; $connection = mysql_connect($host, $root, $password) or die ("Couldn't connect to server."); $database = "courses"; $db = mysql_select_db($database) or die ("Couldn't select database."); $sql = "SELECT coursename FROM trainingtopics"; echo $sql."=sql<br>"; $result = mysql_query($sql) or die(mysql_error()); echo $result."=result<br>"; while($row=mysql_fetch_array($result)) { // NOTE this one ABOVE the echo echo "result found!"; echo $row[0]; } ?>
View Replies !
Accessing Query Data From Query Against Multiple Tables
I have a query that gets info from two tables in my database. How do I access the data from the query? I know how to use the mysql_fetch_assoc() when the query in question only pulls information from a single table. How do I do the same thing for multiple tables and then insert the necessary data into my page? Code:
View Replies !
PHP Update Query Mysql: Query Succussful?
I can't seem to successfully test an update query. Below is a piece of code that updates a statistics table. If row today doesn;t exist, a new day must be created. But this doesn't work... thank you for your reply. $today= date("Y-m-d"); $qq="update totals_r set hits_r=(hits_r+1), lang_$lang=(lang_$lang+1), cat_$cat=(cat_$cat+1), rating_$rating=(rating_$rating+1), bussite_$bussite=(bussite_$bussite+1) where date='$today'"; $result_6 = mysql_query ("$qq"); if (!$result_6){ /// IF !ROW_TODAY ==> CREATE NEW DAY $qq_2="insert into totals_r (hits_r, lang_$lang, cat_$cat, rating_$rating, bussite_$bussite, date) values(Ƈ',Ƈ',Ƈ',Ƈ',Ƈ','$today')"; $result_6_2 = mysql_query ("$qq_2"); if (!$result_6_2){ $err_msg_sql_6= mysql_error(); $err_loc_6="$PHP_SELF"." // Query6: update totals_r"; } }
View Replies !
Speeding Up Query/code (query Within Result Set)
I'm looking for ideas on how to speed up this script. Basically it finds all the zip codes in a zipcode table, then looks for all the records in another table with those zip codes. Right now it finds all the zips then within that WHILE, it looks for a record in another table with that zip: PHP Code:
View Replies !
Query - Create The Mysql Query To Get All Fields
I've a table "article". Any article is of a type in table "type1" or "type2" Each type may be of a model in table "model1" or "model2". Each model can be on a certain make, also in 2 tables, "make1" and "make2". they are a few possibilities. "article" can be of "type1" or "type2" "type1" can be of "model1" only - "type2" can be of "model1" or "model2" "model1" can be of "make1" only - "model2" can be of "make1" or "make2" "article" has "type.id" field (char10). If it start with "my" then it's a "type2", otherwise is a "type1" "type1" has only "model1.id" field. "type2" has "model1" and "model2" fields. If one is filled, the other isn't "model1" has only "make1.id" field. "model2" has "make1.id" and "make2.id" fields. If one is filled, the other isn't so here are the possibilities: article -> type1 -> model1 -> make1 article -> type2 -> model1 -> make1 article -> type2 -> model2 -> make1 article -> type2 -> model2 -> make2 Now, I must create the mysql query to get all fields given the "article.id". Is it possible ? How ? will this work ? in pseudo-code article left join type1 articleid = type1id inner join model1 type1id = model1id //inner because if type1, the model is 1 inner join make1 model1id = make1id //inner because if model1, the make is 1 left join type2 articleid = type2id left join model1 type2id = model1id left join model2 type2id = model2id left join make1 model2id = make1id left join make2 model2id = make2id
View Replies !
How Do I Find Even #'s In Php
ur prob. all laughing at this easy *** question ... but for some reason i cant fig. it out. i know how to find even (and odd) numbers in c++ (using the %). how the hell do u do it in php tho... im trying to alternate the bgcolor of a row in a table (from #CCCCCC to #FFFFFF) here is my code.. if ($row = mysql_fetch_array($result)) { $x=0; echo "<table width=200 border=1 cellspacing=0 cellpadding=4>"; do { if (($x%2)==0){$color="#FFFFFF";} else {$color="#CCCCCC";} echo "<tr bgcolor=$color><td>"; print $row["name"]; print ("</td><td>"); print $row["email"]; print ("</td></tr>"); $x=$x+1; } while($row = mysql_fetch_array($result)); print ("</table>"); } else {print "Sorry, no records were found!";
View Replies !
How To Find IP?
Mostly when u visit shopping carts n u checkout n go futher for payment in the list box your desired country is selected automatically this is bcoz of they are tracking us by our IP Address. So which function in PHP is used for find the IP Address of a person who is visiting my site?
View Replies !
Find An Url?
I'm trying to read url's off of a website page by reading it's source code and locating http://www..com/? etc. <embed src="http://www.somewebsite.com/someflash.swf" width="somewidth height="someheight"> Is it possible to locate a code in the source of a web page, except the exact link "http://www.somewebsite.com/someflash.swf" can be replaced with like %%%%%%%%%% so it simply finds it's similiar match? Otherwise I need to put in the exact url, and I want to search for all http urls instead.
View Replies !
Find A
I have a text feild where data is pasted: Corners 9 8 Header 10 9 Goals 1 3 What would be th best way to parse this data so I can see cornera = 9 and cornerb = 8.
View Replies !
Find [ % ]
if I wanted to find any items in an array starting with [ and ending with ] how would I go about it? I amm building an email queue processor and I want to be able to place email address or distribution list names. eg if I had a list.. chris@domain.com, john@domain.com, [maillist_1] PHP Code: $email_to = "chris@domain.com, john@domain.com, [maillist_1]"; $email_to = explode(",", $email_to); foreach($email_to as $to_emails) { // First Check if its a distribution list if($dist == "yes") { // get the list and split them. $emails_to[] = $to_emails; } else { $emails_to[] = $to_emails;....................
View Replies !
How To Find Url Php
Hello all,If my site has two domains, but domain one should point to french which already works.but domain 2, how can I check the url and if url is let's say domain2.com then add lang=en to the query string.
View Replies !
Find A Tag
how to extract a tag from an URL. For eg, If i enter the URL http://youtube.com/watch?v=dYhhQhtrlFI I'd like the EMBED tag from the page to be extracted. (i.e) When i enter the URL in a field and hit the submit button, i want the EMBED code to be stored in variable.
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 !
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 �', 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 !
Using Query Result To Do Another Query In Loop
I have 2 tables, one called users2 and one called books. Books has a field called UserId, which is the ID of the user that added the book to the database. My problem, is that i need to take this ID from the book table, and use it to get some information from the user table. Here is my code to get the ID from the book table: Code:
View Replies !
|