smantscheff 265 Veteran Poster
jlego commented: completely forgot about unions +0
ptara1 commented: solved the problem +1
Don't leave us guessing. If the code is not correct, what's the error message or the unsuspected behaviour?
Do you really have a table named "users"?
If users and section are text/char fields, their value have to be enclosed by quotes in the WHERE clauses (which is good practice anyway):
$users = mysql_query("SELECT * FROM ".$tbl_name2." WHERE users ='".$username."'");
mysql_query("UPDATE ".$tbl_name3." SET Status = 'Complete' WHERE section='".$section."'");
Try to state your problem and show the relevant parts of your code instead of posting all your code and leaving us to find out what you are looking for.
SHOW CREATE TABLE mytable;
Restart the mysql server.
Please mark this thread as solved.
There is nothing in the IT world which happens automatically.
To make the /contact link work, you'll first have to install the modification from my previous post.
The code is working. Try http://kbrlifestyles.com/bootcamp.html
Now you will have to modify it to suit your needs. Start with
RewriteRule ^([a-z0-9]+)(.htm(l)?)?$ index.php?p=$1 [L]
Both sites have the same setup (LAMP), and the website scripts are controlled by SVN (or another version control tool) so that they can easily be updated. The content is in the database of which there is only one.
What do you mean with "is not working"?
Your rule RewriteCond %{REQUEST_FILENAME}.php -f
requests that for a request like /abc
the file named /abc.php
exists. Is that what you want?
Your last rule will never catch anything in its second pair of brackets. In RewriteRule ^(.*)(/?)$ index.php?p=$1 [L]
the first bracket pair catches all content.
1) www.netuse.de. I don't know if they have an english interface, but they have a support which does it's job.
2) How much traffic will the users generate? In general, I'd say: it doesn't matter. The standard shared machine which you can rent for a few bucks will do the job with ease.
Start with a small box. If traffic grows, move database and server to two different small machines. If it still grows, add another web server and a load balancer. If it still grows, move your (mysql) database to a cluster.
Try this:
create view view1 as
SELECT *,
COUNT(CASE WHEN games.competition = 1 AND appearances.type = 1 THEN 1 ELSE NULL END) AS lgest,
COUNT(CASE WHEN games.competition = 1 AND appearances.type = 2 THEN 1 ELSE NULL END) AS lgesub,
COUNT(CASE WHEN games.competition = 1 AND appearances.type = 3 THEN 1 ELSE NULL END) AS lgebench,
COUNT(CASE WHEN games.competition = 2 AND appearances.type = 1 THEN 1 ELSE NULL END) AS facst,
COUNT(CASE WHEN games.competition = 2 AND appearances.type = 2 THEN 1 ELSE NULL END) AS facsub,
COUNT(CASE WHEN games.competition = 2 AND appearances.type = 3 THEN 1 ELSE NULL END) AS facbench,
COUNT(CASE WHEN games.competition = 3 AND appearances.type = 1 THEN 1 ELSE NULL END) AS fatst,
COUNT(CASE WHEN games.competition = 3 AND appearances.type = 2 THEN 1 ELSE NULL END) AS fatsub,
COUNT(CASE WHEN games.competition = 3 AND appearances.type = 3 THEN 1 ELSE NULL END) AS fatbench,
COUNT(CASE WHEN games.competition = 4 AND appearances.type = 1 THEN 1 ELSE NULL END) AS kscst,
COUNT(CASE WHEN games.competition = 4 AND appearances.type = 2 THEN 1 ELSE NULL END) AS kscsub,
COUNT(CASE WHEN games.competition = 4 AND appearances.type = 3 THEN 1 ELSE NULL END) AS kscbench,
COUNT(CASE WHEN games.competition = 5 AND appearances.type = 1 THEN 1 ELSE NULL END) AS lcst,
COUNT(CASE WHEN games.competition = 5 AND appearances.type = 2 THEN 1 ELSE NULL END) AS lcsub,
COUNT(CASE WHEN games.competition = 5 AND appearances.type = 3 THEN 1 ELSE NULL END) AS lcbench,
COUNT(CASE …
Do your checking in the same script as the form display. Set your form action to "myformscript.php#contact" and relocate the user only after the form has successfully been submitted.
A better practice would be to first send a test mail to the mail server directly from the PHP script with an SMTP protocol emulation. So you can check if the entered address is valid and known. Otherwise you might lose visitors who erroneously enter a wrong email address and never receive their confirmation link.
If the address is valid, you will still need the confirmation mechanism to protect yourself against spammers.
Intermedia result: switch the table sequence in your join clauses from
FROM goals, games INNER JOIN players
to
FROM games, goals INNER JOIN players
and likewise
FROM appearances, games INNER JOIN players
to
FROM games, appearances INNER JOIN players
to get the query to run (on mysql 5.1.41-3ubuntu12.6).
But the queries have empty results. The players table is missing in your dump file. So I have to take back my "kudos" - test case not complete.
You could create views from both queries and join them on the player_id - or couldn't you?
Put the image file name in quotes: "CClogo.jpg"
Make sure that the upper/lowercase spelling of the filename is correct.
Make sure that picscript1.php does not output any characters after the image data. It's good practice to delete the closing ?> php bracket from scripts which do not output HTML.
You can, if you assign the variables first. And for readablity I think it's easier to integrate the variables in the string (at least if you're using a decent PHP editor with syntax highlighting).
$name = $result['name'];
$bio = $result['bio'];
Print "<tr><td class='ParaText' align='left' valign='top'>name</td><td class='ParaText'>$name</td><td class='ParaText' align='left' valign='top'>$bio</td></tr>";
Your delete syntax is flawed. You're not supposed to use field names in DELETE statements. Try without.
%U is a formatting parameter for the date_format function which displays the week of the input date.
To match only the current week use
WHERE WEEK(somedatefield) = week(now())
Use the "week" modificators for grouping on your date field.
SELECT * FROM mytable group by date_format(mydate,'%U') as week
Please check your data integrity by switching to InnoDB before further probing the problem.
Without taking a closer look, there is at least one thing fishy: Your tables are defined as MyISAM but use foreign keys. Foreign keys are meaningless in MySQL unless you use InnoDB tables. Therefore it might well be that your data are corrupted (violating relational integrity).
Show your CREATE TABLE statements and your code block.
An interesting problem. I cannot get it to work, though, because MySQL keeps telling me
"ERROR 1054 : Unknown column 'scorer' in 'on clause"
Does anyone else have this problem, too? And maybe a solution?
And kudos for Steve for supplying a complete test case as a starting point.
Please mark this thread as solved.
The query is running on the server and not consuming bandwidth. Bandwidth is consumed by the query results, if they are transmitted as a whole.
They did it with some javascript functionality which you can find here: http://www.paid-surveys-at-home.com/maxheight.js
You are confusing a lot of terms.
You don't insert data into a form, you set instead the values of some form input elements.
Your "original" is not a form element, but a hyperlink. What do you want to change it to?
Do you want a change in the "original" without reloading it? Then you'd have to use JavaScript.
Yes, that's the way to do it.
You could enhance the statement with ON UPDATE and ON DELETE clauses, but with your standard plain vanilla version you are on the safe side so that you cannot delete entries from the lookup tables which are still in use.
You do not "insert" a value into a form. A form is an HTML structure which is delivered to the browser. You build it using HTML and PHP. You use PHP for setting the dynamic parts of the form, in this case the "value" attribute.
Like in <form action="POST"><input type='text' name='ZipCat' value='<?php echo $_GET['ZipCat'];?>'/></form>
Do you mean: how can you attribute values to form elements before the form is delivered to the user?
Basically, your hyperlink should contain the ZipCat element as a get parameter to the php script which contains the form. Example:
Change echo "<td>" . $row['ZipCat'] . "</td>";
to echo "<td><a href='myscript.php?Zipcat=" . $row['ZipCat'] . "'>" . $row['ZipCat'] . "</td>";
and in myscript.php use the value of $_GET to fill a form field: echo "<input type='text' name='ZipCat' value='" . $_GET['ZipCat'] . "'/>";
You can do that with a union query (I'm ad-libbing table and field names here):
select state as location from states where state like "%AR%"
union
(
select concat(city,', ',state) as location
from cities join states
where cities.state_id=states.state_id and city like"%AR%" or state like "%AR%"
)
As for names, I wouldn't call a table tbl_... From the syntactical context it is quite clear where a table or view and where a column is being referred to. And a database is not only a means of storing data, but also a means of communication - between you and yourself in half a year when you have to modify your code.
Make sure that your cigar table has foreign keys into the lookup tables.
Add further LEFT JOINs to pritaeas' sample query to integrate the other cigar attributes into your query.
You have one form in your HTML and then some input elements outside of the form. They are never sent.
For me, the easiest way to transform POST data in a mail text is a post array walk:
foreach( $_POST as $key => $value )
$message .= "$key: $value\n";
mail($to, $subject, $message );
Sou you want to match one, two or more keywords to various fields in the database.
I recommend a regular expression search over a concatenation of fields.
Example:
select * from table1 join table2 on table1.id=table2.id
where concat(table1.field1, ' ', table1.field2, ' ', table2.field1) rlike "(keyword1|keyword2)"
I want all the states to show up in the suggestions whether we have jobs in the state or not. Hopefully, that makes sense.
No it doesn't. Why would you show states for which you don't have jobs? To make the user believe that you have a large database?
To show states regardless of their presence in the job table you can combine state and town names in a union query in which you pull all towns with states from the job table and all states which are not linked to the job table from the states table.
Your code table seem to me like a unstructured mass of text strings with codes attached. Each of the lookup tables refers to only one field in one table and makes sure that only certain values may be entered. You could have a similar effect by enum fields which list all allowed content strings, but they are not so easy to maintain as lookup tables.
Please mark this thread as solved.
In the long run it pays to have your data as structured and un-redundant as possible. So I support pritaeas' advice to use lookup tables for coded values.
Regarding efficiency and performance, with properly set indexes you will not notice any difference if you use text strings or code numbers - at least not if your row count stays below a million or so. Therefore it might be easier to store each string explicitly, but with a foreign key reference pointing to a lookup table so that you cannot store 'uncontrolled' string values.
Please mark the thread as solved.
Change if(preg_match("/^[ a-zA-Z]+/", $_POST['search'])
to if(preg_match("/^[ a-zA-Z0-9]+/", $_POST['search'])
Please show the "CREATE TABLE Users" statement.
And for debugging change
$result = mysql_query($query);
to
$result = mysql_query($query) or die(mysql_error());
These are four different queries. If you use prepared statements, each needs its own statement.
You are confusing file names and page titles.
The page title which a browser shows is stored in the html <title> element.
You can redirect file names in the apache webserver using the redirect module (ModRewrite). If the redirect engine is installed and active and redirection is allowed for your .htaccess file and directory, then you can use .htaccess to redefine file names. Example:
RewriteEngine On
RewriteRule test1 page.php?id=1
RewriteRule test2 page.php?id=2
or more generally RewriteRule test([0-9]+) page.php?id=$1
Where do you look for keywords? In one table column or in several? In one table or in several? Why do you have to swap the keywords? Would the result be different for "porter harry" and for "harry porter"?
It would be easier for us to help you if you would clearly state your problem.
Set the connection character set to utf-8, too.
mysql_query("SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'");
or
mysql_set_charset( "utf-8" );
Whether a post is a reply is implicit in the data and should therefore not explicitly be stored. The first post of a thread is the topic, the others not.
When you store all posts in one table, you can sort them like this:
drop table if exists posts;
create table posts (id integer, id_topic integer, timestamp integer);
insert into posts values (1,1,1),(2,2,2),(3,3,3),(4,3,4),(5,3,5), (7,1,7);
select * from posts;
+----+----------+-----------+
| id | id_topic | timestamp |
+----+----------+-----------+
| 1 | 1 | 1 |
| 2 | 2 | 2 |
| 3 | 3 | 3 |
| 4 | 3 | 4 |
| 5 | 3 | 5 |
| 7 | 1 | 7 |
+----+----------+-----------+
/* all topics sorted by last post*/
select p1.id from posts p1 where timestamp = (select min(timestamp) from posts p2 where id_topic=p1.id_topic) order by (select max(timestamp) from posts p3 where id_topic=p1.id_topic) desc;
+----+
| id |
+----+
| 1 |
| 3 |
| 2 |
+----+
How to get results in the same order as i am passing the question ids in my last post?
You don't, at least not in an easy fashion.
Either there is a data property which you can use for sorting (like an alphabetical sequence, a timestamp etc., or you have to code an inline or explicit function to alter the sorting arbitrarily.
For this you could for example use the locate() or the if() function, like in:
select id from mytable order by (if(id=13,1,if(id=17,2,if(id=16,4)));
or
select id from mytable order by locate(concat(' ', id, ' '), ' 13 17 16 11 12 ');
You mean that the output is ordered by question_ids. This is from a database point of view a random order - the order of the input. So the result is not sorted. To sort it by specific criteria, include an ORDER BY clause in your query.