One assignment for each field:
UPDATE table1 SET at_bats = at_bats + $at_bats, hits = hits + $hits WHERE user_id = $id;
One assignment for each field:
UPDATE table1 SET at_bats = at_bats + $at_bats, hits = hits + $hits WHERE user_id = $id;
It's not us who are confused ;-)
You can put your php script to sleep for one day (see the sleep function) and let it run unterminated. Or you can use PHP from the command line as a script language and call it from a cronjob.
I'd recommend you use wget and grep from the command line to retrieve the site's source code, grep for the string and write the result to a text log file. Then you can load the log file later into a database for statistical evaluation and further processing.
There are numerous ways. For example, you can use the mysql_field_name() function. Or you can alter your script. In the loop, do
foreach($show as $key => $value)
echo "$key: $value\t";
echo "\n";
Use preg_replace() to match and format the values supplied by users.
Strip the phone numbers of any non-numeric characters first. Apply
$number = preg_replace( '/[^0-9]/', '', $number );
$number = preg_replace( '/([0-9]{3})([0-9]{3})([0-9]{4})/', '($1) $2-$3', $number );
Likewise for the domain.
Before you move on to the next problem, mark this thread as solved.
Without having understood the details of your problem, I see that it cannot work: your LEFT JOIN clause does not contain any comparison:
FROM prod_contacts.cms_contacts
LEFT JOIN prod_contacts.cms_table_packholder ON cms_contacts.packholder
should probably read
FROM prod_contacts
LEFT JOIN cms_contacts ON cms_contacts.packholder = prod_contacts.packholder
Where is the problem?
You dynamic PHP page displays the database content.
When the user submits new stats, store it to the database first place in your script. Then load the data from the database and display the current database content - including the newly submitted data - in the same script.
I suggest you do some basic research of relational database design and learn the notions of 1:n and m:n relations.
Download an open source shop system (like OSCommerce or the like) and study their database setup.
A lookup table is a table with key-value pairs. In your item table you have a field which contains the key, in the lookup table you have some text string associated with it. You could also use the mysql enum type for that purpose, but that's not so easy to maintain as a separate table.
With proper database design you find the number of items per invoice with a query which selects all item positions for a given invoice number from the invoice details table.
For further help, show us the CREATE TABLE statements or some ERM or other design code which you have done already.
1. Add a field "size" to the product table and add a lookup table "sizes" for this field.
2. The standard layout is one table for the invoice and one table for the invoice positions (items) which are linked to the invoice table.
I do not understand. What does not work? My query returns the sum of all pop values for each single blkidfp00 value - which is 2333 in your example.
Which result do you expect from this test case? Replace 'Adams' by your '$county' $_GET variable, and there you are. Or aren't you?
drop table if exists wi_allbcdata;
create table wi_allbcdata
(id integer,
blkidfp00 char(30),
countyname char(30),
servicetype integer,
pop integer
);
insert into wi_allbcdata values
('1','55001950100100','Adams','10','1980'),
('2','55001950100100','Adams','20','1980'),
('3','55001950100100','Adams','30','1980'),
('4','55001950100101','Adams','10','353'),
('5','55001950100101','Adams','20','353'),
('6','55001950100101','Adams','30','353');
SELECT blkidfp00, pop FROM wi_allbcdata b WHERE b.countyname='Adams' GROUP BY blkidfp00;
+----------------+------+
| blkidfp00 | pop |
+----------------+------+
| 55001950100100 | 1980 |
| 55001950100101 | 353 |
+----------------+------+
select sum(c.pop) from (SELECT pop FROM wi_allbcdata b WHERE b.countyname='Adams' GROUP BY blkidfp00) c;
+------------+
| sum(c.pop) |
+------------+
| 2333 |
+------------+
select sum(c.pop) from (SELECT pop FROM wi_allbcdata b WHERE b.countyname='Adams' GROUP BY blkidfp00) c;
You do not get a PHP error, but a notice.
To avoid it, change
$act = $_GET['act']; //retrives the page action
to
if (isset($_GET['act'])) $act = $_GET['act']; //retrieves the page action
I am not sure if the PHP error notice appears before the header is sent to the browser. If this is the case, the header cannot be processed any more. So first try to get rid of the PHP notice. (You can also use the PHP error_reporting() statement. Look it up in the manual.)
Use the id attribute in Javascript and the name attribute in the PHP form processing.
For processing it is irrelevant if you have a submit button or a javascript function calling form.submit().
Replace "Replay" by "Reply". Replace "\n" by "\r\n". Add a "\r\n" to the first header to separate it from the second.
$headers = "From: mywebsite.ca\r\nReply-To: Do Not Reply\r\nX-Mailer: PHP/" . phpversion();
$headers .= "\r\nContent-type: text/html; charset=iso-8859-1";
Then try again.
I suggest you use something like pritaeas' expression in a BEFORE INSERT trigger and store it in a invoice_number field. Instead of using the count(*) function I'd rather check for the highest number in this month and store it in a separate field. In your trigger BEFORE INSERT:
SET new.invoice_number = 0 + (SELECT max(invoice_number FROM bills WHERE YEAR(timestamp) = YEAR(NOW()) AND MONTH(timestamp) = MONTH(NOW()))
Please mark this thread as solved.
I don't know wordpress but I would assume they use date type fields for dates. In that case you have to format your input date accordingly:
SELECT * FROM 'wp_posts' WHERE 'post_date' < '2010-10-31';
Still better, put the whole HTML code within PHP tags. It's much easier to read and to maintain.
<?php
for ($i = 0; $i <= 10; $i++)
{
echo "
<tr>
<td>
<input name='rate$i' id='rate$i' type='text' onkeyup='integeronly(this)' >
</td>
<td>
<input name='qty$i' id='qty$i' type='text' onkeyup='integeronly(this)' >
</td>
<td>
<input name='amt$i' id='amt$i' type='text' readonly='readonly'>
</td>
</tr>"
;
}
?>
In the processing script, walk through the $_POST array and check which item of ckbox has a value assigned. Test it:
<form method='post'>
<input type='checkbox' name='cb[]' value='a'>
<input type='checkbox' name='cb[]' value='b'>
<input type='submit' value='submit'>
</form>
<?php
print_r( $_POST );
?>
Use radio buttons. That's what they are for: selection of one of multiple values.
array_unique() keeps the indexes intact. If not specified otherwise, these are ascending integers.
Try this instead:
$pid = array_unique($pids);
foreach( $pid as $key => $value )
echo "$key: $value<br/>";
Both in Linux and in Windows you can have filenames containing @, so that should not be the reason. It's rather the upload module which does some replacement operations on the filenames.
Grep all your source code and a database dump of your development database for the Æ’ character. Make sure that the browser recognizes the correct character set (encoding).
You do not have to remove the ' but to escape it. Precede it with a backslash.
See http://php.net/manual/de/function.mysql-real-escape-string.php
To the best of my knowledge MySQL does not have macro or eval capabilities. This means that there is no built-in parser which can evaluate a string expression as program code. You will have to supply this parser yourself.
I'd recommend you write a function named "convert" or the like which parses the ToMetrics and ToEnglish field and returns the calculation result.
The alternative is to hard-code the calculation into the query and to keep the ToEnglish and ToMetric fields as reference only, not used in the actual calculation, like you do in your code.
You can actually use the CASE construct directly as a calculated field, much like you did already:
Select
vitalsigns.DisplayShort,
vitalsigns.ToEnglish,
xrefvitalsigns.Value,
xrefvitalsigns.TypeME,
CASE
WHEN vitalsigns.DisplayShort='Temp' And xrefvitalsigns.TypeMe='M'
Then ((xrefvitalsigns.Value/0.556)+32)
WHEN vitalsigns.DisplayShort='WtH' AND xrefvitalsigns.TypeMe='M'
THEN (xrefvitalsigns.Value*2.2)
END AS VALUE
From xrefvitalsigns INNER JOIN vitalsigns
ON xrefvitalsigns.vitalsignID=vitalsigns.ID;
Please mark this thread as solved.
If propertylisting_details.php?recordID=nnn works, but your generated links do not, there must be an error in generating them. How does the HTML source code of these links look in the generated page?
It is a bad idea to have structurally identical tables created at runtime. What for? Put all the info in one table.
If you still want to do it that way, set correct quotes in your query. Within single quotes PHP will not replacement variables, with double quotes it will. Change your query to
mysql_query('CREATE table praveen' . $_POST['id'] . '(id int, amount varchar(10), DTMY text(30))');
}
What exactly is your problem?
Does propertylisting_details.php?recordID=nnn work? (Replace nnn with any valid record number.)
Does $row_rs_search contain a value?
Show the code in propertylisting_details.php where you query the database.
Maybe you want SHOW CREATE TABLE which retrieves the table definition. From this you can extract all your enum (set) fields.
Please mark this thread as solved.
Each checkbox needs a unique name by which it is identified in the $_POST array. If all checkboxes have the name "checkbox", you will only get the value of one of them.
Replace = by == in your comparison statements.
Don't post irrelevant code.
Try to pinpoint your problem.
Replace all include() by require_once().
// ardav, you out there? I was here already...
if($problem == "solved"){
clickLink("mark_as_solved");
}
Your code has one superfluous loop which you did not notice because of a second error.
<?
$db_name="mydb";
trim($searchterm);
if (!$_GET["searchterm"])
{
echo "You haven't entered any word to search.Please, go back and entered it.";
exit;
}
$searchterm = addslashes($searchterm);
require("dict.php");
if (!$db)
{
echo "Error. Can't connect to database.Please try later";
}
mysql_select_db($db_name);
$query = "select * from words where englishword like '".$_GET["searchterm"]."%' order by englishword";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
if (!$num_results) die( 'No matches found.');
echo"<table width = '434' border='0'>";
/* for ($i=0; $i <$num_results; $i++) this is an unnecessary loop */
while($data = mysql_fetch_array($result))
{
echo "<tr align='left'>";
echo "<th>";
echo "<span class ='font'>";
echo "{$data['englishword']}";
echo "</span>";
echo "</th>";
echo "<th align='left'>";
echo "<a href=\"/dict/audio_en/{$data['englishword']}.mp3\" target='new' class='popup-link' title=\"open the audio file for the word {$data['englishword']} \" >
<img src='/images/audio.gif' alt = open the audio file for the word {$data['englishword']} ></a> <a href=\"http://en.wiktionary.org/wiki/{$data['englishword']}\" target='new' class='popup-link' title=\"Search this word in Free Wiki Dictionary{$data['englishword']} \" ><img src='/images/wiki.png' alt = Search this word in Free Wiki Dictionary {$data['englishword']} ></a>";
echo "</th>";
echo "</tr>";
echo "<tr>";
echo "<td>";
echo " ";
echo "</td>";
echo "<td align='left'>";
echo "<span class ='font'>";
echo (stripslashes($data["Zword"]));
echo "</span>";
echo "<td>";
echo "</tr>";
}
echo "</table>";
mysql_close($db);
?>
You can add a field for table linking, 4 characters wide, which is fed by a trigger on insert and update. On each update you set it to substr(cc.notes,1,4). Then you can link the tables directly on those fields.
This error message says it plainly enough. You cannot use LEFT on TEXT fields.
By the way, I think it's also bad practice to join on substrings. You cannot have a foreign key constraint on those expressions, which means that your database is potentially corruptible by invalid data.
Sorry, my mistake - a reading error.
Your error would have to be at the bracket of the last inner join. Drop the outermost brackets of line 5.
Do you want to know the name of the Mumbai person of maximum age? Then you have to group by age, select the maximum of it and find a person of that same age:
select name from man m1 where m1.city = 'Mumbai' and m1.age = (select max(m2.age) from man m2);
Or do you want to find the oldest person in Mumbai?
select name from man m1 where m1.city = 'Mumbai' and m1.age = (select max(m2.age) from man m2 where m2.city = 'Mumbai');
The ON clause is missing after the first INNER JOIN clause.
What is the second part? And did you ever consult a manual?
Maybe you forgot to initialize the session with session_start().
And instead of line 3 it shoud read
$row = mysql_fetch_row( $r );
Create one table for users, one table for salaries, and join them on the user ID.
create table users
( id integer not null primary key auto_increment
, name text
, email text
, phone text
, address text
);
create table salaries
( id integer not null primary key auto_increment
, id_user integer not null
, year integer not null
, month integer not null
, salary float not null
, foreign key (id_user) references users (id)
);
It's utterly nonsense to create a table for each new user.
drop table if exists calculation;
create table calculation (one float, two float, sign enum('+','-','*','/'),answer float);
insert into calculation (one,two,sign) values (1,2,'+'),(1,2,'-'),(1,2,'*');
UPDATE calculation SET answer =
CASE sign
WHEN '+' THEN one+two
WHEN '-' THEN one-two
WHEN '*' THEN one*two
ELSE answer=one/two
END
;
+-----+-----+------+--------+
| one | two | sign | answer |
+-----+-----+------+--------+
| 1 | 2 | + | 3 |
| 1 | 2 | - | -1 |
| 1 | 2 | * | 2 |
+-----+-----+------+--------+
Beware of "0" values in column two.
And what would be the use of calculated values in a table?
Filter the "." before you insert it. You can replace the period by applying replace():
INSERT INTO mytable myvalue VALUES (replace('1.000','.',''));
Add "FIRST" after the column name.
http://dev.mysql.com/doc/refman/5.1/de/alter-table.html
ALTER TABLE mytable ADD COLUMN xyz(text) FIRST;
You can delete all your mysql data by deleting the "data" directory in \xampp\mysql (at least that's the path in my installation). The access restrictions are stored in a database named mysql, so when you delete and re-install it you should be back on square 1.
This has nothing to do with any windows administrator privileges - mysql maintains its completely independent access restriction system.
The problem is that both views contain the same column names for the same tables.
While the mysql command line interface handles this quite gracefully, the PHP interface identifies columns by column names only, without the table prefix. Therefore the player.* columns from view1 are merged with or overwritten by the player.* columns of view2.
This query illustrates the problem:
select view1.surname,view2.surname from view1 left join view2 on view1.player_id=view2.player_id;
You can overcome this problem by explicity assigning alias names to the columns which you want to pull.
select view1.player_id as theRealId, view1.surname as theRealSurname, view1.*, view2.* from view1 left join view2 on view1.player_id=view2.player_id;
Now you can refer to column theRealId and theRealSurname in your PHP query processing.