smantscheff 265 Veteran Poster

How are subdomains created in php?

The are not. You create subdomains in your webserver which has to be aware of them and configured to direct them to the correct directories scripts. Apache is capable of wildcard subdomains, so all subdomains can point to the same directory.
What you can do in PHP is to evaluate the server name ($_SERVER) which contains the subdomain name. If all your subdomains point to the same directory and script, the script can extract the subdomain from the server name variable and act on it.

I don't see how your design adds much to privacy. A hacker who is capable of hacking one account on a username/password level will have the rights of the hacked account. If your system is well designed, then only this account can be harmed.
A hacker who is capable of hacking a whole table will be capable of hacking the other tables, too. So there is no additional safety in them.
And for protection against government you need a complete encryption. Encrypt your server's hard disk and secure the connections via a VPN. Otherwise a government agency will be capable of laying hands on the hardware, and everything which is not encrypted will be compromised.

smantscheff 265 Veteran Poster

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"?

smantscheff 265 Veteran Poster

500 tables of the same structure - I would say this is a design flaw. You will of course have good reason for it, presumably safety arguments. Would you mind telling us about them?

smantscheff 265 Veteran Poster

You cannot have that (columns acting as rows) in standard SQL. You will have to walk through the result set and format a report based on grouping by organization.
In MySQL you can maybe make use of the group_concat() function: group by organization and concatenate the areas of interest in one column.

smantscheff 265 Veteran Poster

@javvy: You are assuming that images are external files. This is not necessarily so, and there are many good reasons to store them in the database.

smantscheff 265 Veteran Poster

It would be easier for us to help you if you would clearly state your problem.

smantscheff 265 Veteran Poster

The distinctive feature of the controls is their html property "name". Build the names as unique strings using the group member IDs, so that your controls have names like cb1_1, cb_1_2, cb2_1, cb2_2 and so on. Then on the receiving side walk through the $_POST array and check each input name with a regular expression like

foreach( $_POST as $key => $value)
  if (preg_match( '/cb([0-9]+)_([0-9]+)/', $key, $match )) {
    $checkbox = $match{1];
    $groupmember = $match[2];
    ...

]

smantscheff 265 Veteran Poster

If your raw image data are stored in a database, you need a script which not only retrieves them but also adds the html image headers. For example with JPEG images, you might code something like this:

<?php
[...
your database connector retrieves image data as $imgdata
with a query like "select imgdata from images where id='$myId'" 
...]

header( "Content-type: image/jpeg" );
echo $imgdata;

[No closing ?> bracket at the end - more often than not you'll overlook a blank at the end of the file]

If this script is called myimage.php, you can use it as an image file name in html: <img src='myimage.php?id=xyz' />

smantscheff 265 Veteran Poster

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" );

smantscheff 265 Veteran Poster

Thank you for sharing. But who would want to use this instead of a simple CREATE TABLE query?

smantscheff 265 Veteran Poster

If the species is given, the task is simple (to describe).
First SELECT latitude, longitude FROM locations WHERE SPECIES=myspecies
Then set a marker on your map at each lat/lon point. You can do that with the Google Maps API.
If you choose other maps without an API (e.g. from Wikimedia), you will have to map the geographical coordinates to pixels on the map. This is easy for small areas of the globe where you can use linear trigonometry, but becomes a little bit trickier if your maps and species distribution comprises relevant part of the globe - then you will have to use spherical trigonometry.

smantscheff 265 Veteran Poster

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 |
+----+
smantscheff 265 Veteran Poster

That's correct. A standard barcode scanner is an input device which transmits character data into the keyboard buffer. You have to store them in the same manner as if they had been typed in via a keyboard.

smantscheff 265 Veteran Poster

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 ');
smantscheff 265 Veteran Poster

There are numerous places where character encoding can be specifically set, among them database definition, table definition, field definition and interface character set. These all have to fit with each other to preserve the original data encoding.
Study this: http://www.koch.ro/blog/index.php?/archives/50-MySQL-character-sets-primer.html (including references) and this: http://www.phpwact.org/php/i18n/charsets
Make sure that your HTML has the correct encoding announced either in an HTML header or in a meta-tag (Content: text/html; charset=utf8)

smantscheff 265 Veteran Poster

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.

smantscheff 265 Veteran Poster

select price * (1 - if(discount_active, 0.1, 0 )) as retail_price

smantscheff 265 Veteran Poster

Your outermost loop lacks a sort clause.
I assume that you want an order like this, so that the thread with the youngest reply or topic creation timestamp is displayed first:

TOPIC 1 (timestamp 1)
  REPLY 7 (timestamp 7)
TOPIC 3 (timestamp 3)
  REPLY 4 (timestamp 4)
  REPLY 5 (timestamp 5)
TOPIC 2 (timestamp 2)

It might be easier if you would not separate topics and replies in different tables but to pack all posts belonging to a thread into the same table - the first post, too.

smantscheff 265 Veteran Poster

Set up your database and all connections to use UTF-8 as the default character set.

smantscheff 265 Veteran Poster

If you know php/mysql, you could learn php/mssql and then write a php script which transfers the school data to your website.
Or find out how mssql data can be exported (presumably as CSV) and write a shell script which imports them into you database.
Do this is serveral small steps.
Export from mssql to CSV.
Import from CSV into mysql.
Write s shell script which does the job.
Write a shell script which transfers the mssql data to you web server (for example with ftp).
Write a shell script which combines all.

smantscheff 265 Veteran Poster

Yes.

smantscheff 265 Veteran Poster

Your table structure is fine.
MySQL does not sort records without a SORT BY clause. If you want the result ordered by some criteria, you have to name them explicitly in your query.

smantscheff 265 Veteran Poster

I don't know wordpress. But I recommend that you first import your raw data into mysql. Afterwards they will be much easier to manipulate.
Set up a table which matches the structure of your CSV data and import them. Then you can build views or queries which adapt the source data to the wordpress structures, e.g. by concatenating the custom fields into one wordpress text field.
Alternatively you might code a wordpress extension which directly makes uses of your imported data.

smantscheff 265 Veteran Poster

No, it's not safe to use angle brackets in links because they might interfere with HTML coding and they definitely will in a lot of websites programmed by lesser geniuses.

smantscheff 265 Veteran Poster

If you don't see an error message that means that there probably hasn't been an error.
How would you generate any output? Not in your sample code above.

smantscheff 265 Veteran Poster

And check if $_POST[id] contains anything.

smantscheff 265 Veteran Poster

You cannot update queries. You could update a database. This is a question of workflow. How do data get from the school database to your home computer? Is there a direct network connection which you might use for updating? Or would you export from mssql to an intermediate format and then import into mysql? And would you have to re-update the school database with your changes from your home installation?

smantscheff 265 Veteran Poster

Change line 3 to or die(mysql_error()) which will tell you about the problem: You have to separate the assignment by comma:

UPDATE anime_list SET anime_name = '$animename', rating = '$rating', episodes = '$episodes' WHERE id='$id'
smantscheff 265 Veteran Poster

You cannot reduce the number of queries.
You need a subset of questions, but for each question a complete set of choices.
You cannot do the following because mysql doesn't allow limits in subsets:

select * from questions q, choices c
where q.question_id = c.question_id
and q.question_id in 
(select question_id from questions x where cat_id=3 order by rand() limit 10);

You could first isolate the subset of questions in a separate table:

drop table if exists tmp_questions;
create temporary table tmp_questions like questions:
insert into tmp_questions select * from questions where cat_id=3 order by rand() limit 10;
select * from tmp_questions q, choices c where q.question_id = c.question_id;
jlego commented: great info +0
smantscheff 265 Veteran Poster

You could use INSERT IGNORE.
First INSERT IGNORE into your user table, then into the item table, then in tableA. Then update tableA. You can be sure that the correct data are in it afterwards:

INSERT IGNORE INTO user values('x');
INSERT IGNORE INTO item values(1);
INSERT IGNORE INTO tableA values('x',1,'z');
UPDATE tableA set value='z' where userid='x' and itemid=1;

This is a bit redundant on the query side, but easy to code and to maintain.

smantscheff 265 Veteran Poster

This does not make sense. Which field do you want to update on duplicate keys? There is no field named "value" in your table.

smantscheff 265 Veteran Poster

Please show the CREATE TABLE statement. IS (userid, itemid) a unique key?

smantscheff 265 Veteran Poster

If your database is an sql database, use the insert command, like in

insert into users (username, followers) values ('user1',288);
smantscheff 265 Veteran Poster

What is the "quantity"? Is this the number of items in stock? Then you should have a trigger in your database which decreases the number of items in stock when an item is sold. Learn about mysql triggers. Solve this on the database level, not in PHP.

smantscheff 265 Veteran Poster

You need to click twice because your action sequence is wrong. Change it and you will have to click once only.

smantscheff 265 Veteran Poster

Insert does not need a where clause because you do not insert at a specific location other than the table. You just insert a row with some values.

smantscheff 265 Veteran Poster

So, what have you done already?

smantscheff 265 Veteran Poster

Change

insert into Borrowers() values ()

to

insert into Borrowers values (NULL,'$BorrowerName','$Email','$Telephone','$ReasonUse')

Do likewise with the Camera table insert.

smantscheff 265 Veteran Poster

A good plan. Now go ahead and do it. If you encounter any problems, come back with them.

smantscheff 265 Veteran Poster

Your query is updating all records with type_code='1' in each loop. Maybe you want this:

update products SET cost='$cost' where p_num='$num'
smantscheff 265 Veteran Poster

Which of the above words denotes your problem? followers - tweets - database - php - ?

smantscheff 265 Veteran Poster

Of course: take me. Or have a look at getafreelancer.com

smantscheff 265 Veteran Poster

DELETE the record before you SELECT it, otherwise it will appear in the result list of the select (line 4) before your delete in line 42 kills it.

smantscheff 265 Veteran Poster

Use the mysql function last_insert_id().

smantscheff 265 Veteran Poster

Run your prepared statement from the mysql command line which will tell you what went wrong.

smantscheff 265 Veteran Poster

Use the replace function:

update theTable set theField = replace( theField, '±', '±');

Obviously your interfaces got mixed up with UTF-8 and other encodings.

kvskchaitanya commented: this reply solved my issue +0
smantscheff 265 Veteran Poster

What does "not properly" mean?

smantscheff 265 Veteran Poster

Try the ifnull function to protect against unwanted NULL values.

smantscheff 265 Veteran Poster

Learn about preg regular expressions.
Your regular expressions are malformed.
Learn about debugging. Configure your server or your script (with error_reporting(E_ALL) so that it gives you the appropriate error message Warning: preg_match() [function.preg-match]: Unknown modifier ';' in x.php on line y As long as you search for exact strings only, you better use strpos instead of preg_match.

smantscheff 265 Veteran Poster

Try wget and curl.