smantscheff 265 Veteran Poster

API means Application Program Interface. What application are you talking about?
Do you want to program a score list in PHP? What does your input look like?

smantscheff 265 Veteran Poster

Use the php dir class function: http://php.net/manual/en/class.dir.php
Come on, man, give it at least a try.

smantscheff 265 Veteran Poster

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

?>
smantscheff 265 Veteran Poster

If you strip your query of the group clause, you get the following "raw" data for the aggregation which show the problem: you have one row for each value of cub. I do not understand the semantics and therefore cannot delve deeper, but I think you have to work on the query below until it shows the correct results. Then make it a view and build your aggregate query on the view.

Select *,
If(B.ttc In ('X','Y','Z'), 0, B.ua) as s1, 
If(B.ttc In ('X','Y','Z'), B.ua, 0) as s2
From Table_B As B
Left Join Table_C As C On B.acctno = C.acctno
Left Join Table_A As A On B.acctno = A.acctno
Where A.status != 'C'
;
+--------+-----+--------+--------+--------+------+------+--------+--------+-------+--------+
| acctno | ttc | ua     | acctno | cub    | dc   | rc   | acctno | status | s1    | s2     |
+--------+-----+--------+--------+--------+------+------+--------+--------+-------+--------+
| 123456 | X   | 5.432  | 123456 | 10.987 | 1234 | abcd | 123456 | A      | 0     | 5.432  |
| 123456 | X   | 5.432  | 123456 | 0.987  | 1234 | abcd | 123456 | A      | 0     | 5.432  |
| 123456 | A   | 2.345  | 123456 | 10.987 | 1234 | abcd | 123456 | A      | 2.345 | 0      |
| 123456 | A   | 2.345  | 123456 | 0.987  | 1234 | abcd | 123456 | A      | 2.345 | 0      |
| 123456 | B   | 8.765  | 123456 | 10.987 | 1234 | abcd | 123456 | A      | 8.765 | 0      |
| 123456 | B   | 8.765  | 123456 | 0.987  | 1234 | abcd | 123456 | A      | 8.765 | 0      |
| 234567 | A   | 1.234  | 234567 | 6.543  | 2345 | bcde | 234567 | A      | 1.234 | 0      |
| 234567 | A   | 1.234  | 234567 | 1.654  | 2345 | bcde | 234567 | A      | 1.234 | 0      |
| 234567 | A   | 1.234  | 234567 | 0.789  | 2345 | bcde | 234567 | A      | 1.234 | 0      |
| 234567 | X   | 12.345 | 234567 | 6.543  | 2345 | bcde | 234567 | A      | 0     | 12.345 |
| 234567 | X   | 12.345 | 234567 | 1.654  | 2345 | bcde | 234567 | A      | 0     | 12.345 |
| 234567 | X   | 12.345 | 234567 | 0.789  | 2345 | bcde | 234567 | A      | 0     | 12.345 |
| 234567 | A   | 9.876  | 234567 | 6.543  | 2345 | bcde | 234567 | A      | 9.876 | 0      |
| 234567 | A   | 9.876  | 234567 | 1.654  | 2345 | bcde | 234567 | A      | 9.876 | 0      |
| 234567 | A   | 9.876  | 234567 | 0.789  | 2345 | bcde | 234567 | A      | 9.876 | 0      |
+--------+-----+--------+--------+--------+------+------+--------+--------+-------+--------+
smantscheff 265 Veteran Poster

If this is the best you can do for me, what do you expect? You could have at least submitted instantly repeatable test code without need for re-formatting.

I don't even get the same test results:

drop table if exists table_A;
create table table_A (
dc  varchar (255),
rc  varchar (255),
acctno  int (11),
status  char (1)
);
insert into table_A values
('1234','abcd','123456','A'),
('2345','bcde','234567','A'),
('3456','cdef','345678','C');

drop table if exists table_B;
create table table_B (
acctno  int (11),
ttc  varchar (10),
ua  decimal (10, 3)
);

insert into table_B values
('123456','X','5.432'),
('123456','A','2.345'),
('123456','B','8.765'),
('234567','A','1.234'),
('234567','X','12.345'),
('234567','A','9.876'),
('345678','B','10.987'),
('345678','B','2.345'),
('345678','B','6.543'),
('345678','A','0.123');

drop table if exists table_C;
create table table_C (
acctno  int (11),
cub  decimal (10, 3)
);

insert into table_C values
('123456','10.987'),
('123456','0.987'),
('234567','6.543'),
('234567','1.654'),
('234567','0.789'),
('345678','5.432');

Select A.dc,A.rc,B.acctno,
((Sum(If(B.ttc In ('X','Y','Z'), 0, B.ua))) -
(Sum(If(B.ttc In ('X','Y','Z'), B.ua, 0)))) As Total_UA,
(Sum(C.cub)) As Total_CUB
From Table_B As B
Left Join Table_C As C On B.acctno = C.acctno
Left Join Table_A As A On B.acctno = A.acctno
Where A.status != 'C'
Group By B.acctno Having Abs(Total_UA - Total_CUB) > 0.0001 
;
+------+------+--------+----------+-----------+
| dc   | rc   | acctno | Total_UA | Total_CUB |
+------+------+--------+----------+-----------+
| 1234 | abcd | 123456 | 11.356   | 35.922    |
| 2345 | bcde | 234567 | -3.705   | 26.958    |
+------+------+--------+----------+-----------+
smantscheff 265 Veteran Poster

Try again, this time include the schema.

smantscheff 265 Veteran Poster

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.

smantscheff 265 Veteran Poster

Submit the necessary CREATE TABLE statements and some data for a complete test case.

smantscheff 265 Veteran Poster

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.

smantscheff 265 Veteran Poster

If the field may only have four values, use an enum type.

create table publisher(name varchar(20), city enum('mumbai','pune','nasik','panji'))
smantscheff 265 Veteran Poster

Google for "sql injection". Protect your database (in gdform.php), not your form. You cannot do anything against malicious data coming in. But you can protect against processing it.

smantscheff 265 Veteran Poster

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.

smantscheff 265 Veteran Poster

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

The ON clause is missing after the first INNER JOIN clause.

smantscheff 265 Veteran Poster
smantscheff 265 Veteran Poster

What is the second part? And did you ever consult a manual?

smantscheff 265 Veteran Poster

Maybe you forgot to initialize the session with session_start().
And instead of line 3 it shoud read

$row = mysql_fetch_row( $r );
smantscheff 265 Veteran Poster

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

It's utterly nonsense to create a table for each new user.

smantscheff 265 Veteran Poster
select a.*,b.*,c.* from a join b on a.x=b.x join c on b.x=c.x

or

select a.*,b.*,c.* from a join b on a.x=b.x join c on a.x=c.x
smantscheff 265 Veteran Poster

Add a CREATE TABLE and some INSERT statements for a complete test case for us.
Have a look at the result of your query. Which row appears more than once?
Change SELECT to SELECT DISTINCT. Does it change anything?

smantscheff 265 Veteran Poster

You can add headers as a 4th parameter of the mail function.
Try "From:xyz@maindomain.com\r\n\Reply-to:xyz@maindomain.com"

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

smantscheff 265 Veteran Poster

The server has crashed. Restart it.

smantscheff 265 Veteran Poster

Filter the "." before you insert it. You can replace the period by applying replace():

INSERT INTO mytable myvalue VALUES (replace('1.000','.',''));
smantscheff 265 Veteran Poster

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

I'm glad to have been of help.
Yes, views can simplify complicated queries a lot. One drawback in MySQL is that they are stored in an very explicit form with all table prefixes and each column listed separately. Have a look at SHOW CREATE VIEW view1. If you add a column to one of the tables of the view, it won't show up in the view until you explicitly insert it. Therefore I find it good practice to store source code for views externally outside of MySQL for further editing.

smantscheff 265 Veteran Poster

Have a look in the server's error log.

smantscheff 265 Veteran Poster

With a Rewrite rule in the server configuration. Study the Apache RewriteEngine module.

smantscheff 265 Veteran Poster

Can you do it the other way round? Have your server send a message to all known clients as soon as the maximum has been reached.
I must admit that I do not yet understand the setup. If you have no control of the nodes, then you have either an intermediate agent between the database and the nodes or you are working directly on database level. Is that so? Or what do you mean with "no control"?
Did you test if the database performance really is affected by your query? MySQL has a query cache which should do most of the work in this case.
You could set up a polling process which connects to the database only once and queries it every few minutes whether the maximum has been reached. Then your clients connect to this polling process to see if it's o.k. to feed the database before they connect to the database. The process could have a very simple protocol with minimal overhead.

smantscheff 265 Veteran Poster

On PHP level you can use regular expressions. Look up the manual for the preg_... functions.

smantscheff 265 Veteran Poster

Start debugging at the root.
- Establish a connection from the mysql command line to your database with the same connection parameters as in you PHP script. Does it work?
- Echo the result of each assignment line in PHP. What is the value of $conn after line 4?
- Is the source code of the retrieved HTML page really empty? Or is only the browser not displaying anything because of erroneous HTML?
- Try to call mysql from PHP with a wrong syntax. Does it raise an error?

smantscheff 265 Veteran Poster

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.

AndreRet commented: Thanks, but I got this solved... +6
smantscheff 265 Veteran Poster

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.

smantscheff 265 Veteran Poster

Why would checking the row count crash your DB?
You could create a trigger which checks BEFORE INSERT that the row count does not exceed your maximum and reject the INSERT if it does.
How to reject a row in a trigger: http://forums.mysql.com/read.php?99,134466,134481#msg-134481

smantscheff 265 Veteran Poster

If you can guarantee an uninterrupted sequence of id numbers, you could select one of those with the rand function:

select max(id) from tbl into @p;
select * from tbl where id=ceil(rand()*@p);
smantscheff 265 Veteran Poster

If you have a good working knowledge of MS-Access and its ways there is no need to migrate the application to MySQL.
But if you are determined to migrate, MySQL is a good choice - very performant, good functionality.
Yes, you can strip the browser to a bare window. But why?
Have a look into HeidiSQL, Navicat and phpMyAdmin which might save you tons of work. In many cases it's easier to give the (few) backend users a thorough training than to set up an application which only performs standard operations (insert, update, delete).

smantscheff 265 Veteran Poster

Headers may not be sent after any script or HTML output. Blank spaces are also output.
Your output starts at
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
in header.php
Rearrange your code so that no output precedes the header() function.

smantscheff 265 Veteran Poster

select * from tbl order by rand() limit 1;

smantscheff 265 Veteran Poster

Your code is a syntactical nightmare.
Strings in PHP have to be enclosed in single or double quotes. ($message = Name)
You cannot open a <?php tag inside an already opened one.
A tip: do not mix HTML and PHP code. Write code like yours this as pure PHP without ever closing the PHP bracket.

smantscheff 265 Veteran Poster

To redirect the browser, output a "Location: ..." header or its meta-tag equivalent.

smantscheff 265 Veteran Poster

You could also use a regular expression to extract the desired content:

if (preg_match( '~feedback_url\':\s*\'([^\']+)\',\s\'file\':\s*([^\']+)'~, $sourcecode, $match )) {
  $feedback_url = $match[1];
  $file = $match[2];
}
smantscheff 265 Veteran Poster
smantscheff 265 Veteran Poster

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

$database_name is never initialized.
On my test machine the code runs fine - it shows error messages where it's supposed to.
The HTML is not well-formed. Close the <html> tag. Does it change anything?

smantscheff 265 Veteran Poster

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.

smantscheff 265 Veteran Poster

SHOW CREATE TABLE mytable;

smantscheff 265 Veteran Poster

Post also the surrounding code as there seems to be now obvious flaw with the snippet.

smantscheff 265 Veteran Poster

Restart the mysql server.

smantscheff 265 Veteran Poster

Please mark this thread as solved.