Re: [PHP-DB] DATETIME
Hi All, I have a DB that is storing the date/time an event happens in DATETIME format, i.e. 1254252889, which translates to Tue, 29 Sep 2009 19:34:49 UTC I am trying to write a query in PHP that will look for any row that falls within a range of dates, i.e. between Sep 1 and Oct 1, but there doesn't seem to be a way to search, since you would never be able to specify a match between what date range you put in, and the time stamps?? I created a form that allows them to select a date, but even converting a date string to a timestamp, you'll never be able to get a match in the db...? Any thoughts appreciated, Edward I'm not sure I'm following you. 1) What database are you using? MSSQL/Informix/MySQL? 2) The data type for your event date/time column is just DATETIME? Or is it DATETIME YEAR TO FRACTION or anything like that? 3) Wouldn't your query be written in SQL and just executed from PHP? If you are using DATETIME YEAR TO FRACTION your query should look something like: SELECT * FROM my_table WHERE event_date BETWEEN ('2009-09-01 00:00:00.000' AND '2009-10-01 23:59:59.999')
Re: [PHP-DB] finder
Hello… I must to do a finder with 10 posibilities. This 10 can be full or empty. (sorry... I just ask this but I’m not understand yet) I know how to do a finder about any field, but this is my first time with one like this where the user can find a “house” in a “zone” or find anything in that “zone”. I must use IF the field empty SELCET... if the field is full SELECT... that with all?? Please... help... Thanks a lot $house = $_POST['house']; $zone = $_POST['zone']; $abc = $_POST['abc']; $query = SELECT * FROM real_estate WHERE 1 = 1; if ($house != ) { $query.=AND house = '$house'; } if ($zone != ) { $query.=AND zone = '$zone'; } if ($abc != ) { $query.=AND abc = '$abc'; }
Re: [PHP-DB] finder
But with that it doesnt difference between full and empty field… If the user want search on two posibilities on ten... Maybe I'm not understanding what you're asking... Or maybe you don't understand the query... Say your form has 10 checkboxes. If the users picks 3 out of ten boxes and clicks submit, the example I gave you will search your database looking for all records that match the 3 check boxes. if $houses equals $_POST['houses'] then $houses will be empty if the checkbox was not clicked and will not be included in the query.
[PHP-DB] Re: [PHP] CREATE question
On 10/30/08, Daniel Brown [EMAIL PROTECTED] wrote: On Thu, Oct 30, 2008 at 2:19 PM, Dan Shirah [EMAIL PROTECTED] wrote: Is it possible for us to use PHP to create temp tables in our database? [snip!] But all that does is give me an ifx_prepare fails message. (Forwarded to PHP-DB as well.) Dan, make sure Informix is set to allow that user to use the CREATE syntax. Also, not sure about IFX, but with other SQL databases - including MySQL - you have to use the full word `TEMPORARY`, not just `TEMP`. -- /Daniel P. Brown http://www.parasane.net/ [EMAIL PROTECTED] || [EMAIL PROTECTED] Ask me about our current hosting/dedicated server deals! Ah! You both may be right. I was running my entire using AQT and it ran fine without any problems but once I pulled it into my web application it took a swan dive. You're probably totally right, of course it could create it in AQT because I'm connecting to it with my credentials, whereas the web application is connecting as a different user. Thanks guys, I'll check out my permissions and hopefully that's all it is. Just an FYI, the use of temp instead of temporary does work in Informix :)
Re: [PHP-DB] from a table, I have to pick only those rows which have two specified fields
On 9/18/08, Vaibhav Informatics [EMAIL PROTECTED] wrote: Any simple command like distinct? -- Vaibhav Informatics, 304 Vasant Plaza, Munirka, Near Subway, New Delhi-110 067 Ph: 011-26194466 Email :[EMAIL PROTECTED] could you provide a little more detail, please? Are you saying that you have a database with multiple columns and only want to extract two of them?
Re: [PHP-DB] Question about access rights in php/mysql
Hi Everyone, I am attempting to wrap my head around an issue and wanted to see if I was thinking right. I am attempting to setup a pURL site, one where they go to something like: example.com/purl.php?purl=jason1234 and the site says Welcome Jason. I have that part of it working, and it's pulling the info from the database just fine, what I'm wondering about is locking it down a little bit more so that they can't just edit the info in the main page, but they have to specifically hit a button to edit the info. Is it better to have 2 connections to the database with 2 separate logins? One for the initial load which just has select privileges and a second for when they hit edit which then gives them update privileges? Or, should i just do 1 login with select, and update privileges? Any ideas or suggestions? Thanks! Jason, I would assume you have some kind of login page, correct? Or can anyone type in the direct URL and access someone else's page? If they have already logged in, I would use some simple javascript to enable/disable the editing of form objects. By setting all of the form objects to disabled they will appear grayed out but the text is still legible. Then when they click on your Edit button just have a Javascript function set them all to enabled. You could do something similar to show/hide div's. Or, you could bypass all the javascript and just add an edit flag to your page? So once they click on the Edit button/link it would update a variable and you could do something like: if ($edit ==Y) { type=Submit name=save value=Save } Add in the option to save only if Edit has been selected? As for your database logins, I don't see a problem with doing it either way. I personally prefer to use a single login, but doing a include() for a second login is no big deal either.
Re: [PHP-DB] Pull Down Menu with ODBC query
Try something like this: tddiv align=right SELECT name=menu ?php $conn = odbc_connect(HOMES, , ); $billdate = $_POST[ 'billdate' ]; $q_menu = SELECT DISTINCT sls_his_cust_id FROM sls_his where sls_his_prchdat_alt = $billdate; $r_menu = odbc_exec($conn, $q_menu); while ($rec_menu = @odbc_fetch_array($r_menu)) $menu[] = $rec_menu; echo OPTION value=\\--SELECT--/OPTION\n; foreach ($menu as $m) { if ($m['sls_his_cust_id'] == $_POST['menu']) echo OPTION value=\{$m['sls_his_cust_id']}\ SELECTED{$m['sls_his_cust_id']}/OPTION\n; else echo OPTION value=\{$m['sls_his_cust_id']}\{$m['sls_his_cust_id']}/OPTION\n; } ? /SELECT /td
Re: [PHP-DB] Question on PHP connect MS SQL 2005
Alice, In regards to: Call to undefined function mssql_connect() in /home/TDC/Desktop/create_new_entry_master.php on line 20 Do you have the MSSQL extension uncommented in your PHP.ini? Dan
Re: [PHP-DB] record pointer
If I understand what you're asking, just write a simple query. $picked = your_selection; $sql = SELECT * FROM your_table WHERE cat = '$picked'; $result = mssql_query($sql) or die (My_Error_Message); $row = mssql_fetch_assoc($result); $id = $row['id']; $name = $row['name']; $cat = $row['cat']; echo $id; // shows your record id on the screen. On 7/5/07, elk dolk [EMAIL PROTECTED] wrote: Hi all, My DB has the following columns: id, name ,cat. I want to select a cat i.e. cat=zzz when the query is finished I should see a specific record within this cat which is defined by id, like id=yyy Any idea how to do this? Is there a function or something like record pointer in MySQL ? cheers - Shape Yahoo! in your own image. Join our Network Research Panel today!
Re: [PHP-DB] Re: record pointer
Okay, in your first post you said you were selecting by category, now you're saying you are selecting by ID and want all corresponding records that have the same category as the selected ID. Which way are you trying to do this?? On 7/5/07, elk dolk [EMAIL PROTECTED] wrote: O.K. the id column is primary key and it is auto_incerment .I think my explanation was not clear enough : this is my query : SELECT * FROM table WHERE ID=$ID this will find the record with the specified ID and I will be able to see it, now I want to be able to scroll up and down to all the records that belong to the same cat(egory)! Frank Flynn [EMAIL PROTECTED] wrote: This is standard SQL: SELECT id, name ,cat FROM catTable WHERE cat = 'zzz'; This would return something like id name cat 1 fredzzz 5 fefezzz 18Mr. Puddles zzz 27Moris zzz and so on Your column 'id' is the pointer you're looking for. You should define it as 'PRIMARY KEY' and perhaps AUTO_INCREMENT (this means MySQL will automatically assign a value to it). Hi all, My DB has the following columns: id, name ,cat. I want to select a cat i.e. cat=zzz when the query is finished I should see a specific record within this cat which is defined by id, like id=yyy Any idea how to do this? Is there a function or something like record pointer in MySQL ? cheers - Get your own web address. Have a HUGE year through Yahoo! Small Business.
Re: [PHP-DB] mssql connecting
Did you already try these steps? http://us2.php.net/manual/en/function.mssql-connect.php#70918 On 5/23/07, Bryan [EMAIL PROTECTED] wrote: I'm trying to connect to mssql 2000 on a windows server 2003 standard box using php v5.1.6/apache 2.2.2 fedora core 4 on a separate box, of course. Any ideas? It just gives me the wonderful error: SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect in file. I also have Plesk 8.1 on the linux box so if I need to recompile php, would it break anything? I've installed freetds as well but haven't recompiled php questioning the above. Thanks for any and all help... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] DB Design Concepts
Okay, so couldn't you just set a default value for the column (N for NULL). This way column 1 and column 2 both contain valid data for whichever state your column takes on. Then just tell your logic to omit the results of column 2 that have a value of N. This way only your valid rows would be pulled and your value for N would serve the purpose of a NULL as your logic changes the state. On 5/2/07, Max Thayer [EMAIL PROTECTED] wrote: That's one of the kickers. The 7% of the time the column is populated is determined by business logic. And when the business logic says it's needed, at application run time if certain conditions were met, the column takes on the characteristic NOT NULL attribute. -Original Message- From: Dan Shirah [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 02, 2007 3:50 PM To: Max Thayer Cc: php-db@lists.php.net Subject: Re: [PHP-DB] DB Design Concepts Max, I am assuming that since column b will only be populated 7% of the time that it is not a value specific column (does not matter if it has a value or not) Therefore I would suggest leaving the NULL's in there as it will not (at least should not) affect any system performance. On 5/2/07, Max Thayer [EMAIL PROTECTED] wrote: I'm using MySQL 5.x InnoDB engine, transactional tables. I have a conceptual design question. If I have a two columns 'a' and 'b', a is the primary key, and b is a type double, in table 1 (T1) for which column b will have many NULL values, do I leave it with an allow null constraint on the column or pull the column and place it into table 2 (T2) with a foreign key, making a simple optional one-to-one relationship. Over the course of time, as the table fills with records, will a column w/ many NULL values have a detrimental effect on performance or maintenance with regards to the DB? Am I missing something here in DB design 101, by leaving the column in the T1 and knowing it will only be populated 7% of the time; what are the major implications based on the RDBMS and engine I'm using? Do I go to 2nd NF simply because a column is not going to be populated as often? Max H. Thayer Lead Software Developer Center for High-Throughput Structural Biology Hauptman-Woodward Medical Research Inst. 700 Ellicott St. Buffalo, NY 14203 Phone: 716-898-8637 Fax: 716-898-8660 http://www.chtsb.org http://www.chtsb.org/ http://www.hwi.buffalo.edu http://www.hwi.buffalo.edu http://www.hwi.buffalo.edu/
Re: [PHP-DB] widthheigh
I believe what he is saying that since you wrap your echo in double quotes, that you should not use duoble quotes again inside the same echo. Therefore your code should like like this: td width=90 height=70 ?php echo img src='/album/img/'.$photoFileName[2].' width='90' height='70 ' border='0' / ? /td On 3/30/07, elk dolk [EMAIL PROTECTED] wrote: thank you bastien, those wrappers are confusing for me, could you tell me where can I find more info. about them and based on your suggestion re-write this line for me? td width=90 height=70?php echo img src='/album/img/.$photoFileName[2]. width=90 height=70 border='0' / ?/td bastien wrote: you need to escape double quotes in an echo if you use double quotes as the wrapper. - Need Mail bonding? Go to the Yahoo! Mail QA for great tips from Yahoo! Answers users.
Re: [PHP-DB] Using multiple submits on a page and retaining $POST data
Try something like this: Your query here to get your dropdown values ** *// This first option value will set your default dropdown to display as blank* echo OPTION value=\\--SELECT--/OPTION\n; *// This will create a loop to return each option of your dropdown* foreach ($query_result as $q) { *// This if statement says that IF the value in your database matches your $_POST(selected) value then mark it as SELECTED* if ($q['my_column_value'] == $_POST['my_selected_value']) echo OPTION value=\{$q['my_column_value']}\ SELECTED{$q['my_column_value']}/OPTION\n; *// This else statement will return your default(unselected) dropdown list if it can't match the selected value with a value in your database* else echo OPTION value=\{$q['my_column_value']}\{$q['my_column_value']}/OPTION\n; } Hope that helps. On 3/16/07, Onochie Anyanetu [EMAIL PROTECTED] wrote: Almost what I wanted to do. I am looking for a way to set the default option value to the selection the user just chose. for example, something like select name=cars value=$_POST['cars'] On 3/16/07, Gunawan Wibisono [EMAIL PROTECTED] wrote: solved On 3/16/07, Onochie Anyanetu [EMAIL PROTECTED] wrote: Hello Gunawan On your first comment, im not sure what you were referring to when you said it is a js problem on your second comment, i am talking about the user entered data. data submitted by the first submit button will always be predefined by means of the user using a selection box, the data im concerned with checking is the input boxes he will be seeing. and this wont necessarily be username/pass. and im trying to do this in php if at all possible. on your next comment, (6) i am talking about after i vertified the validity of the user typed/entered data, i will enter that into my db next comment - i knew this would be hard to describe, but i'll try again. this is to be done all on one page. and ive tried using something like: value=\$_POST['name']\ but i am having problems keeping the initial drop down at the selected choice, so whenever either submit button is pressed and the post goes to php self, the drop down is refreshed back to its starting value, which is NULL hahaha.. that's simple.. drop down menu always return to the null because u don't give selected on one of option. i have a function (build in) that's answer your problem.. if you on hurry.. i'm sory, i cant give it now.. my skrip in other comp.. select option value=base selectedsale options/option option value=base2 Buy options/option /select try this on offline i believe.. the first you enter the page.. the sale option will be selected now add 2 option then try one of the option you add have selected.. what happen next you will see the default will be change, remember erase selected forgive me.. i think it matter of js but it matter of html. fyi.. try using ajax .. i believe it make your life for comfort.. (since it don't need to refresh the page) and make your skill up. I hope that helps define my problem a little more Onochie On 3/16/07, Gunawan Wibisono [EMAIL PROTECTED] wrote: that's not php problem that's was javascript problem On 3/16/07, Onochie Anyanetu [EMAIL PROTECTED] wrote: Hello, and I would like to thank everyone that attempts to help me out. I have looked long and hard online before I resorted to this. My problem is that I have a page that relies on multiple submits and data from what was submitted. example: // 1. some sort of drop down // 2. submit button // 3. display data retrieved from database // 4. user enters more information // 5. second submit button, run checks to vertify all data is entered u mean when clicked.. the info like username are check whenever is valid or not?? perhaps u should try ajax // 6. enter data into database i don't get it what u mean in here?? The problem is in step 5, when the user hits the second submit and data is checked before db submission, I am losing the data displayed by the first submit button hmm i don't get it by reading at the first. i think in the 2nd page u should try to make input type=hidden name=user value=landa this input contain what previous data enter... foreach($_POST as $nm=$val){ $txt.=input type=hidden name=$nm value=$val; } echo $txt; This is what I have tried ive tried using POST and SESSION variables to display the data, but this doesnt work. this is because in my code i have an if isset statement to check if submit has been pressed, then the variables are retrieved from the db and used. when clicking the second submit button and checks are done, the top portion of the page of information retrieved by the first submit are nothing but blanks because the first submit is no longer set (using isset) my next idea was to save
[PHP-DB] MSSQL Server
I cannot connect to my MSSQL server. I use the following connection string: php: -- $connection = mssql_connect http://php.net/mssql_connect('server','user', 'password') or die ('server connection failed'); $database = mssql_select_db http://php.net/mssql_select_db(database_name , $connection) or die ('DB selection failed'); ? -- The MSSQL server is setup to use Windows and Server Authentication. I have a *local* dummy account setup for testing and when using this account I can connect with no problems, but when I try and use my domain/network account I cannot connect at all. (my network account has full access to the server, database and tables) I can even login to the SQL Management Studio using Windows Authentication and my network account, but still cannot connect using PHP. Any ideas?
Re: [PHP-DB] Special Character
To turn off the auto formatting of hyphens: In Microsoft Word 2003: Open a new document. Go to ToolsAuto Correct Options Select the Auto Format As You Type tab Deselect the Hyphens (--) with Dash (-) option. Even though it says it will replace a double hyphen (--) with a Dash (This is an em dash) it also does the same thing for a single hyphen depending on the sentance structure. Hope this helps! Dan On 11/16/06, Niel Archer [EMAIL PROTECTED] wrote: Hi David What you describe sounds like Word is auto replacing hyphens with either en- or em-dashes. This is a configurable option in Word that often defaults to on. Try using double quotes, If they get switched to 66's and 99's style quotes, then that is likely the problem. I no longer use MS Office for these and other reasons, so cannot tell you how to switch off this formatting. But it can be switched off, somewhere within it. The only other option I can think of would be to change your Db character set to one that can accept these extended characters. That might also mean changing some of Window's/Word's behaviour (to be using UTF-8 for example). Niel -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php