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 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 !
Simple Delete From Array?
Any way to do a simple delete from array? In other words, what would be the *easiest* (and fastest php runtime) way to delete "banana" from the following array: $my_array = array( "apple", "banana", "grape", "lime" ); .....so that $my_array will now be: $my_array = array( "apple", "grape", "lime" );
View Replies !
Simple Delete Of File Question
I have a dynamic list of images Code: $files=directory("../photos/","jpg,jpeg,Jpg,JPg,JPG"); foreach($files as $pic){?> <img width="150" src="<?php echo $path.$pic;?>" align="bottom" /> <input type="button" name="Submit<? echo $ct?>" value="Delete" /> <?php echo $path.$pic;?><br/> <?php }?> There's got to be a simple way to have this button delete just that file.
View Replies !
Simple Login Page To Delete And Edit Things In Mysql Database
How do I build a simple login page on my site? I need a way to login to my admin area in my webshop, so I can add, delete and edit things in mysql database. I don't need help with add, delete and change things, only the login thing. The users should not even know that there is a admin login page. The users don't login to shop, they just shop so I can't use the user login page because there is no such page. Can someone please give me some guidelines for 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 !
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 !
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 !
Simple Php Query!
i am trying to get some records to display from a mysql database done in phpmyadmin... Now the php seems to run fine, but only displays 1 row from the database which is 'Web' and it does so in the wrong place (where First name & lastname should be) Code:
View Replies !
DB Simple Query
I'm busy messing around with the pear package db (mysqli) and was wondering if theres a simple way to do simple select queries. Like say grab a username based on a user id. PHP Code: $TestSQL = "SELECT * FROM `users` WHERE U_ID=Ɔ'"; $Results = $dbh->getAssoc($TestSQL); print_r($Results); which prints this out, Array ( [0] => Array ( [0] => username [1] => password ) )
View Replies !
Simple Query
I need to query my db using a date and then, if the query returns anything, I need to set a variable. However I keep getting the error : Function name must be a string Code:
View Replies !
A Simple Form Query
Can any help me? What I want to do is simple but I can't find anything to help aside from a little php that doesn't help. I have a form with three text areas, I would like this form, when submit is clicked, to take the user to an HTML formattable output page of the heading of the text areas and the info the user typed in, a preview page if you will. It will be so the user can print the formatted output and file it in their student logs. Or they can save the html output file. I found a php script that does output to a php file, with the headings and results, only I don't know how to format the php to accept my external css file. Any help appreciated, I have a headache from searching for options! Ellie Here is an example of what I was doing...Any solution is welcome but for a linus server <?php $prefer = $_POST["prefer"]; $develop = $_POST["develop"]; $challenge = $_POST["challenge"]; if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Personal INFO</title> <link rel="StyleSheet" href="style.css" type="text/css" /> </head> <body> <form method="post" action="<?php echo $PHP_SELF;?>"> <p>Which opportunity do you prefer and why? <textarea rows="5" cols="20" name="prefer" wrap="physical"></textarea> <br /> How could you use this opportunity to develop yourself? <textarea rows="5" cols="20" name="develop" wrap="physical"></textarea> <br /> What might challenge you? <textarea rows="5" cols="20" name="challenge" wrap="physical"></textarea> <br /> </p> <input type="submit" value="submit" name="submit"> </form> <? include "<link rel='StyleSheet' href='style.css' type='text/css' />"; } else { echo "<p>Which opportunity do you prefer and why?</p> ".$prefer." <br />"; echo "Which opportunity do you prefer and why?<br /> ".$develop." <br />"; echo "Which opportunity do you prefer and why?<br /> ".$challenge." <br /></p>"; } ?>
View Replies !
Simple POST Query
I have a simple query but due to my lack of php knowledge, can't find the right function. Let's say I have a form with 3 input fields. [field1] => 'hello' [field2] => 'ok' [field3] => 'goodbye' When I submit the page, I would like to echo this result: [field1] [field2] [field3] In other words, I want to have control over the posted header to determine if I should input in database the variable or not. If I use $HTTP_POST_VARS it actually returns the variable inside the header... i actually need the header's name.
View Replies !
Simple Mysql Query
mysql_query("UPDATE table SET field='$value' WHERE class='2'"); How can I make that update every row where the class is 2 or greater?
View Replies !
Simple Query Change
i need to remove the MD5 pass encryption. PHP Code: $query = "INSERT INTO $tb_albums (user_id, title".(($_POST['password']) ? ", password" : '').") VALUES ('".$_SESSION['userid']."','".$_POST['title']."'".(($_POST['password']) ? ",'".md5($_POST['password'])."'" : '').")"; thiers so many brackets when i try ti remove the md5 all i get is errors.
View Replies !
Simple MySQL Query Using PHP
I'm using a pre-written directory script that I want to personalise a bit. There is a table called categories, and in that table, there are fields for "id" and "cat_name". The URL used is in the form index.php?cat_id=1 What I need to do is to display the corresponding cat_name for the id in the URL. Is this easy? Where do I start? How do I get to learn all this stuff?
View Replies !
Simple Search Query
I am trying to create a simple search query to find if a name exist in my mysql db. $sql = "SELECT category_name FROM gallery_category WHERE category_name = '".$category_name."'"; if(mysql_query($sql) == $category_name) { do not create directory } else create directory
View Replies !
Simple Database Query
i have a database which has a table which has a number of fields. what i would like to do is display the latest entries on a front page, but I want know how to display the latest entry from a certain category which is defined in the field category. Code:
View Replies !
Simple Join Query
i'm using mysql 3.23 for my DB. I am trying to run a simple mysql query with a join. Although i'm normally good at joins but for some reason i cant get this query to work and its just a simple join. right have a users table USERS user_id int user_name varchar(200) USER_REMOVE_SEARCH user_id int rem_user_id int i just want all users from users table except 7 the one's that user_id 7 deleted from his search and now exist in user_remove_search table.
View Replies !
Simple Query String Not Passing
I've been messing with PHP for a few months now, and have some basics down. However, I thought I understood this issue, but here I am posting... <heavy sigh>. Two files: register.php which is the form to allow a user to register with the site, and success.php which does the form validation, etc. If invalid input is found, I'm using the code below to go back to the register page. @header("Location: http://url/register.php?id=1"); The id is examined in a switch statement on the register page to generate a message on the register form telling the user exactly what field the problem occurred in. Here's the problem: The id value is not being passed in the redirect. Can anyone tell me what I'm doing wrong?
View Replies !
AJAX, PHP, Mysql Simple Query Example Anyone?
I'm having a heck of a time wrapping mind around AJAX. Anyone know of a simple, straight-forward example for pulling a simple query from mysql with PHP using AJAX? As I understand it I need a PHP script that pulls the query and dumps the data into XML format, that is called by triggering a javascript event that reads that file with XMLhttprequest. Is there a cross-browser way of doing this or do I have to detect whether I'm using IE or Mozilla? A good example that doesn't look like rocket science would be nice.
View Replies !
Simple Search Question From Query.
I am trying to use a form to call another page (search.php) where search.php finds the text enter in the text field from the database and displays it. The problem im having is that I cannot seem to get it working... could some one please look at my code and tell me if it is ok, and if it isn't, help me make it work. 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 !
Better MySQL/PHP Query Formatting (simple Question)
I have been using MySQL in conjunction with PHP for many years now... I have been using the exact same method for not only connecting to a database and performing the queries but also displaying the results. I've been told numerous times that my methods are out-dated. I'm more than willing to cede to this possibility but I need help getting out of the rut!!! Can anyone help me? Here are some examples: <head> .... <?php include "../../../_private/mysql.inc"; ?> <?php $db = mysql_connect("$server","$user","$pass"); ?> .... </head> <body> .... <?php mysql_select_db("database_name",$db); $result = mysql_query("SELECT * FROM temple_items",$db); while ($myrow = mysql_fetch_array($result)) { $id = $myrow["ID"]; $name = $myrow["Name"]; $amount = $myrow["Amount"]; $date = $myrow["Date"]; echo "<div>" . $name . ": " . $amount . " (" . $date . ")</div><br />"; } ?> .... </body> It's crap, I know... I've been told that there are more efficient ways of doing nearly all of this. Can someone instruct me in the ways of better database queries? I'm hopeless until I have this knowledge.
View Replies !
Simple Menu, MySQL Query Question
I'm creating simple menu. MySQL: +----+-----+----------------------+ | id | sid | Title | +----+-----+----------------------+ | 1 | 0 | Main Menu 1 | 2 | 0 | Main Menu 2 | 3 | 1 | SubMenu 1 of menu 1 | 4 | 1 | SubMenu 2 of menu 1 | 5 | 1 | SubMenu 3 of menu 1 | 6 | 2 | SubMenu 1 of menu 2 +----+-----+---------------------- What should be my query? I'm trying to select all titles, and display them: Main Menu 1 - SubMenu 1 of menu 1 - SubMenu 2 of menu 1 - SubMenu 3 of menu 1 Main Menu 2 - SubMenu 1 of menu 2
View Replies !
Simple Question: Query String Variable And More
suppose i have two html-formatted documents with appropriately coded <?php ?> areas. a typical query is this: file.php?call=123.html in 123.html i define a variable $doctitle How can I display $doctitle in file.php (an html-formatted file as well)
View Replies !
Simple MYSQL Query - 2 WHERE Conditions Syntax
I am trying to formulate a mysql select statement where it selects all the fields below I am having trouble however with WHERE indMatch.player2ID = '$username' I want to add to this WHERE indMatch.p2ConfirmResult is equal to 0 aswell but I do not know the syntax. Code:
View Replies !
Simple Select Query To Get The Huge Number Or Recors And Save In Text File
I have a huge mysql database with arround 500,000 records. All the records have a date field. Every day like 100 records been added in the database with date. I am getting this data using select query in different forms like current week, month, year and all from beginning data and save it as a text file Now the problem I am having is with the select query ...
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 !
Simple Script For Doing A Simple Photo Album And Journal?
I'm looking to quickly get a photo album online. Very simple, thumbnails, a few pages, maybe a description, but hopefully a small script that's easy to edit and work into my existing site. I know about hot scripts, etc. but I was wondering if any one could recommend one? Secondly, I also want to setup a journal. It's not really a "blog" although I guess blog software may work. But it isn't going to be a message board or anything like that. Just a place to put out random bits of news. Once again, same premise, I'm trying to find the most simple script possible that could basically traverse a directory of simple textfiles and produce a list. I know all about Blosxom and stuff like that, but I'd like a script that just did the above and didn't overtake my site like PHPNuke or something like that. I'll probably roll my own, but I thought I'd check first.
View Replies !
Simple Simple String Question
When I take the input from a textarea and insert it into a mysql-base and then retrieve it and show it, all the line feeds/breaks are gone. It is shown as one giant string. How can this be fixed, so the text will be shown as it was entered? Does it have something to do with stripslashes/addslashes or am I way off?
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 !
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 !
|