|-|x 126 Junior Poster in Training

Are you typing into this textbox or setting it programatically? If typing, then the event would be triggered for every key press, and thus you will experience multiple successive postbacks.

If any other function/event occuring is changing the text in code on PostBack, it could be triggering an additional postback from that event as well.

Just food for thought.

|-|x 126 Junior Poster in Training

Hi Dave, glad to be of help and that you found your experience here at Daniweb to be positive - it's a great community.

One final note for your site; I would recommend also specifying the charset for your html code to ensure continued successful interpretation by the widest possible range of browsers. You can specify the charset in both the meta tag <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> as well as the link tag for your stylesheet.

All the best!
/H

|-|x 126 Junior Poster in Training

OK in that case, I suggest you download Toad, and generate some changes in your 2 databases. Then run Toads comparison function and output the script so you can see what its doing. You will see how it creates temporary tables to copy data while updating the schema, drops and recreates foreign keys, and does the schema changes itself.

The best way to learn is to study what others have done, then you can always add your own features as fits your needs. :)

|-|x 126 Junior Poster in Training

heheh... it could have at least been the latest version of Firefox then :P

|-|x 126 Junior Poster in Training

It looks like you are not setting $email_to or $email_subject anywhere.

Check these, and verify if you can that your SMTP server is configured in the php.ini/conf file. You may need to set this via

ini_set ( "SMTP", "smtp-server.example.com" );
|-|x 126 Junior Poster in Training

It actually doesn't surprise me. The number of "big" sites I have been to that are only compatible with IE is a constant point of contention as I specifically avoid using IE due to its history of security related and efficiency issues.

|-|x 126 Junior Poster in Training

It could be on the css file itself, at filesystem level.

Imagine you are saving the css source code in a text editor. At the file save dialog, in some editors you can specify the character set of the file, ie: ascii, utf8 etc. If this has been set to something that conflicts with the web pages delivery as specified in the HTML source, this may cause the browser to interpret the css file contents incorrectly.

When I saved and opened the file I can see that it has been saved in a UTF8 format. The browsers default interpretation may not be detecting this.

Possible solution: You can specify the charset in the link tag. (Note the link tag should also have a close backslash, not sure if this may be affecting the functionality as IE can sometimes be more lenient on invalid HTML.) See this page for more details, but I would try something like this.

<link rel="stylesheet" type="text/css" charset="utf-8" href="http://www.classixrock.com/classix.css" />
JorgeM commented: appreciate it! +0
|-|x 126 Junior Poster in Training

It looks to me like it might be a charset configuration problem. If I view the CSS file in Chromes dev tools it shows up as Chinese text. The charset might be specified in the file itself or possibly in the web server where it is storing/delivering the file.

Check out the screenshot to see what I'm talking about.
chrome

JorgeM commented: great job on the troubleshooting! +4
|-|x 126 Junior Poster in Training

Are you intending to trigger this process manually? If so I recommend using a database comparison utility to generate the difference scripts for you. This will also give you a chance to visually verify the updates that will occur before executing the script.

There is a discussion on this topic here which lists a number of tools for this purpose. The redgate comparison toolkit is probably the best, though it is commercial, so if you want to use it beyond their 30 day trial you need to buy it. Otherwise Toad is probably the best free tool I have used which does good DB comparisons.

|-|x 126 Junior Poster in Training

I think you have understood the problem correctly. The database will not work correctly if the UserID is Foreign Key to 3 separate user tables.

Rather than trying to condition the FK based on the Type field, it might be better in this scenario to split the UserID into 3 separate fields, each FK linked to the appropriate user table.

Example

CREATE TABLE login (
  LoginID varchar(20) not null,
  AdminID int null,
  PatientID int null,
  SLP_ID int null,
  Password varchar(20) not null,
  PRIMARY KEY (LoginID),
  KEY AdminID (AdminID),
  KEY PatientID (PatientID),
  KEY SLP_ID (SLP_ID)
);
ALTER TABLE login
  ADD CONSTRAINT login_fk1 FOREIGN KEY (AdminID) REFERENCES Admin (AdminID),
  ADD CONSTRAINT login_fk2 FOREIGN KEY (PatientID) REFERENCES Patient (PatientID),
  ADD CONSTRAINT login_fk3 FOREIGN KEY (SLP_ID) REFERENCES SLP (SLP_ID);

If you can post the SQL create scripts for your tables, and a sample data set we will be able to get a better idea of how to help you.

|-|x 126 Junior Poster in Training

ou ... but maybe you didn't mean symmetrically opposite.

Is this a trick question?

|-|x 126 Junior Poster in Training

window -> cleaner

|-|x 126 Junior Poster in Training

What is the error you are getting?

I don't believe you can have an actual foreign key set up on the table pointing to multiple other tables, but it shouldn't be causing an error with duplicate values unless you have specified that field as unique

Copy your table/database structures and the data you are trying to insert here and we may be able to help identify the source of the problem.

|-|x 126 Junior Poster in Training

Assuming the autoincrement ID's do match up in both tables you could use a subquery like so...

...
WHERE BuyPortfolio.[STOCK ID] NOT IN (SELECT [STOCK ID] FROM Portfolio)

This will return all records in the BuyPortfolio table which are not in the Portfolio table according to the ID's.

|-|x 126 Junior Poster in Training

Where you are setting Tableid, I believe you are actually redeclaring a local variable with the same name, so your global is never getting set. Try removing the var from line 6 and see if that solves your problem.

Here is some general information on javascript variables that may also be helpful:
http://www.w3schools.com/js/js_variables.asp

|-|x 126 Junior Poster in Training

It is my understanding that EXPLAIN performs an analysis of the execution, not a pre-analysis as MS SQL Servers optimisation engine does. It simply provides information about the execution path, it doesn't alter the query or optimise it in any way.

If we alter the subquery to eliminate the error, the EXPLAIN results are the same for both queries.

EXPLAIN SELECT * FROM tblp
WHERE true OR (SELECT value FROM tblp LIMIT 1);

In order to demonstrate that MySQL isn't optimising out the hard coded values we can use a variable, which achieves exactly the same results.

set @v = true;

SELECT * FROM tblp
WHERE @v OR (SELECT value FROM tblp);      #  Successful

SELECT * FROM tblp
WHERE not @v OR (SELECT value FROM tblp);  #  Subquery Error

Additionally, if we reverse the order of the OR arguments, it doesn't work.

SELECT * FROM tblp
WHERE (SELECT value FROM tblp) OR true;      #  Subquery Error

Thus, we can conclude that during execution the WHERE clauses are evaluated in order and that MySQL does in fact short circuit once it has a determination of the overall outcome.

|-|x 126 Junior Poster in Training

What exactly do you mean by parse? Are you searching for specific values in the data?

I would almost guarantee that doing these operations in an SQL script will be faster than processing manually in any programming language.

|-|x 126 Junior Poster in Training

Incidentally, I verified that the inverse holds true for an AND clause

SELECT * FROM tblp
WHERE false AND (SELECT value FROM tblp);

^ Short circuits executing successfully and returns 0 rows.

SELECT * FROM tblp
SELECT true AND (SELECT value FROM tblp);

^ Throws the subquery exception.

|-|x 126 Junior Poster in Training

During some recent project issues I found myself asking this very question: Does MySQL short circuit WHERE clause statements?

After doing some research and finding that several other people and technical forums have posed this question, with several answers pertaining to be intelligent but that amount to "i don't know", I decided to perform some experiments.

Firstly, how to test whether a statement is being executed or not? Solution: make it throw an exception. I initially tried some select statements with parameters and division by zero, but MySQL apparently returns NULL instead of a divide-by-zero error. So I came up with the following statements:

SELECT * FROM tblp
WHERE true OR (SELECT value FROM tblp);

SELECT * FROM tblp
SELECT false OR (SELECT value FROM tblp);

While this is syntactically a legal statement, it is not a logically correct one as the subquery will return multiple rows.

  • The first statement executes successfully and returns all rows in the table, equivalent to select * from tblp where true

  • The second statement, however, throws an error Subquery returns more than 1 row

This to me is pretty definitive evidence that MySQL does short circuit WHERE OR statements.

|-|x 126 Junior Poster in Training

Thanks guys, there are some great ideas here.

Biiim: I wont be able to use Group functions alone as I do need to display other data as well, and as you pointed out it will not reliably display the matching values.

Philippe: Setting the latest flag only after invoicing would be the ideal solition as a workflow change, however, this is actually set in an external system which we are importing data from, and so it is necessarily set when the new version is created regardless of status. You are correct in that I could select the latest invoiced contract regardless of this flag, as it is no longer a reliable criterea.

smantscheff: I actually hadn't thought of using the sort like that to determine both latest and max version. I will investigate using this in combination with some grouping, but I think you might be on to something.

|-|x 126 Junior Poster in Training

I managed to get the join version working, it seems to be more efficient but I will need to verify this further with the full dataset.

Here for interest:

...
LEFT JOIN (status s LEFT JOIN status sx ON sx.pid = s.pid AND sx.DateStamp > s.DateStamp) ON s.pid = p.id
...
WHERE sx.DateStamp IS NULL
|-|x 126 Junior Poster in Training

Sweet! Keep up the good work, Dani. :)

|-|x 126 Junior Poster in Training

I have a datasource on my page, the select query of which creates a pivot table. The complexity is that the columns in the pivot are determined by records in another table (the users table). So I have to use a prepared statement to build and execute the pivot query, as beow;

SelectCommand="set @q = CONCAT('SELECT Question,',
(SELECT GROUP_CONCAT(CONCAT('NULLIF(COUNT(NULLIF(t.user=',ID,',0)),0) AS `',Firstname,' ',Lastname,'`')) FROM users),
' FROM archiveresponses LEFT JOIN archivetransactions t ON t.TransactionID=archiveresponses.TransactionID 
GROUP BY Question,Compliance HAVING Compliance=0');
PREPARE smt FROM @q;
EXECUTE smt;"

The actual select query that runs will look something like this (obviously the number of user-named columns is dynamic)

SELECT Question,NULLIF(COUNT(NULLIF(t.user=2,0)),0) AS `John Smith`,NULLIF(COUNT(NULLIF(t.user=3,0)),0) AS `Jane Doe` FROM archiveresponses LEFT JOIN archivetransactions t ON t.TransactionID=archiveresponses.TransactionID GROUP BY Question,Compliance HAVING Compliance=0

This works perfectly when I run it manually against the database. However, in the aspx page it throws an exception stating
MySql.Data.MySqlClient.MySqlException: Parameter '@q' must be defined.

I am positive that this worked a couple days ago, but no longer. Only some minor changes have been made to the query and page layout which should not have affected the workflow of the PREPARE-EXECUTE structure of the query.

Is there any way to tell the datasource that @q is not in fact a parameter, but just part of the query that needs to be executed?

Alternately,

does anyone know how to use the Prepared statement construct without requiring the interum variable?

I know you can use PREPARE stmt FROM 'string constant query' but it doesn't …

|-|x 126 Junior Poster in Training

Hmm.. seems strange to me that the property is not supported, but eh.

Both good work-arounds, thanks for the advice guys.

|-|x 126 Junior Poster in Training

Try something like the below ... (this code assumes you have done the relevant sql object declarations)

Dim strFrom AS String = ""
strQuery = "SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'Database1'"
con.Open()
theQuery.Connection = con
theQuery.CommandText = strQuery
theReader = theQuery.ExecuteReader
While theReader.Read
    If strFrom = "" Then strFrom = "FROM " & theReader("TABLE_NAME")
    ELSE strFrom &= ", " & theReader("TABLE_NAME")
    End If
End While
theReader.Close()
con.Close()
|-|x 126 Junior Poster in Training

update: actually now I get the 404 when going to the javascript/dhtml topic forum

|-|x 126 Junior Poster in Training

Ok, so the scenario is a database which stores customer contracts (to keep it simple) so that every time a contract is expired and renewed a new version is created in the database to reflect any changes (terms, price etc).

My page needs to display a list of the latest (current) versions of each contract, which is made really simple by the fact that the table includes a latest flag field, so the initial query would look something like this:

select * from tblp where latest;

Now we get to the interesting part. If you take a look at the following sample dataset:

drop table if exists tblp;
create table tblp (client int,value decimal,ver int,latest tinyint,invoice char(8) null);
insert into tblp values
(1,500,1,0,'00654321'),
(1,550,2,0,'00654322'),
(1,550,3,0,'00654323'),
(1,600,4,1,null),
(2,500,1,0,'00654001'),
(2,550,2,0,'00654002'),
(2,600,3,1,'00654003');

we see that the result produced by the initial query is as follows

client value ver latest invoice
1      600   4   1      -
2      600   3   1      00654003

However I need not display entries that have not been invoiced (and are therfore not finalised). I can do this with a subquery and comparison on the version number as follows:

select * from tblp p
where (latest AND invoice IS NOT NULL)
OR (ver = (select max(pp.ver) from tblp pp where pp.client=p.client AND pp.invoice is not null))

client value ver latest invoice
1      550   3   0      00654323
2      600   3   1      00654003

However, I'm not convinced this is the best way to achieve the desired outcome. I also …

|-|x 126 Junior Poster in Training

Ok, I assume this is the right place to put this...

bizzarly, I can't seem to access my post due to a 404 error. I got the email saying some activity on the post, clicked the link and got the error. Also get it when trying to view from the topic listing. Other posts in that and other topics seem fine. Not sure if its something about that post in particular or if its some client/proxy/caching issue (will update if I manage to get in).

post in question is http://www.daniweb.com/web-development/javascript-dhtml-ajax/threads/420946/readonly-checkbox

|-|x 126 Junior Poster in Training

line 10 is not quite right.

strFrom &= theTable

you would need to access the row and field inside the table object.
(sorry about this example, but can't recall exact vb syntax off hand, in c# it would be something like this...)

strFrom &= theTable.rows[0].cells[0]

This should grab the first value of the first row returned in the table, you can of course reference any valid row/column index.

Note: you would need to loop through the table rows to obtain all results if more than one is returned/required.

alternative method:
If you structure your initial query so that it will only return a single result item you could use strFrom &= theQuery.ExecuteScalar without the need for an adaptor or table object. But this will work with a query that returns only a signle record with a single field

|-|x 126 Junior Poster in Training

Thanks, that will do what I need.

I still do wonder if there is any way of making the readonly property work without javascript? Or is this feature just not implemented in the HTML standard or something?

|-|x 126 Junior Poster in Training

seems to me that you should check your php.ini to ensure it includes the line extension=php_mysql.dll uncommented, this is what tells php to load the mysql extension.
(if it is not there, you should be able to simply add it)

|-|x 126 Junior Poster in Training

try maybe sorting on ID and date both descending

SELECT * FROM $logbook WHERE Date<='$Date' AND ID!='$ID' ORDER BY Date DESC, ID DESC LIMIT 1

you could also add an extra clause to exclude the previously selected ID AND ID!='$Next["ID"]'

(of course you need to grab the value from the MySQL result properly, but you get the idea)

|-|x 126 Junior Poster in Training

There is a function called LEFT which can be used to grab the first letter of a field for comparison

example:

SELECT * FROM tblBrands WHERE LEFT(Brand,1) BETWEEN 'A' AND 'E'

etc...

|-|x 126 Junior Poster in Training

I think that should work, but you will need to give the hidden field a name in order to identify and grab it from the POST array.

<input type="hidden" name="id" value="'. $result['id'] . '">

then you will be able to access the data like so: $_POST['id']

|-|x 126 Junior Poster in Training

implode needs to be passed an array in order to work properly, what you are doing is passing a single element of an array
$result['userid'] will return the value of the userid for the first record. $result is in fact only the first record of the result set presented as an array.

Unfortunately I don't believe implode can be used to achieve what you need.
What you will need to do is loop through each record, and manually append the result value to your new query string.

for example

while ($row = mysql_fetch_array($query2)) {
  if (!empty($string))
    $string .= " OR "
  $string .= "id =".$row['userid'];
}
|-|x 126 Junior Poster in Training

Hi guys,
Working on one of my web projects recently I came accross a need for presenting some readonly data as part of the user input form. The readonly property of the input tags seem to work as expected for other types of input control, but not for the checkbox.

Sample code:

<input id="chkExempt" type="checkbox" readonly="readonly" /> Exemption

The result is a checkbox that is "greyed out" in appearance but still responds as normal to user interaction (ie: clicking checks/unchecks). I also tried this with readonly="true" as seems to be the Microsoft way of doing things, but the results were the same.

I can of course set the checkbox to be disabled, but then it no longer is pushed back to the server as part of the form post, which I needed.

Does anyone know why this doesn't work? or an alternate way of achieving the desired outcome? (preferably avoiding javascript)

cheers
/H

|-|x 126 Junior Poster in Training

try this...

onchange="document.theform.showValue1.value=this.value.split(' ')[0]; document.theform.showValue2.value=this.value.split(' ')[2]">

note that if your final values in the dropdown have spaces in them you will need to adjust the split function calls accordingly.

|-|x 126 Junior Poster in Training

Thanks, and I realise you are correct about aggregate functions, although in this case MySQL's handling of the Grouping is sufficient as the primary table will not return duplicate records for the key fields. I have however included the additional non-aggregate fields in the Group clause now, for precision.

I am actually converting this from a legacy system which may not have been written 100% accurately. In addition, the existing data is also legacy and we cannot guarantee that it is complete or integral (ie: no foreign key enforcement) therefore the Joins must allow for incidental missing or invalid data on the Right side.

To my main issue now, I have a work around solution which gives me the correct result. However, as it is a nested subquery I have concerns about efficiency once the data starts to increase. The new join looks as follows:

LEFT JOIN (SELECT * FROM (SELECT * FROM stats ORDER BY dateChanged) ss GROUP BY ss.pid) s ON s.pid=p.id

Max and Min functions wont achieve what I need as they only return the max date for the entire table, and I need the greatest value for each ID in the table. It would work as another nested subquery, but that still doesn't eleviate the efficiency issue.

I am open to any suggestions as to how to eliminate the subquery nesting. I read an article that suggested to do it joining the table to itself WHERE left.dateChanged>right.dateChanged but I couldn't make it work.

|-|x 126 Junior Poster in Training

I believe what you are talking about is possible, although I have not worked with Google Places specifically before.

To get the form to post to an external website, you need to specify the URL in the forms action property (see more info here more info here ).

To my understanding (and this is purely conjecture) if a user is signed in with a Google account in their browser already, it may sign them in automatically. Alternately it may take the user to a page where they can login or sign up and still keep the post data.

I would suggest checking out the Google Places API and see if they have provided an interface or script code to do what you want already.

|-|x 126 Junior Poster in Training

line 15...

if (is1or2or3=true)

needs to use the comparison double equals == as the single equals is for assignment, and an assignment statement will always evaluate to true.

|-|x 126 Junior Poster in Training

else {echo '<p> "The following book was submitted: "' . $title . '</p>';

Although I am not sure this is the cause of your error, you don't actually need the double quotes inside this string unless you want them to display.

echo '<p>The following book was submitted: ' . $title . '</p>';

edit
just noticed this.

public function getdisplayTitle('title') {

you have a string constant in your function definition where you should have a variable.

public function getdisplayTitle($title) {

you may also want to change the order of checking and getting the value of your POST variable here...

$displayTitle = $_POST['title'];
if(isset($_POST['title'])) {

|-|x 126 Junior Poster in Training

ExecuteScalar is for queries that return a single result, eg SELECT Count(*) FROM table1

To load the data into the DataTable you will need to use DT.Load(CMD.ExecuteReader) or something similar. The second Execute (ExecuteNonQuery) is not needed.

Also, you can leave out the DataAdaptor completely, if you are binding the gridview to the DataTable directly the DataAdapter is not needed. Alternately, If you intend to use the DataAdaptor for updating you should bind the gridview to the DataAdaptor instead.

|-|x 126 Junior Poster in Training

I'm on ICS (4.0.2) and dont have any problems

|-|x 126 Junior Poster in Training

The laptop should function fine with a partitioned drive so long as there is sufficient space on the primary partition for the OS to function (create virtual memory and temporary files, expand the registry hives etc)

The best way to get rid of the superfluous operating system would be to format the second partition. This WILL DESTROY any data on that second partition, but will not affect any data on the primary partition. I would suggest copying anything you need from the second partition either onto the primary partition or an external drive and then formatting that partition. If you are not intending to use the additional operating system you could gain yourself a fair amount of disk space and potentially performance by removing it.

If you are unsure about how to format the partition, please ask as I would hate for you to accidentally format the whole drive and lose important data.

|-|x 126 Junior Poster in Training

Thines01: that still won't increment when the initial condition is false as it will not enter the loop.

shean1488: actually you can do exactly as you wished, simply add count++ to your condition statement...

while(count++ > 0 && some expression && another expression)

this will increment count each time the condition is evaluated and (so long as count is not negative) will always evaluate to true and thus not affect the outcome of the condition statement.

|-|x 126 Junior Poster in Training

fibonacci -> golden mean

|-|x 126 Junior Poster in Training

fibonacci -> golden mean

|-|x 126 Junior Poster in Training

I would also add that if it is an old TV show, it may have been released into the public domain and/or the original copyright holders no longer claim rights to the property. In such a case it would not be illegal for you to download and watch the show from any source.

This is common enough but will depend on the owning company, as some are happy to release their stuff for public consumption when they no longer feel it is potentially profitable, others seem to hang onto it forever in order to maybe sell the rights to produce sequels/remakes/spinoffs etc.

|-|x 126 Junior Poster in Training

Saturn orange echidna

|-|x 126 Junior Poster in Training

object -> OOP