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.





Select & Delete Mysql Queries


i've try to insert and delete record at the same page, but it only can insert and can't delete the record. when i click submit button from the previous form, the record is insert into table B and delete from the table A. is the code correct? Code:




View Complete Forum Thread with Replies

Related Forum Messages:
Delete Mysql Query NOT USING SUB-SELECT.
I need a DELETE that represent the sql below:

SELECT L.pk FROM t1 L LEFT JOIN t2 F ON F.fk = L.pk WHERE F.fk IS NULL

NOT USING SUB-SELECT.

View Replies !
Delete Expired Queries
I had queries stored in mysql database according to queries
publication date (in format 2007-5-6, 2007-4-30 etc.). However, i
would like to implement automatic expired queries deletion after 6
months. For instance, 2007-4-30 released bulletin will be deleted
after it expired 6 months later. How do I peform this?

View Replies !
Do Queries On XML Similar To The Way That You Do Queries On MYSQL And Then Use The Results.
I am fairly familiar with PHP and MYSQL and I know a little about XML.

I would like to know if it is possible to do queries on XML similar to the
way that you do queries on MYSQL and then use the results.

An example of a simple PHP/MYSQL setup.

<?php
$user="username";
$host="sqlserver";
$password="password";
$database="database";
$connection = mysql_connect($host,$user,$password)
or die ("Couldn't connect to the server");
$db = mysql_select_db($database,$connection)
or die ("Couldn't connect to the server");

$query = "SELECT * FROM database WHERE(Criteria)";
$result = mysql_query($query)
or die ("Couldn't execute query.");

while ($row = mysql_fetch_array($result))
{
extract($row);
echo"Set of instructions to carry out for each row in the
result";
}

?>

The question is, is it possible to do similar things with PHP/XML?
Lets say that I have an XML file located at a certain URL and I want to run
a query on it and use the results.
1. Is it possible?
2. What is the easiest way to do it?
3. How would I translate the above code to work with XML?
4. Is ther resource on the web on how to structure the queries?

View Replies !
SELECT And UPDATE Queries
I have the following code that displays an ad at the top of my webpage. I would like to add an update statement that updates a field in my table for the cooresponding ad whenever the ad is displayed. Code:

View Replies !
Multiple Select Box Search Queries
I am trying to create an elegant query together with a multiple select box, tbl_level linked by a foreign key. Sample code below:

$sql = "SELECT DISTINCT Firstname,.... FROM .... ";

//conditional statement to determine whether WHERE clause is needed
if($_POST["FirstName"] != "" {
$sql .= "WHERE ";
if($_POST["Firstname"] != "") {
$sql .= "Firstname LIKE
"".addslashes($_POST["Firstname"]).""" }

//select box entries array Level

if($_POST["Level"] != ""){
$i=0;$query.="( ";
foreach ($_POST["Level"] as $val{
if ($i >0){$query.= " AND ";}
$query .= "tbl_level.LevelCatID LIKE $val ";
$i=1;}
$query.=" )";
$query.= " AND tbl_name.NameID = tbl_level.NameID"; }
//query database

I can't use this as only a single Level select selection works, if user selects more , I can' t search the Level column for 2nd input from the select box using this. I am trying to avoid too many calls to the database, As I have several multiple select options for user to input for searching.Am trying to call single complex query at the end of code.

View Replies !
Multiple SELECT Queries Combined
I have several SELECT queries on a few of my webpages, and I have been told that the more query connections that are open the slower the server will run.

So firstly, is it possible to merge/combine 2 SELECT queries into a single query? Code:

View Replies !
Select And Display Multiple Queries / Results
Howdy all, i've been looking through various sites / tutorials and through this php book I have here to try figure out whats causing this problem but haven't had any luck yet.

The problem is that its displaying the Designation as the link url instead of the jcode. Hope i explained this well. Above this bit of code has calls the individual Catagorys, if theres data in that catagory it will display it with whats below. PHP Code:

View Replies !
Multiple Queries - Query To Select * From Reviews
My displayreview.php file queries the Reviews table: displayreview.php?id=67 The query here then looks up all the fields for ID 67, simple stuff. My problem is, I wanna do a second query on the Reviews table underneath for related items (say, if there are reviews of the same band/record label.) I want the query to select * from Reviews where, say, Record_Label=$Record_Label (as already defined in the first query), so that the results would display all other reviews for records released on Review 67's record label.

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 !
Select A Row To Delete/modify
Suppose to have read and displayed (using PHP) a group of row of a DB
table on a dinamyc table on a HTML/PHP page.

The number of row displayed could be from 1 to n. Each row contains
informations and also a cell with a unique ID of the element.

I would like to show at the beginning of each line of the table a
couple of cells containing two different icons (one for delete and one
for modify) so the user could click on it to delete/modify the
corresponding row on the DB table.

In other word I need to delete/modify the Dbtable row which have the
ID of the line where the icon was clicked. This means also that when a
icon is clicked I must jump to a PHP routine passing it the ID that
appears on the same line of the icon clicked.

I have seen a similar method of delete/modify on the phpAdmin program,
but I was unable to understand how it work because of the complexity
of that routines.

To achieve my need I can use, if necessary, also Javascript
statements.

View Replies !
Multi Table Insert Delete Select Function Needed.
I am going nuts here and I know with all the functions out there, there must be an easier way to do this. Maybe someone can point me to the right tutorial or even show me how to do this.

I have a $main_id and many $sub_id tables and like to “SELECT to view” INSERT and DELETE those. UPDATE must not be but would be nice.
Here is how it looks:

View Replies !
Have To "actions" Or Run Two Types Of Queries (select,and Update) On The Same Form?
I had a brilliant idea on one of my pages that selects some data from
my mysql database.
I first set the page up to display some info and an image, just one
item, with a row of data, etc.

then I thought it would be nice to do a select, and perhaps an update
(the title of the image) on the same page.

I am wondering if I am having the wrong idea. I have a form, with two
submit buttons, one selects an image, and some info. the other will
update the image title for the given image (id, and p).
I am seeing that I have a mistake here, since it seems the update
query will run as well as when the select query is run (select button
clicked). this overwrites my image titles in the db.

I have the wrong idea, but have not seen how to do this "right". I
could use another php page for update, but I am guessing this can be
done from the same page.

Below is my poor code - i am not an expert programmer!!! any help,
suggestions will be helpful.

<?php

$img = $_REQUEST["img"];
$p = $_REQUEST["p"];

echo '<div class="input">'."".'</div>'
//connection files for mysql
@include 'c:/php/includes/db.inc'
@include 'c:/php/includes/error.inc'
//***@include '/usr/local/php/include/db.inc'
//***@include '/usr/local/php/include/error.inc'
//@require_once '/usr/local/php/include/size_image.php'

View Replies !
Using MySQL Sub Queries In PHP CLI
I am using a sub query like the following in a cron file and its throwing a query error.

...eexpiry = (CURDATE() + INTERVAL (SELECT alert2 FROM settings) DAY)...

Does that mean I cant use sub queries in PHP CLI?

View Replies !
Php/mysql Queries
I finally got my totals to work for this survey, but now the queries are killing the database. With only 14 submissions to the database it takes 10 sec to query the whole thing. 100 survey submissions didn't even load after 5 min. How can I economize my queries? PHP Code:

View Replies !
Mysql Queries
I hope this is not to much to ask for in a post, but any help would be apperciated. my site script uses a template .tpl system similar to smarty... to for each $en[] query i'll be able to post the results below in the html by using <% %>

I attempted to start writing the queries but i think i need to use something like mysql_result(mysql_query("SELECT... for each. Code:

View Replies !
Scheduled Mysql Queries?
How do you schedule a mysql query? Like (half pseudo-code):

mysql_schedule("every five minutes");
$query = mysql_query("SELECT some integer");

$int = mysql_fetch_array($query,MYSQL_NUM);
$int[0] += 10;

mysql_query("INSERT $int")

or something along those lines...I want my users to accumulate "taxes" every turn..even when their not playing..turns will last 5 minutes.

View Replies !
Put MySQL Queries Into Variables
The following query returns 7 codes, how do I put each of them into a
separate variable?

$result = mysql_query("SELECT day_plan FROM calorie_plan WHERE calories
= '$calories'");
if (!$result) {
die('Invalid query: ' . mysql_error());
}
while ($row = mysql_fetch_array ($result))
{
$day_plan = $row['day_plan'];
}

I'm sure I've done this before but I can't remeber how or where.

View Replies !
Dates In MySQL Queries
I am trying to do select all of the records in a table where they data
has not expired.

The table contains two fields Subject (varchar(100)) and ExpiryDate
(Date).

I am getting all of the records returned when I execute:

$sql = "select * from tbl where ExpiryDate > " . date("Y-m-d");
mysql_query($sql);

The expiry date in the record I am looking at is 2004-03-25 and the
query that is being executed is:

select * from tbl where ExpiryDate > 2004-03-28

What am I missing? Can anyone recommend a good site to look at that
discusses dates in MySQL queries?

View Replies !
MySQL Queries On Email?
Is it possible for an SQL query to be activated when an email arrives? Its for a mailing list, so that if someone emails a special address for unsubscribing, it automatically pulls their address' off the mailing list DB?

View Replies !
How Can I Get Rownum Using MySQL Queries ,
How can I get rownum using MySQL queries ,
In Oracle one can you in this way SELECT rownum as srno, fname FROM
tablename
suppose If there are 45 records and if i use while for the

srno should display 1, 2, 3, ... 45

query like SELECT rownum as srno, fname FROM tablename

I dont want to use php counter, i want it from query

View Replies !
PHP + MySQL + Queries That Depend On Each Other?
My doubt is related to PHP and MySQL usage, and it's related to check
if performed queries are performed with success, since we know that:



View Replies !
Relatively Complex Php/mysql Queries
I need to write to 5 related mySQL tables from one form, using php.

First, I need to write some of the data to one of the tables so that I can extract (SELECT) the auto_incrementing primary key to use as a foreign key in the next two INSERTS.

Then I have to extract (SELECT) the auto_incrementing primary key from one of those tables to use as a foreign key in the last tables.

But if I get a failure part way through this operation, I could have a partial write and my data integrity is not just compromised... it's just plain bunged up!

What are some strategies that can be used to prevevnt this from happening?

View Replies !
Mysql Queries Overload?
I need load some fields from a Mysql database, including some text fields, into variables or an array, but I will use them on different pages, for example: "$result[Name]" loads in every page, but "$result[Adress]" will load only in adress.php , questions:

1)is there a way to load the line returned by the query in a array and store it in a page which every one of the others can access?
2)if make a new query every page loaded, will this overload my server since lots of clients can login at the same time?
3) Is there a way to pass the array?

4) Is any of these the best way of doing it? Or anyone have a better idea?
PS: If im gonna pass the variables, I need to pass it in a text link.

View Replies !
Big Amount Of Mysql Queries...
I have good script which works fast, but if i try to push to mysql many queries, i loose about 1000% of speed... my system have about 300-800 select queries and they can't be optimized... can it be here some hidden things too process many queries (select) faster? (no merge or different sql based optimizations... only php)

View Replies !
Secure MySQL Queries
I would like to know if there is any functions I should use on every data entered by a user before making my SQL query to make it secure so the user cannot try to mess with the database? I usually do addslashes sometimes but is there a function that I could use on every variable that I will use in my SQL query that would make it secure in everyway?

View Replies !
Multiple Queries To MySQL
I am querying each column twice; once to see how many people said 'Yes' to that question, and again to see how many people said 'no' to that question. This means a total of 38 queries. Is this the right way to do it or is there a better way? Like just one BIG query? Code:

View Replies !
MySQL Queries And Relevance
I'd like to be able to search for multiple words, and have it return any results in which a certain field contains all or any of those words in any order. So, if I search for "example one" it would return things that contained "one example" and "one other example as well as the exact phrase, or ones that only contain some of the words in the query ("example two").

Ideally, it should also give each result a rank based on how closely they match the query, and list them in order of relevance.

Anyone have any idea how this could be done?

View Replies !
Multiple MySQL Queries
I am trying to select data from two separate MySQL tables, where I cannot use join, but when I put the two select queries into a single query, I get an error telling me to check my syntax. Both of the queries work fine when I use them to query the MySQL server directly.

My guess is that the MySQL extension only expects a single resource back from the database, but get's several, or that it just checks the statement first, and decides it's not valid. However, my guesses and/or assumptions don't really make much of a difference as to the workings of the PHP MySQL extension. Would anyone know if there is something I can do to get around this problem?

View Replies !
Speed Up Mysql Queries?
I have a database with well over 350,000 records and was wondering if there was anything i can do to speed up how it reads from the database. i cannot remove any of these tables.
here is how i read from the database now. Code:

View Replies !
Optimizing Mysql Queries
have a feeling that this isn't very optimal. Is there a way where you can put all these mysql queries into one or more fewer than this? This way works great, though a bit too much queries.

$querytotal = mysql_query("SELECT id FROM $db WHERE date_pub='$week' AND visible=&#390;'"); .......

View Replies !
MySql Caching Queries
I would like such that once any unique query has been executed, it should be cached and should display quickly next time the same query is called unless the mysql table which is being accessed is updated or its timestamp changes.

Is this possible or there are better caching/speed improvements available?

View Replies !
Safe MySQL Queries
After realising how easy it is for a malicious user to inject an sql query
into a paramenter for a query, e.g:

$query = "SELECT name FROM employees WHERE ID = ".$HTTP_GET_VARS['id']

And the user enters for the query string: mypage.php?id=1 UNION DISTINCT....

I'm trying to work out what level of protection is needed. As far as I can
see, for integer values I should just validate that a numeral has been
entered, and for text the addslashes() or mysql_escape_string() functions
are enough. Am I right in saying this?

View Replies !
An (OR) Operator For MySQL Queries
I've used one before but can't remember what it was, say for example I need to SELECT 2 different specific values from the same field. something like:

$query = "SELECT * FROM table1 WHERE field1 = 'dog' OR field1 = 'cat' LIMIT 0,100";

of course the above statement will return an error but you get the idea of what I am trying to do. I haven't been able to figure it out yet.

View Replies !
MySql Last Month Queries
I have to manually change the dati in the php file every month, for it to work.

My current syntax:

$sql_3="SELECT COUNT(distinct person_id) from request_rights where register_date < &#392007;-08-01 00:00:00'";

$select_3 = mysql_query($sql_3) or die("Nevar pieslçgties DB!");
$select_3_rez = mysql_fetch_array($select_3);

View Replies !
Standard Mysql Queries
I'm familiar with standard mysql queries. but his one is a little advanced for me. can so one decipher it.

"SELECT o.*, u.username FROM myauction o, myauction_users u WHERE blah blah blah blah blah...

View Replies !
Using Mysql Queries With Functions
I am using a a class with the following function to gain the only sql result i need to use with 4 other functions. I am trying to avoid writing the same query over and over.

function SQL($result){
$sql = "SELECT gametype, name, choice, comments FROM sportd ORDER BY id_num DESC";
$result = mysql_query($sql);
return $result;
}

I am able to echo the number of rows in the result to other functions but not any of the result variables.

My question is, How can i take the function above, and use the $result var in other functions?

View Replies !
Skipping Mysql Queries
I have a mysql query that tracks traffic to my site and if the query takes too long then the page simply fails to load. If I put this on the bottom of the page the page loads but I get the headers already sent error message. Is there a way I can skip a query if it takes over, say 2 seconds to finish?

View Replies !
Mysql Queries And Activity
I am going through and optimizing my code. I would like to get a nice "before and after" picture of how many fewer queries and general activity I have after I am done optimizing. I'm sure it could be done on the server end but is there any way for me to tell on the user end when I only have access to cpanel X?

View Replies !
Construct MySQL Queries
I am having trouble with MySQL and PHP. I want to do neat stuff in PHP but I have trouble generating commands and stuff. I was wondering if there is any visual tool that can help me contruct PHP and MySQL codes.

View Replies !
1000s Of MySQL Queries
I am trying to execute arounf 1500 MySQL queries using the same script:

[php]
<?php // Line 1
mysql_connect(..., ..., ...);
mysql_select_db(...);
mysql_query("INSERT INTO..........");
mysql_query("INSERT INTO.........."); //Line 6
etc
?>

I am getting this error:

Parse error: syntax error, unexpected T_STRING in /home/isaac/public_html/thepeccavi/bsc/pupils/sql.php on line 6Isaac

View Replies !
PHP/MySQL - Effiecient Way (low CPU, Fewest Queries)
Suppose you have a database with a Date column (format: YYYY-MM-DD)that has an entry for many days, spanning several years. Maybe sometimes entire weeks or even entire months are skipped, but there are lots of entries.

*********************
* myDate * myEntry *
*********************
2001-02-22 asdasdas
2001-02-28 ssdsdwww
2001-03-10 dfgdfgdf
...
2005-06-03 sdfsdfdg

What is the most effiecient way (low CPU, fewest queries) to extract each month and year that contains at least one entry? Sort of like the archive list in blogspot.

View Replies !
Dynamically Generate MySQL Queries
what I expect will be a
reasonably simple question.

I have an html form (which is generated in php) which contains a
number of rows (one row per product in the 'products' table).

It is generated with the following php

<code>
// create a table for the results
echo('<table border=1 cellpadding=2>');
echo('<tr> <th>Product Description</th><th>Sales $</th><th>Sales
Units</th><th>Credits $</th><th>Credits Units</th> </tr>');

// add the results to the table
while ( $row = mysql_fetch_array($result) ) {
// get columns from the output on the current row
$ProdDesc = $row['ProductDescription'];
$ProdID = $row['ID'];
// write content collected above into table cells
echo('<tr><td>');
echo($ProdDesc);
echo('</td><td>');
echo('<form action="update-db.php" method="post"><input type="text"
name="sd');
echo($ProdID);
echo('">');
echo('</td><td>');
echo('<form action="update-db.php" method="post"><input type="text"
name="su');
echo($ProdID);
echo('">');
echo('</td><td>');
echo('<form action="update-db.php" method="post"><input type="text"
name="cd');
echo($ProdID);
echo('">');
echo('</td><td>');
echo('<form action="update-db.php" method="post"><input type="text"
name="cu');
echo($ProdID);
echo('">');
echo('</td></tr>');
}
echo('</table>');
//the table is complete
</code>

The values sd1, su1, cd1, cu1,...... cuXX are all available to the
update-db.php page which is called when this form is submitted so I am
fairly sure this is working correctly.

So far, so good, but when it comes to inserting the data into the
database I have not been able to create the SQL dynamically (in
testing I know the number of products and have manually written lots
of SQL INSERTs but this will not work in the real world)

The SQL needs to look like roughly like this:
mysql_query ("INSERT INTO sales_dollars (SaleID, ProductID,
WeekCommencing, Sales, Credits) VALUES ('',
'$prodID','$WeekCommencing','$sd1', '$cd1')");

My logic was to say something like this (which needless to say doesn't
work !)
<?php

for ($prodID = 1; $prodID <= $prodCount; $prodID++)
{
$currentSD = "sd" . $prodID
$currentSU = "su" . $prodID
$currentCD = "cd" . $prodID
$currentCU = "cu" . $prodID

mysql_query ("INSERT INTO sales_dollars (SaleID, ProductID,
WeekCommencing, Sales, Credits) VALUES ('',
'$prodID','$WeekCommencing','$currentSD', '$currentCD')");
}

I may have messed up the for loop here but the real problem was that
query would insert '$sd1', '$sd2' etc as text strings into the
database rather than evaluating $sd1 to it's value (passed from the
original table which would be a number)

I have tried using eval() with no success (though that may well be due
to my complete newbieness with php). I have also tried passing the
values from the original html as arrays and trying to use simillar
logic as above to read from $array[$currentArrayElement] also with no
success. Again, if I manually echo the results of $array[0] I am
returned the value entered in the first html field but I can not
dynamically select the next array element.

I hope I have made sense of the problem without writing unnecessary
garbage.

View Replies !
Executing Multiple SQL Queries (MySQL)
I am writing an install script, which needs to build the tables and insert specific records for the application. There are about 50 or so queries. (format exported via phpMyAdmin) I've got all these queries in a file - how do I go about running them all individually?

Clause - I can't simply use file() and do each like that. The SQL statement for the tables is in a multiline format, like this: Quote:

CREATE TABLE `categories` (
`ID` int(11) NOT NULL auto_increment,
`parentID` int(11) NOT NULL default &#390;',
`name` text NOT NULL,
`description` text NOT NULL,
`filename` text NOT NULL,
PRIMARY KEY (`ID`),
UNIQUE KEY `ID` (`ID`)
) TYPE=MyISAM;

View Replies !
Optimise Two Mysql Queries To One Query
$a = mysql_query("Select a,b FROM t WHERE category=1")
while($a) {
$x = $a[a];
//some echo
//another query

$b = mysql_query("Select * FROM t WHERE subcategory=$x")
while ($b) {
//some echo
}
}

Point is that I have menus, parents with childes (childes are not
parents) and I want to display them using only one query.

- Parent 1
-- Child 1
-- Child 2
- Patent 2
-- Child 3

View Replies !
Simplify/Reduce Mysql Queries
Anyway to simplify/reduce the amount of queries I use here (they will get loaded on every page by hundreds of users simultaneously)? It's an IP system Im building to record the IP's of my users. If working correctly, it should add a new entry each time their IP changes, and keep up to 10 records of IP changes. Code:

View Replies !
1000-10000 Mysql Queries
there is one PHP file (cronjob.php), which will update mysql database every 24 hours. Script will always do 6 required sql queries and 3 additional queries for every user in the database. But what if my site has 1000 or even 10000 users? Will server break?Queries data contains only number, no long text or etc. So, if 3-30k mysql queries for server at one time is too much, what to do then?

View Replies !
UNIQUE Or DISTINCT MySQL/PHP Queries
I have a product database (provided by a partner site) which has 10,000+ items. These items are identified by a unique ID number, which in this case is the manufacturers' product items.

To do away with EXTENSIVE "massaging" of the data, I am "dumping" the raw text-delimited data into our MySQL database, in its own unique table. I query the database to display different types of items, and want to do it MORE EFFICIENTLY than the structure of the data allows. Code:

View Replies !
Listbox And Multiple Php/mysql Queries
i've run into a bit of a problem which i can't seem to solve. Basically i'm making a forum and i'm working on a section that enables you to view information about the other users signed up the forum in one big table.

I have 6 columns and a listbox that enables you to sort the data regarding the selected item chosen (ie. if postcount is chosen the table will be sorted by post count) Anyway, here's my code for the listbox: Code:

View Replies !
Using Session Variables In Mysql Queries
My php code consists of getting a person's session_id() and placing that in a session variable for use in other pages.

The thing is, though, that when i place a session variable in a mysql query, i get the following error:

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/e/r/i/ericjacobson01/html/index.php on line 11

This is the part that php complains about:

$_SESSION['buyer_id'] = session_id();

$istableset = mysql_query("SELECT * FROM ' .$_SESSION['buyer_id'] '");

View Replies !
Case Insensitive MySQL Queries
I've been having a lot of trouble with just the tiny bit of following code:
$strNewEmail = strtoupper($strNewEmail);

Code:

View Replies !
Formatting MySQL Queries Like MyAdmin
Does anyone know of a function that will format a MySQL query to appear like PHPMyAdmin shows them when display the query? This would make analyzing results visually to be much easier.

View Replies !
Mysql Sort Multiple Queries
I have a table called registration and a table called apppost. When I run the following code below, both queries print and match fine on the same page (like I want it to).

However, when I do a sort (i.e. - http://www.example.com/folder/phpfile.php?sort=status) I get a warning that the mysql_fetch_array($result2) supplied argument is not a valid MySQL result resource. The data from the first query ($result) still displays correctly, but the data from the second query ($result2) doesn't display at all. Code:

View Replies !

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