RE: [PHP-DB] Re: Making a txt file from db data, is it possible?
fopen() fwrite() fclose() -Original Message- From: Raymond [mailto:[EMAIL PROTECTED]] Sent: Monday, April 08, 2002 12:05 PM To: Frank Flynn; [EMAIL PROTECTED] Subject: [PHP-DB] Re: Making a txt file from db data, is it possible? Hi! Ok, I think I maybe have to explain this a little better : ) I have this website that have a webshop that is driven by mysql and php. This is working fine, but when a customer puts something into his cart and he is sending his order, I would like to send this order by fax to the store nearest the customer. And I have this faxprogram that scan a directory for files and send them as a fax. So I was thinking I'm not sure if it is possible, but if it is possible to write all products in the customers cart into a txtfile. Iwould make to send fax, or? Thankfull for all advices or help : ) Best regards Raymond - Original Message - From: Frank Flynn [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Sunday, April 07, 2002 6:02 AM Subject: Re: Making a txt file from db data, is it possible? On 4/6/02 4:12 PM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: From: Raymond Lilleodegard [EMAIL PROTECTED] Date: Sat, 6 Apr 2002 17:18:07 +0200 To: [EMAIL PROTECTED] Subject: Re: Making a txt file from db data, is it possible? May I use this dump method with a query too? Or is this only for making a hole table into a txt file? By the time I caught this thread there was no mention of the DBMS you were using and they are different. Still one trick that usually works is to create a view with the query you want and to dump that view. Because I'm trying to get a website into a txt file and save it into a directory on the server to get a order sendt by fax. Or is this a long way to go? Sounds like the long way to me. But like I said I just saw this am I'm not sure what you're trying to do. I'd be happy to comment further if you like just send more details of what you're trying to do. Good Luck, Frank Regards Raymond -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Insert, Arrays, Null
When you say ...account for either a numeric or NULL value ..., do you mean SELECT a value that could be NULL? If so, the query is SELECT * FROM mytable WHERE cusa IS NULL || cusa = 0 -Original Message- From: Zach Curtis [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 9:11 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Insert, Arrays, Null I have attempted to insert data from an array into a table in which the values are string and numeric or NULL. The string values are no problem ($password, $int_id), but when I try to insert a value which may be either numeric or NULL (cusa, cusb, cusc) I can't produce a query that accounts for either a numeric or NULL value. I have tried various combinations of queries that include using ', , and ., in the query, however those queries usually result in either NULL values not be inserted into the table, a parse error, or a failed query. # partial mysql table definition password CHAR(8) NOT NULL, int_id VARCHAR(4) NOT NULL, cusa TINYINT UNSIGNED NULL, cusb TINYINT UNSIGNED NULL, cusc TINYINT UNSIGNED NULL, PRIMARY KEY(password, int_id) // partial php script // *** // the following (example) values are variable b\c the data are being read into this script dynamically // alpha values $password = test; $int_id = a; // numeric or NULL values $data_array = array(); $data_array[cusa] = NULL; // can be numeric or NULL $data_array[cusb] = 0; // can be numeric or NULL $data_array[cusc] = 9; // can be numeric or NULL // *** // this results in cusa = 0 in the table and not NULL $query = INSERT INTO s999dat SET password='$password', int_id='$int_id', cusa='$cus_array[cusa]', cusb='$cus_array[cusb]', cusc='$cus_array[cusc]' ; Any thoughts on how I can create this query that can account for either a numeric or NULL value coming from the dynamic array? Thank you. _ Zach Curtis Programmer Analyst POPULUS www.populus.com _ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Insert, Arrays, Null
Is there some reason you are using the SET-clause version of INSERT? Also, given that cusa, cusb, cusc are INTs, DO NOT enclose in single-quotes You can do as I've done in the past; check for value of cusa and create INSERT accordingly: ?php if (isset($data_array[cusa]) ) $cusa = $data_array[cusa]; \\ repeat for each variable else $cusa = NULL;\\ repeat for each variable $query = INSERT INTO mytable (cusa,cusb,cusc) VALUES($cusa,$cusb,$cusc); ? -Original Message- From: Zach Curtis [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 9:29 AM To: Rick Emery; [EMAIL PROTECTED] Subject: RE: [PHP-DB] Insert, Arrays, Null The data being read dynamically into the array could contain values which are NULL (the default) or numeric (if a numeric value exits). However, the query is using a INSERT INTO and I can't seem to form this query to account for either a NULL or numeric value. Zach -Original Message- From: Rick Emery [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 8:18 AM To: 'Zach Curtis'; [EMAIL PROTECTED] Subject: RE: [PHP-DB] Insert, Arrays, Null When you say ...account for either a numeric or NULL value ..., do you mean SELECT a value that could be NULL? If so, the query is SELECT * FROM mytable WHERE cusa IS NULL || cusa = 0 -Original Message- From: Zach Curtis [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 9:11 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Insert, Arrays, Null I have attempted to insert data from an array into a table in which the values are string and numeric or NULL. The string values are no problem ($password, $int_id), but when I try to insert a value which may be either numeric or NULL (cusa, cusb, cusc) I can't produce a query that accounts for either a numeric or NULL value. I have tried various combinations of queries that include using ', , and ., in the query, however those queries usually result in either NULL values not be inserted into the table, a parse error, or a failed query. # partial mysql table definition password CHAR(8) NOT NULL, int_id VARCHAR(4) NOT NULL, cusa TINYINT UNSIGNED NULL, cusb TINYINT UNSIGNED NULL, cusc TINYINT UNSIGNED NULL, PRIMARY KEY(password, int_id) // partial php script // *** // the following (example) values are variable b\c the data are being read into this script dynamically // alpha values $password = test; $int_id = a; // numeric or NULL values $data_array = array(); $data_array[cusa] = NULL; // can be numeric or NULL $data_array[cusb] = 0; // can be numeric or NULL $data_array[cusc] = 9; // can be numeric or NULL // *** // this results in cusa = 0 in the table and not NULL $query = INSERT INTO s999dat SET password='$password', int_id='$int_id', cusa='$cus_array[cusa]', cusb='$cus_array[cusb]', cusc='$cus_array[cusc]' ; Any thoughts on how I can create this query that can account for either a numeric or NULL value coming from the dynamic array? Thank you. _ Zach Curtis Programmer Analyst POPULUS www.populus.com _ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Insert, Arrays, Null
Using VALUES() is faster Nothing really wrong with SET clause, though -Original Message- From: Zach Curtis [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 10:34 AM To: Rick Emery; [EMAIL PROTECTED] Subject: RE: [PHP-DB] Insert, Arrays, Null Terrific! I tried an example assigning the array to a variable using the if-else statements before creating the query. Now the table contains values and NULLs. Is there something wrong about using the SET clause version? I like to see the assignments for each column/value side by side. Is there an advantage to using the VALUES clause? Thank you for your assistance. Zach -Original Message- From: Rick Emery [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 8:42 AM To: 'Zach Curtis'; [EMAIL PROTECTED] Subject: RE: [PHP-DB] Insert, Arrays, Null Is there some reason you are using the SET-clause version of INSERT? Also, given that cusa, cusb, cusc are INTs, DO NOT enclose in single-quotes You can do as I've done in the past; check for value of cusa and create INSERT accordingly: ?php if (isset($data_array[cusa]) ) $cusa = $data_array[cusa]; \\ repeat for each variable else $cusa = NULL;\\ repeat for each variable $query = INSERT INTO mytable (cusa,cusb,cusc) VALUES($cusa,$cusb,$cusc); ? -Original Message- From: Zach Curtis [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 9:29 AM To: Rick Emery; [EMAIL PROTECTED] Subject: RE: [PHP-DB] Insert, Arrays, Null The data being read dynamically into the array could contain values which are NULL (the default) or numeric (if a numeric value exits). However, the query is using a INSERT INTO and I can't seem to form this query to account for either a NULL or numeric value. Zach -Original Message- From: Rick Emery [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 8:18 AM To: 'Zach Curtis'; [EMAIL PROTECTED] Subject: RE: [PHP-DB] Insert, Arrays, Null When you say ...account for either a numeric or NULL value ..., do you mean SELECT a value that could be NULL? If so, the query is SELECT * FROM mytable WHERE cusa IS NULL || cusa = 0 -Original Message- From: Zach Curtis [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 9:11 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Insert, Arrays, Null I have attempted to insert data from an array into a table in which the values are string and numeric or NULL. The string values are no problem ($password, $int_id), but when I try to insert a value which may be either numeric or NULL (cusa, cusb, cusc) I can't produce a query that accounts for either a numeric or NULL value. I have tried various combinations of queries that include using ', , and ., in the query, however those queries usually result in either NULL values not be inserted into the table, a parse error, or a failed query. # partial mysql table definition password CHAR(8) NOT NULL, int_id VARCHAR(4) NOT NULL, cusa TINYINT UNSIGNED NULL, cusb TINYINT UNSIGNED NULL, cusc TINYINT UNSIGNED NULL, PRIMARY KEY(password, int_id) // partial php script // *** // the following (example) values are variable b\c the data are being read into this script dynamically // alpha values $password = test; $int_id = a; // numeric or NULL values $data_array = array(); $data_array[cusa] = NULL; // can be numeric or NULL $data_array[cusb] = 0; // can be numeric or NULL $data_array[cusc] = 9; // can be numeric or NULL // *** // this results in cusa = 0 in the table and not NULL $query = INSERT INTO s999dat SET password='$password', int_id='$int_id', cusa='$cus_array[cusa]', cusb='$cus_array[cusb]', cusc='$cus_array[cusc]' ; Any thoughts on how I can create this query that can account for either a numeric or NULL value coming from the dynamic array? Thank you. _ Zach Curtis Programmer Analyst POPULUS www.populus.com _ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Stuck on db entry from select box...
jas, Ya didn't do what I told you to do. Now, do this: SELECT NAME=\files\; $sql = UPDATE $table_name SET file_name=\$files\; -Original Message- From: Jas [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 12:01 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Stuck on db entry from select box... Ok here is my problem and where I am at this far, first thing I needed to do is to read the contents of a directory and place the results into a select box in a form (accomplished), now where I am stuck is passing the selection from said select box to another script so it may be put into a mysql database table... my code is as follows: ?php $dir_name = /path/to/images/directory/; $dir = opendir($dir_name); $file_list .= pFORM METHOD=\post\ ACTION=\index_done.php3\ SELECT NAME=\files\$file_name; while ($file_name = readdir($dir)) { if (($file_name != .) ($file_name !=..)) { $file_list .= OPTION VALUE=\$file_name\ NAME=\$file_name\$file_name/OPTION; } } $file_list .= /SELECTbrbrINPUT TYPE=\submit\ NAME=\submit\ VALUE=\select\/FORM/p; closedir($dir); ? within the page... I echo the results like so: ? echo $file_list; ? so far so good, now on the index_done.php3 my code is put into a require statement and the required file code is as follows... ?php $db_name = database_name; $table_name = cm_index; $connection = @mysql_connect(localhost, username, password) or die (Could not connect to database. Please try again later.); $db = @mysql_select_db($db_name,$connection) or die (Could not select database table. Please try again later.); $sql = UPDATE $table_name SET file_name=\$file_name\; $result = @mysql_query($sql, $connection) or die (Could not execute query. Please try again later.); ? I think I need a new pair of eyes to review this and let me know where I am going wrong, also on another note I don't want to put the file in the database table I want to put the path to the file in the database table, any help would be greatly appriciated. =) Jas -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Stuck on db entry from select box...
I had a typo: $sql = UPDATE $table_name SET file_name=\$files\; -Original Message- From: Rick Emery [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 12:29 PM To: 'Jas'; [EMAIL PROTECTED] Subject: RE: [PHP-DB] Stuck on db entry from select box... jas, Ya didn't do what I told you to do. Now, do this: SELECT NAME=\files\; $sql = UPDATE $table_name SET file_name=\$files\; -Original Message- From: Jas [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 12:01 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Stuck on db entry from select box... Ok here is my problem and where I am at this far, first thing I needed to do is to read the contents of a directory and place the results into a select box in a form (accomplished), now where I am stuck is passing the selection from said select box to another script so it may be put into a mysql database table... my code is as follows: ?php $dir_name = /path/to/images/directory/; $dir = opendir($dir_name); $file_list .= pFORM METHOD=\post\ ACTION=\index_done.php3\ SELECT NAME=\files\$file_name; while ($file_name = readdir($dir)) { if (($file_name != .) ($file_name !=..)) { $file_list .= OPTION VALUE=\$file_name\ NAME=\$file_name\$file_name/OPTION; } } $file_list .= /SELECTbrbrINPUT TYPE=\submit\ NAME=\submit\ VALUE=\select\/FORM/p; closedir($dir); ? within the page... I echo the results like so: ? echo $file_list; ? so far so good, now on the index_done.php3 my code is put into a require statement and the required file code is as follows... ?php $db_name = database_name; $table_name = cm_index; $connection = @mysql_connect(localhost, username, password) or die (Could not connect to database. Please try again later.); $db = @mysql_select_db($db_name,$connection) or die (Could not select database table. Please try again later.); $sql = UPDATE $table_name SET file_name=\$file_name\; $result = @mysql_query($sql, $connection) or die (Could not execute query. Please try again later.); ? I think I need a new pair of eyes to review this and let me know where I am going wrong, also on another note I don't want to put the file in the database table I want to put the path to the file in the database table, any help would be greatly appriciated. =) Jas -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Submitting Dynamic Form
I use the PHP manual and the on-line resources/tutorials, such as PHP.net I have lots of time to read these things, because...well...I have no life GRIN I just kind of stumble on these things. -Original Message- From: Chris MacKenzie [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 04, 2002 12:51 AM To: Rick Emery Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Submitting Dynamic Form Ah, I just knew there must be an easy way of doing it. Thanks Rick ! Is there a good reference on stuff like this with some examples ? Am I pushing the friendship ? :-) Rick Emery wrote: $HTTP_POST_VARS or $_POST is an associative array that holds the keys and values for all inputs/selects in form from the submitted page. Use array_keys() to determine the names of all your list boxes to examine each key and its value. Or you can use the list($key,$val) = each($HTTP_POST_VARS) construct to extract each key and value. So then you just walk through the array and process each entry. -Original Message- From: Chris MacKenzie [mailto:[EMAIL PROTECTED]] Sent: Wednesday, April 03, 2002 8:47 AM To: Rick Emery Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Submitting Dynamic Form Hi Rick, Here's a code snippet (less error checking). Basically there could be as many as twnety questions listed with their associated listboxes of possible answers. Also be aware that ms-sql identity type is similar to mysqls autoincrement type except that once a record is deleted, that identity value is never used again. My problem is that since the question_id field is never guaranteed to be sequential and seeing that I have named the answer listboxes with the question_id field, what is a good way to extract the values from the form and perform an update query ? How can I do this if I don't know what the question_id values will be ? -- CUT $sql= SELECT * FROM tbl_exam_questions ORDER BY question_id;; $result=mssql_query($sql,$conn1); $numrows = mssql_num_rows($result); print 'form method=POST action=submit_exam_answers.php name=F1'; ## List All Questions and load the possible answers into list box. for($cnt = 0; $cnt $numrows; $cnt++){ $row = mssql_fetch_array($result); print 'p'.$row[question_text].'/p'; print 'My Answer is: select size=1 name='.$row[question_id].'option selected value=0- SELECT ONE -/option'; ## Now fetch the possible answers and load it into the list box. $pa_sql = SELECT * FROM tbl_exam_answers WHERE question_id = .$row[question_id].;; $pa_result = mssql_query($pa_sql,$conn1); $pa_numrows = mssql_num_rows($pa_result); for($pa_cnt = 0; $pa_cnt $pa_numrows; $pa_cnt++) { $pa_row = mssql_fetch_array($pa_result); print 'option value='.$pa_row[id].''.$pa_row[p_answers].'/option'; } print '/selectbrhrbr'; ## Finished Loading Possible Answers into list box. } print 'pinput type=submit value=Save Answer name=Submitinput type=reset value=Reset Form name=Reset/p/form'; -- CUT Oh, and before I forget tbl_exam_questions.correct_answer holds the relevent id entry from tbl_exam_answers what happened when you extracted the form field names from the DB? Hi All, I'm pretty new to the whole php thing and I'm currently making an multiple choice exam type of thing with php/mssql. The two tables concerned are called tbl_exam_questions and tbl_exam_questions which are defined like so. [tbl_exam_questions] ( [question_id] [int] IDENTITY (1, 1) NOT NULL , [question_text] [varchar] (355) NOT NULL , [correct_answer] [int] NOT NULL ) ON [PRIMARY] [tbl_exam_answers] ( [id] [int] IDENTITY (1, 1) NOT NULL , [question_id] [int] NOT NULL , [p_answers] [varchar] (255) NOT NULL ) ON [PRIMARY] What I'm trying to do is to pull all the questions out and display them with the possible answer in a html form and dropbox. I'm displaying the entire exam on one page, with one submit button on the bottom so that the student can review the answers before finally submitting them. The problem I have is that the form field names are dynamic in that they are set up the value held in tbl_exam_answers.question_id and with ms-sql the identity type is not guarenteed to be incremental, so how can I reference them to send a query back to the DB to mark the student ? Have I painted myself into a corner ? :-/ -- Rgds, Chris MacKenzie Windows: Where do you want to go today ? Mac OS: Where do you want to be tomorrow ? Linux: Are you coming or what ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Database Sorting by date
Ron, What problem are you having? I'm looking at your code, and it's so clean, I could eat off of it. My only suggestion would be that $month will NEVER == NULL. If you are testing for NULL, the test is: if ($month == NULL ) Second, $month will be assigned a value, so it will never be NULL either. BTW, what is in drop.inc? -Original Message- From: Ron Allen [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 04, 2002 8:09 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Database Sorting by date Here is the problem I want to be able to view all or search through the currency lists in the database by the month. Any help would be great!!! Here is the code TABLE FORM name=currency METHOD=POST ACTION=testtest.php TR HEIGHT=20TD COLSPAN=2FONT SIZE=+0 FACE=VERDANA BR TRTD ALIGN=LEFT BSelect a CCSD:/BBRselect name=month onChange=document.currency.submit() option value=NULLSELECT option value=NULLVIEW ALL option value=2002-03March 2002 option value=2002-04April 2002 option value=2002-05May 2002 option value=2002-06June 2002 option value=2002-07July 2002 option value=2002-08August 2002 option value=2002-09September 2002 option value=2002-10October 2002 option value=2002-11November 2002 option value=2002-12December 2002 /TD/tr /table ? include '..\drop.php'; $DBName = currency; $table = currency; $db = mysql_connect($DBhost,$DBuser,$DBpass) or die(Problem connecting); mysql_select_db($DBName) or die(Problem selecting database); if ($month == NULL){ $query = SELECT * FROM $table; $result = mysql_query($query) or die (Query failed); //let's get the number of rows in our result so we can use it in a for loop $numofrows = mysql_num_rows($result); } else { $query = SELECT * FROM $table where DATE = preg_match(Y-m,'$month')) ORDER BY DATE; $result = mysql_query($query) or die (Query failed); //let's get the number of rows in our result so we can use it in a for loop $numofrows = mysql_num_rows($result); } ? ? echo TABLE BORDER=\1\\n; echo TR bgcolor=\#709fff\TDcenterbDATE/b/center/TDTDcenterbEURO /b/center/TDTDcenterbEURO RECONVERSION/b/center/TDTDcenterbKM/b/center/TDTDcenter bKM RECONVERSION/b/center/TDTDcenterbHUF/b/center/TDTDcente rbKUNA/b/center/TD/TR\n; for($i = 0; $i $numofrows; $i++) { $row = mysql_fetch_array($result); //get a row from our result set if($i % 2) { //this means if there is a remainder echo TR bgcolor=\#d3d3d3\\n; } else { //if there isn't a remainder we will do the else echo TR bgcolor=\#f0f0f0\\n; } echo TD.$row['DATE']./TDTD.$row['EURO']./TDTD.$row['EURORECON']. /TDTD.$row['KM']./TDTD.$row['KMRECON']./TDTD.$row['HUF']. /TDTD.$row['KUNA']./TD\n; echo /TR\n; } //now let's close the table and be done with it echo /TABLE\n; ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] How to link a MYSQL table to a dbase file
Can you use a cron (Unix) or at (Windows) job to dump the dbase data to a comma-separated-value table? Then suck up the csv into the mysql databasde. -Original Message- From: Marij Bellen [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 04, 2002 8:37 AM To: '[EMAIL PROTECTED]' Cc: '[EMAIL PROTECTED]' Subject: [PHP-DB] How to link a MYSQL table to a dbase file How can I extract data for a mysql-table from a dbase file? This is the situation: 1) we have a dbase-file with data 2) the dbase-file is put on the server 3) we have a mysql-table that needs to get his data out of this dbase-file. How can I link this mysql-table to this file! !!note: --- I don't mean how I can put the data of the dbase-file into the table, but the table should be linked to the dbase file to get its data! Background: --- we want to upload a file with data from our own local database each night to our internet-mysql-database. In MS-access such a file is called a 'external table.' If this isn't possible and we don't have the ability to use the php-dbase-functions (because of our provider), is there another solution to get the data from the dbase-file automatically in the mysql-database? Can you help me!! Thanks. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Database Sorting by date
Ron, This would indicate that $table was not set. Or that the table indicated in $table does not exist. Print out $query; is it as you expected? Enter the SELECT at the mysql command prompt: what is the result? -Original Message- From: Allen, Ronald L CIV [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 04, 2002 8:41 AM To: Rick Emery Subject: RE: [PHP-DB] Database Sorting by date The query fails when I try to look at a month it says Query Failed Ronald L. Allen (MCSE NT, MCP, CCNA) SR. LAN/WAN Administrator SFOR - Hungary, Croatia [EMAIL PROTECTED] [EMAIL PROTECTED] +36-82-50 ext. 22580 DSN: 760-2000 -Original Message- From: Rick Emery [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 04, 2002 16:43 To: 'Ron Allen'; [EMAIL PROTECTED] Subject: RE: [PHP-DB] Database Sorting by date Ron, What problem are you having? I'm looking at your code, and it's so clean, I could eat off of it. My only suggestion would be that $month will NEVER == NULL. If you are testing for NULL, the test is: if ($month == NULL ) Second, $month will be assigned a value, so it will never be NULL either. BTW, what is in drop.inc? -Original Message- From: Ron Allen [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 04, 2002 8:09 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Database Sorting by date Here is the problem I want to be able to view all or search through the currency lists in the database by the month. Any help would be great!!! Here is the code TABLE FORM name=currency METHOD=POST ACTION=testtest.php TR HEIGHT=20TD COLSPAN=2FONT SIZE=+0 FACE=VERDANA BR TRTD ALIGN=LEFT BSelect a CCSD:/BBRselect name=month onChange=document.currency.submit() option value=NULLSELECT option value=NULLVIEW ALL option value=2002-03March 2002 option value=2002-04April 2002 option value=2002-05May 2002 option value=2002-06June 2002 option value=2002-07July 2002 option value=2002-08August 2002 option value=2002-09September 2002 option value=2002-10October 2002 option value=2002-11November 2002 option value=2002-12December 2002 /TD/tr /table ? include '..\drop.php'; $DBName = currency; $table = currency; $db = mysql_connect($DBhost,$DBuser,$DBpass) or die(Problem connecting); mysql_select_db($DBName) or die(Problem selecting database); if ($month == NULL){ $query = SELECT * FROM $table; $result = mysql_query($query) or die (Query failed); //let's get the number of rows in our result so we can use it in a for loop $numofrows = mysql_num_rows($result); } else { $query = SELECT * FROM $table where DATE = preg_match(Y-m,'$month')) ORDER BY DATE; $result = mysql_query($query) or die (Query failed); //let's get the number of rows in our result so we can use it in a for loop $numofrows = mysql_num_rows($result); } ? ? echo TABLE BORDER=\1\\n; echo TR bgcolor=\#709fff\TDcenterbDATE/b/center/TDTDcenterbEURO /b/center/TDTDcenterbEURO RECONVERSION/b/center/TDTDcenterbKM/b/center/TDTDcenter bKM RECONVERSION/b/center/TDTDcenterbHUF/b/center/TDTDcente rbKUNA/b/center/TD/TR\n; for($i = 0; $i $numofrows; $i++) { $row = mysql_fetch_array($result); //get a row from our result set if($i % 2) { //this means if there is a remainder echo TR bgcolor=\#d3d3d3\\n; } else { //if there isn't a remainder we will do the else echo TR bgcolor=\#f0f0f0\\n; } echo TD.$row['DATE']./TDTD.$row['EURO']./TDTD.$row['EURORECON']. /TDTD.$row['KM']./TDTD.$row['KMRECON']./TDTD.$row['HUF']. /TDTD.$row['KUNA']./TD\n; echo /TR\n; } //now let's close the table and be done with it echo /TABLE\n; ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Editing/Updating Data with Forms
Josh, Your question is too vague to answer. Do you know mysql? Do you know PHP or PERL? If not, learn these, then ask. If so, create code, then ask -Original Message- From: Evans, Josh [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 04, 2002 9:31 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Editing/Updating Data with Forms Can anyone help me with editing/updating data in a table with using a form? Josh Evans ACS Helpdesk [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] How to link a MYSQL table to a dbase file
cron is an application/utility on ALL unix servers. It is used to execute ANY unix command or script at specified dates, times, etc. type the following to learn more: man cron man ctrontab your cron job would execute the command to translate the dbase file to sql. Then execute mysql to read in the sql file -Original Message- From: Marij Bellen [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 04, 2002 8:57 AM To: Php-Db@Lists. Php.Net (E-mail) Subject: Re: [PHP-DB] How to link a MYSQL table to a dbase file I run my site on a linux webserver. I don't really know what a cron is? I can also get a csv file. I also have a function to translate the dbase-file to sql. Is a cron a tool or whatever to automatically load data into the database? == Can you use a cron (Unix) or at (Windows) job to dump the dbase data to a comma-separated-value table? Then suck up the csv into the mysql databasde. = How can I extract data for a mysql-table from a dbase file? This is the situation: 1) we have a dbase-file with data 2) the dbase-file is put on the server 3) we have a mysql-table that needs to get his data out of this dbase-file. How can I link this mysql-table to this file! !!note: --- I don't mean how I can put the data of the dbase-file into the table, but the table should be linked to the dbase file to get its data! Background: --- we want to upload a file with data from our own local database each night to our internet-mysql-database. In MS-access such a file is called a 'external table.' If this isn't possible and we don't have the ability to use the php-dbase-functions (because of our provider), is there another solution to get the data from the dbase-file automatically in the mysql-database? Can you help me!! Thanks. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] New to PHP Need Help
Jason, If you don't have one, I would also recommend a good book that combines PHP and MYSQL interaction. I would strongly suggest the one I cut my PHP teeth on: PHP Essentials by Julie Meloni -Original Message- From: Julie Meloni [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 04, 2002 10:18 AM To: Jason Tobias Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] New to PHP Need Help JT $Location_Info = mysql_fetch_row($result); JT echo p$Location_Info; After you fetch the row, you have to extract the elements from the array that makes up the row. For more than one row in your result, you have to call mysql_fetch_row() again. From http://www.php.net/manual/en/function.mysql-fetch-row.php : mysql_fetch_row -- Get a result row as an enumerated array Examples of using this function follow on the manual page. I would venture to guess that what you really want to use would be mysql_fetch_array(), which also produces an array of results, but _all_ of the rows, not just the first one (and thus does not require additional calls to the function). From http://www.php.net/manual/en/function.mysql-fetch-array.php : mysql_fetch_array -- Fetch a result row as an associative array, a numeric array, or both. With examples also on the manual page. - Julie -- Julie Meloni -- [EMAIL PROTECTED] -- www.thickbook.com Find Sams Teach Yourself MySQL in 24 Hours at http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Please help count ?
$post = ereg_replace((.*) ,\\1, $old_post); If you want to search mysql for this that is something else -Original Message- From: Dave Carrera [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 04, 2002 10:29 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Please help count ? Hi All I have a variable returned by my application. For clarity it is a post code so result could be EX3 T56 or BG56 G67 or CA2 123 But I only need the first bit of the postcode to continue my search. How do I set my var to only include the first bit of the postcode. It is returned in the format shown, so my question might be how I read only the first bit before the space. I fully appreciate any kind of help with this and as always thank you in advance for any help. Dave Carrera Php Developer http://davecarrera.freelancers.net http://www.davecarrera.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] RE: [PHP] New to PHP Need Help
change: $Location_Info = mysql_fetch_row($result); to: $row = mysql_fetch_array($result); $Location_Info = $row['fieldname']; replace fieldname with the real name of your database field -Original Message- From: Jason Tobias [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 04, 2002 9:29 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: [PHP] New to PHP Need Help I am trying to define variables through an anchor tag to retrive data from MySQL, When the script runs it displays Array. I am running WIN2K and IIS 5 echo a href=location.php?location=2Camp Street Cafe/a; Here is the script that is called. ?php $db = mysql_connect(localhost, , ) or die (Could not connect to Localhost); mysql_select_db (ETM, $db) or die (Could not connect to the Database); $table = locations; $location = ($_REQUEST[location]); $query = Select * from $table where Location_ID = $location; $result= mysql_query($query); $Location_Info = mysql_fetch_row($result); echo p$Location_Info; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Problem with the beginning variable
show your code -Original Message- From: Ron Allen [mailto:[EMAIL PROTECTED]] Sent: Wednesday, April 03, 2002 5:43 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Problem with the beginning variable I have a problem with the inital load of my page When it loads it says that the variable is not defined. When I click on search after that it works fine. How do I get PHP to recognize a variable as a certain value without making it a static value? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] figuring out number of months between two dates
select PERIOD_DIFF(DATE_FORMAT(2002-04-01,%Y%m), DATE_FORMAT(2001-0801,%Y%m) ) as dd; +--+ | dd | +--+ |8 | +--+ 1 row in set (0.00 sec) -Original Message- From: John Hughes [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 02, 2002 2:28 AM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] figuring out number of months between two dates I'm trying to get PERIOD_DIFF to work in my quest to count months between dates. I've run into a stumbling block: LEFT(CURRENT_DATE,7) produces 2002-04, as you would expect. LEFT(week_date,7) WHERE week_no = '1' produces 2001-08, again as expected (see table below) But PERIOD_DIFF(LEFT(CURRENT_DATE,7) ,LEFT(week_date,7) ) WHERE week_no = '1' produces 1. The trouble appears to be the '-' in the dates produced by LEFT. When I just put PERIOD_DIFF(200204,200108) the result is 8, which is the correct answer. So, how do I produce the year and month digits without the intervening hyphen so I can feed the data to PERIOD_DIFF? - Original Message - From: John Hughes [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, April 01, 2002 11:56 PM Subject: [PHP-DB] figuring out number of months between two dates I have a table that contains a list of dates. For instance: 2001-08-23 2001-08-27 2001-09-04 (and running through) 2002-06-03 I want to calculate how many months between 2001-08-23 and CURRENT_DATE (which for discussion purposes we'll put at 2002-04-01) and how many months between the first week and the last. I can count the weeks and divide by 4.333 to approximate months, but I was wondering if there was a way to use a PHP function or MySQL's MONTH() to do the job. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] autoincrement
what command are you using? When posting questions, give all details...wee can't read your mind -Original Message- From: Daniel Broome [mailto:[EMAIL PROTECTED]] Sent: Monday, April 01, 2002 9:33 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] autoincrement I am trying to add auto increment to a table I have already created in phpMyAdmin but I keeps coming up with an error. what can I do to fix this? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Return the last record on database
SELECT * FROM mytable ORDER BY some_field DESC LIMIT 1; -Original Message- From: Ron [mailto:[EMAIL PROTECTED]] Sent: Friday, March 29, 2002 7:39 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Return the last record on database My database has several records an ID is the primary key I want to diplay output using PHP to a table (no biggy) The problem for me is I just want the record of the database to be displayed!!! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] end of file
while( $row = mysql_fetch_array($result) ) { } -Original Message- From: Natividad Castro [mailto:[EMAIL PROTECTED]] Sent: Friday, March 29, 2002 2:59 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] end of file Hi to all, how can I handle when the recordset reach the last record? is it possible to use eof? e.g. if there is no more record, do something Thanks in advanced Nato -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL/PHP Update
Jason, this is intriguing. Please show us a bit more code before the mysql_query() call. -Original Message- From: Jason [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 28, 2002 1:54 AM To: Php-Db Subject: [PHP-DB] MySQL/PHP Update I'm trying to update my MySQL database, but it doesn't seem to be taking. my code is: mysql_query(update prod_list set prod_manu=$prod_man where sku='$prod'); where prod_manu is an int $prod_man is an int sku is a varchar $prod is text mysql_query() comes back successful, and just to be sure I echoed mysql_error() and nothing came back. What am I doing wrong? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Selecting Drop Down Value From DB to Edit
I'm trying to decipher: when I select the record to edit the drop-downlist has the first option as the value instead of what the corresponding StateID in the column reads. How can I correct this? The form to insert and edit have the below code and correctly insert the StateID What exactly is happening? Run the script, do a View Source on the resulting page; show us the HTML generated. -Original Message- From: Steve Fitzgerald [mailto:[EMAIL PROTECTED]] Sent: Tuesday, March 26, 2002 5:22 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Selecting Drop Down Value From DB to Edit I have the below code that populates a drop down list. The code will correctly insert the value $StateID into another a table. The problem I am running into is that when I select the record to edit the drop-downlist has the first option as the value instead of what the corresponding StateID in the column reads. How can I correct this? The form to insert and edit have the below code and correctly insert the StateID. I tried to write and if statement to state that if the StateID were == to the StateID in he table then print selected, but I think I am missing something. Any suggestions? Thanks. ?php // populates state drop-down list $get_stateid_query = mysql_query(SELECT * FROM State INNER JOIN RaceResults ON State.StateID WHERE RaceID='$RaceID'); echo select name=\StateID\\n; while ($myrow = mysql_fetch_array($get_stateid_query)) { echo ' option value='.$myrow[StateID].''.$myrow[StateName]./option\n; } echo /select\n; ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Big Problems Connecting to MySQL
You need to ensure that mysql.sock has the correct read-write-execute permissions Check the mail list archives; this question is asked and answered EVERY week -Original Message- From: Liam Gibbs [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 27, 2002 1:17 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Big Problems Connecting to MySQL Hi, I'm having some big problems even running any mysql_connect commands. I get the results at the bottom of this e-mail from running a simple mysql_connect command. Some things to consider are that I'm accessing my web site through port 8080, and I'm not sure what username, password, or hostname I should be using. Does anyone know how to find out what username, password, and hostname I should be using? And should I include my port number after my hostname? Sorry. I'm new at this stuff. === Warning: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111) in /index.php on line 9 Warning: MySQL Connection Failed: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111) in /index.php on line 9 __ Do You Yahoo!? Yahoo! Movies - coverage of the 74th Academy Awards® http://movies.yahoo.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Very wierd problem ;-(
show you code and db table struct -Original Message- From: Dave Carrera [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 27, 2002 2:38 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Very wierd problem ;-( Hi All I will try and explain as clearly as I can I have a message board type of script. User logs in = no prob User posts message = No prob can see message on db and retrieve a list of new posts. Now the prob. I am to reply to the message via an admin area by selecting the message fron a generated list abd click on get message and it should give back what was said. When I log in and or create a new user and leave a message I can get all the details and send a reply. But when I try and get back the details of a message that someone else has left I cant get the message and cant reply. Got me foxed. What could I be doing wrong? Any ideas as always appreciated. Dave Carrera Php Developer http://davecarrera.freelancers.net http://www.davecarrera.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] include() statement hell!
did you start each include file with: ?php ? If not, PHP treats the code within as straight text -Original Message- From: Brad Melendy [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 27, 2002 5:03 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] include() statement hell! Ok, I've spent some time reading the docs at php.net and I'm still confused. After a couple hours, I have an include file working with a statement like: include (dblib.inc); However, to add to my confusion, I've got a second include file statement on the next line: include (userlib.inc); And that doesn't work. Most crazy of all, if I just put the darn functions all in the PHP file that is trying to call the include files, everything works perfectly. So far I have my include_path line in the pho.ini file set to no value since I'm just using include files that exist in the same directory as the calling php file. this after I could NOT get the files to be properly recognized from their own include directory. As far as I'm concerned, you should be able to include a relative path with the included filename and have it work. Too bad that doesn't work in PHP. So, long story short, I'm about to give up on include statements and just copy and paste my functions all over the place. Does anyone have any ideas why this is so difficult for me? What am I missing? This stuff is easy in ASP but PHP is giving me serious heart-ache. :-( Thanks for any tips or suggestions. Brad -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] procedures?
I suggest subscribing to the mysql mailing list and asking the question. [EMAIL PROTECTED] -Original Message- From: Chris Payne [mailto:[EMAIL PROTECTED]] Sent: Monday, March 25, 2002 7:47 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] procedures? Hi there, Where can I find information in PLAIN terms about how to use procedures in MySQL? More importantly I want to be able to write my own so I don't have to keep re-using the same code in the way that I do now to access, delete etc from db's. Thank you :-) Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] 2 related ?'s email users
There's a bunch of ways to accomplish what you request. Therefore, I'll offer what I would do. Other folks, more brilliant than, will provide better ideas. 1. Do you have access to the mail server? For instance, I run qmail on my SOHO system and, therefore, have full sys-admin rights. If you do, you can include a unique identifier in the return address. When the newly-signed user responds to the email, your mail server could send the email to the authentication program which would then update the database to reflect a valid user. 2. I would search for all users name Fred%: SELECT username FROM mytable WHERE username LIKE Fred% ORDER BY username; in your PHP program: $base = Fred; //you've set $base from the submitted form $query = SELECT username FROM mytable WHERE username LIKE $base% ORDER BY username; $result = mysql_query($query) or die(...); if( mysql_num_rows($result) == 0 ) { ... this is a unique name... } else { $i = 0; $validname = $base.1; while( list($uname) = mysql_fetch_array($result) ) { if( ! strcmp($uname, $validname ) { $i++; $ validname = $base${i}; } } } Therefore, $validname holds the unused user name to suggest. -Original Message- From: Dave Carrera [mailto:[EMAIL PROTECTED]] Sent: Monday, March 25, 2002 8:15 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] 2 related ?'s email users Hi All I hope you can shed some light on the logic behind these 2 issues. 1) How do I make an email verify type of thing? So user enter there email address as part of the sign up process and we send an email to that address. That bit I've got. But how do you check the reply to the address stored and then activate the account. It's a for online support manager im writing hence the importance of a verified email address. 2) Suggest a Username? I have seen some places that when you put in an onscreen name and click send it checks against the list of usernames already stored and if it matches it comes back an error saying that username already exists but how about this one, which is the name you chose plus a incremental number. So visitor puts in say Fred but Fred exists and so does Fred up to Fred19. How do I check this and offer Fred20 as a suggestion. I hope someone can help with this. As always I thank you in advance of any help, code samples or pointers. Dave Carrera Php Developer http://davecarrera.freelancers.net http://www.davecarrera.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] delete statement question
if you are using mysql 4.x, you might try: DELETE answers FROM exam e, questions q, answers a WHERE a.question_id=q.question_id q.exam_id=e.exam_id; I've not tested this, though. -Original Message- From: Andrés Felipe Hernández [mailto:[EMAIL PROTECTED]] Sent: Monday, March 25, 2002 4:42 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] delete statement question Hi, I hope you can help me with this: I have these 3 tables. exam ( exam_id ) questions ( question_id exam_id ) answers ( answer_id question_id ) I am wondering if i can delete all the rows for answers linked to a given exam using only one delete statement. Thanks in advance, andres -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] delete statement question
this solution will not work for mysql databases, as mysql does not support sub-selects -Original Message- From: Bill Morrow [mailto:[EMAIL PROTECTED]] Sent: Monday, March 25, 2002 2:02 PM To: Andr?s Felipe Hern?ndez Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] delete statement question On Mon, Mar 25, 2002 at 02:42:08PM -0800, Andr?s Felipe Hern?ndez wrote: Hi, I hope you can help me with this: I have these 3 tables. exam ( exam_id ) questions ( question_id exam_id ) answers ( answer_id question_id ) I am wondering if i can delete all the rows for answers linked to a given exam using only one delete statement. Thanks in advance, andres delete answers where question_id in (select question_id from questions where exam_id=X) I assume there isn't a one-to-one relationship between questions and answers? If there is, your database is overnormalized. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] I have been trying to introduce data in a MySQL database but I don't achieve it.
First: what error are you getting? Second, make your code more readable and easier to debug: $query = INSERT INTO usuario (USU_USUARIO, USU_CLAVE, USU_NOMBRE, USU_EMPRESA, USU_DIRECCION, USU_TELEFONO, USU_CIUDAD, USU_DEPARTAMENTO, USU_PAIS, USU_EMAIL, USU_REPCLAVE, USU_TIPCLIENTE). VALUES ('$Cli_usuario','$Cli_Password1','$Cli_Nombre','$Cli_Empresa', . '$Cli_Direccion','$Cli_Telefono','$Cli_Ciudad','$Cli_Departamento','$Cli_Pa is','$Cli_Email','$Cli_RespClave', 'M'); print $query; //do this to ensure you are sending the command you are expecting to send $result = mysql_query($query) or die(Error: .mysql_error()); -Original Message- From: Sergio Cornejo [mailto:[EMAIL PROTECTED]] Sent: Monday, March 25, 2002 2:29 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] I have been trying to introduce data in a MySQL database but I don't achieve it. Hi. I have been trying to introduce data in a MySQL database but I don't achieve it. I work with MySQL 3.23.47 for windows 98, Apache 1.3.23 for windows and PHP4. The form code: form name=frm_Registro method=post action=tievir/regMay.php table width=91% border=0 name=tbl_login bgcolor=#33CCFF tr td width=18% height=27font color=#99 face=Verdana, Arial, Helvetica, sans-serifNombre:/font/td td height=27 colspan=2font face=Verdana, Arial, Helvetica, sans-serif color=#99 input type=text name=Cli_Nombre maxlength=50 size=50 /font /td /tr tr td width=18%font color=#99 face=Verdana, Arial, Helvetica, sans-serifEmpresa:/font/td td colspan=2 font color=#99 face=Verdana, Arial, Helvetica, sans-serif font size=-1 input type=text name=Cli_Empresa maxlength=50 size=50 br Si no pertenece a alguna empresa coloque quot;Independientequot;/font/font/td /tr tr td width=18% pfont color=#99 face=Verdana, Arial, Helvetica, sans-serifDireccioacute;n:/font/p /td td colspan=2font color=#99 face=Verdana, Arial, Helvetica, sans-serif input type=text name=Cli_Direccion maxlength=60 size=60/font/td /tr tr td width=18%font color=#99 face=Verdana, Arial, Helvetica, sans-serifTeleacute;fono:/font/td td colspan=2font color=#99 face=Verdana, Arial, Helvetica, sans-serif input type=text name=Cli_Telefono maxlength=7 size=10 /font/td /tr tr td width=18%font color=#99 face=Verdana, Arial, Helvetica, sans-serifCiudad:/font/td td colspan=2font color=#99 face=Verdana, Arial, Helvetica, sans-serif input type=text name=Cli_Ciudad maxlength=25 size=25 /font/td /tr tr td width=18%font color=#99 face=Verdana, Arial, Helvetica, sans-serifDepartamento:/font/td td colspan=2font color=#99 face=Verdana, Arial, Helvetica, sans-serif input type=text name=Cli_Departamento maxlength=25 size=25 /font/td /tr tr td width=18%font color=#99 face=Verdana, Arial, Helvetica, sans-serifPais:/font/td td colspan=2font color=#99 face=Verdana, Arial, Helvetica, sans-serif input type=text name=Cli_Pais maxlength=25 size=25 /font/td /tr tr td height=19 width=18%font color=#99 face=Verdana, Arial, Helvetica, sans-serife-mail:/font/td td height=19 colspan=2font color=#99 face=Verdana, Arial, Helvetica, sans-serif input type=text name=Cli_Email maxlength=60 size=60 /font/td /tr tr td height=19 width=18%font color=#99 face=Verdana, Arial, Helvetica, sans-serifUsuario:/font/td td height=19 width=16%font color=#99 face=Verdana, Arial, Helvetica, sans-serif input type=text name=Cli_Usuario maxlength=15 size=17 nbsp;nbsp;/font/td td height=19 width=66%font color=#99 face=Verdana, Arial, Helvetica, sans-serif size=-1Debe ser de miacute;nimo 8 y maacute;ximo 15 caracteres. Solo acepta caracteres entre la A..Z y nuacute;meros del 0..9./font/td /tr tr td height=19 width=18%font color=#99 face=Verdana, Arial, Helvetica, sans-serifPassword:/font/td td height=19font color=#99 face=Verdana, Arial, Helvetica, sans-serif input type=password name=Cli_Password1 maxlength=8 size=10 /font/td td height=19font color=#99 face=Verdana, Arial, Helvetica, sans-serif size=-1Debe ser de miacute;nimo 5 y maacute;ximo 8 caracteres. Solo acepta caracteres entre la A..Z y nuacute;meros del 0..9./font/td /tr tr td height=19 width=18% pfont color=#99 face=Verdana, Arial, Helvetica, sans-serifConfirmacioacute;nbr del Password:/font/p /td td height=19font color=#99 face=Verdana, Arial, Helvetica, sans-serif input type=password name=Cli_Password2 maxlength=8 size=10 /font/td td height=19font color=#99 face=Verdana, Arial, Helvetica, sans-serif size=-1Vuelva a digitar el
RE: [PHP-DB] delete statement question
Per my original email; you must be running MYSQL 4.0 or later. If you are runnig version 3.x, as it appears you are, then this suggestion will NOT work -Original Message- From: Andrés Felipe Hernández [mailto:[EMAIL PROTECTED]] Sent: Monday, March 25, 2002 5:59 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] delete statement question Rick, thanks for the idea but actually it wouldnt work :( take a look: mysql delete answers - from exam e, questions q, answers a - where a.question_id=q.question_id and q.exam_id=e.exam_id; ERROR 1064: You have an error in your SQL syntax near 'answers from exam e, questions q, exam_an' at line 1 so i think the problem is that you cant do DELETE something FROM... i think the solution is more like the one Bill Morrow proposed, even though he is using a subselect and i am using my sql. Any ideas? thanks for the help so far, andres - Original Message - From: Rick Emery [EMAIL PROTECTED] To: Andr?s Felipe Hern?ndez [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, March 25, 2002 12:03 PM Subject: RE: [PHP-DB] delete statement question this solution will not work for mysql databases, as mysql does not support sub-selects -Original Message- From: Bill Morrow [mailto:[EMAIL PROTECTED]] Sent: Monday, March 25, 2002 2:02 PM To: Andr?s Felipe Hern?ndez Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] delete statement question On Mon, Mar 25, 2002 at 02:42:08PM -0800, Andr?s Felipe Hern?ndez wrote: Hi, I hope you can help me with this: I have these 3 tables. exam ( exam_id ) questions ( question_id exam_id ) answers ( answer_id question_id ) I am wondering if i can delete all the rows for answers linked to a given exam using only one delete statement. Thanks in advance, andres delete answers where question_id in (select question_id from questions where exam_id=X) I assume there isn't a one-to-one relationship between questions and answers? If there is, your database is overnormalized. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Forms
First: cross-posting to multiple lists...not nice. Most PHP folks are on both lists. Second: your first sentence seems to indicate that unknowledgeable people inhabit the PHP list, vice the PHP-DB list. H GRIN Third: what error do you get when you get the parsing error? -Original Message- From: Ron [mailto:[EMAIL PROTECTED]] Sent: Friday, March 22, 2002 7:05 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Forms I know this is suppose to be databases, but the most knowledgeable people seem to be in here. This is the first time that I have tried to conquer a form in PHP(which I obviously am not doing) so that I can have a total PHP script page and move away from HTML. Here is my code as followed by my book (PHP Black Book) some variables have been changed ? $group[] = Communications; $group[] = Network Section; $group[] = Wire Section; $group[] = Phones; $question[section] = array(type = radio, question = What section is this Trouble Ticket being opened for?, list = $group); function form($page, $question) { $text = ; while(list($group, $v) = each($question)) { if(strlen($text)) {$text .= BR;} $function = form_ . $v[type]; $text .= $function($name. $v); } return(form action=\ttsubmit.php . $page . \ method=\post\ . $text . input type=\submit\ name=\submit\ . value=\Submit\ . /form); } function form_radio($group, $parameters) { $output = ; while(list($k, $v) = each($parameters[list])) { if(strlen($output)) { $output .= BR; } $output .= input name=\itsumit.php . $group . \ . type=\radio\ . value=\ . $v . \; if(isset($paramater[default]) and $v == $paramater[default]) { $output .= checked; } $output .= . $v . \n; } return($output); } //print(form (tt.php, form_radio(group,parameters)); When the last line is commented out there is no output at all. When I uncomment the last line I get a parsing error. I have been trying to figure this out, but I really lost here! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] marking DB entries...
store and validate a username and password with each user's info -Original Message- From: Ljungan [mailto:[EMAIL PROTECTED]] Sent: Friday, March 22, 2002 11:07 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] marking DB entries... Im making an adressbook using PHP and mySQL. I want each user to have access only to his/hers adressinputs. Now Im wondering how I gonna solve this, ofcourse its very easy just to create a table for each user but then the hole idea of database loose its purpose =). How can I mark each input so that only the specific user who entered the information can access it? If two users enters the exact same information I want them both to have access to it... I was thinking about a table looking like this: name CHAR(30), adress CHAR(30), email CHAR(30), phonenumber INT(20), authority ENUM()//here is my thought-- I was thinking I could save the users name in authority and thereby marking that this entry was made bye the specific person. Is it possible to use this? Please give me a few pointers or better, give me a website where I can read about it... thanks! /Ljungan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] marking DB entries...
well...what the bloody hell are you looking for from us? -Original Message- From: Ljungan [mailto:[EMAIL PROTECTED]] Sent: Friday, March 22, 2002 11:29 AM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] marking DB entries... well that wasn't very helpful... I have two tables already, users and adressreg ??? /ljungan Rick Emery [EMAIL PROTECTED] skrev i meddelandet [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... store and validate a username and password with each user's info -Original Message- From: Ljungan [mailto:[EMAIL PROTECTED]] Sent: Friday, March 22, 2002 11:07 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] marking DB entries... Im making an adressbook using PHP and mySQL. I want each user to have access only to his/hers adressinputs. Now Im wondering how I gonna solve this, ofcourse its very easy just to create a table for each user but then the hole idea of database loose its purpose =). How can I mark each input so that only the specific user who entered the information can access it? If two users enters the exact same information I want them both to have access to it... I was thinking about a table looking like this: name CHAR(30), adress CHAR(30), email CHAR(30), phonenumber INT(20), authority ENUM()//here is my thought-- I was thinking I could save the users name in authority and thereby marking that this entry was made bye the specific person. Is it possible to use this? Please give me a few pointers or better, give me a website where I can read about it... thanks! /Ljungan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Multiple SELECT querys
$query = SELECT myvalue FROM mytable WHERE some_condition; $result = mysql_query($query) or die(Error: .mysql_error()); $srch = ; while( list($myvalue) = mysql_fetch_array($result) { $srch .= $myvalue, ; } $srch = substr($srch, 0, -2); $query = SELECT * FROM other_table WHERE this_val IN($srch); $result = mysql_query($query) or die(Error: .mysql_error()); -Original Message- From: Morten Nielsen [mailto:[EMAIL PROTECTED]] Sent: Friday, March 22, 2002 2:28 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Multiple SELECT querys Hi, I make a SELECT in a mySQL database. It returns a variable, which contains 10 values. I then need to make another SELECT in a new database where I have to use the previous 10 values in the WHERE sentence. How can I do this? Regards, Morten -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Re: Relational database
What do you mean last record in a table? What are you REALLY trying to do here? Do you want the last entry made according to a specific criteria? -Original Message- From: Ron [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 21, 2002 9:20 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Re: Relational database Is there a way under mysql to identify the last record in a table so that I can pull information that I need from that entry. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Re: Relational database
Huh -Original Message- From: Ron [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 21, 2002 9:30 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Re: Relational database But can you do that in PHP before you pull info from it -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Selecting Alphabetically
SELECT * FROM mytable WHERE record_name REGEXP ^[a-h] -Original Message- From: Jordan Elver [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 21, 2002 6:05 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Selecting Alphabetically Hi, Could anyone point me in the right direction with this one please. I have a table of records wit a field of artists. I want to select all the records which begin with the letter a-h then i-p etc What is the best way to do this? Cheers, Jord -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] LAST_INSERT_ID()
use mysql_last_id() -Original Message- From: Morten Nielsen [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 21, 2002 2:30 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] LAST_INSERT_ID() Hi, In the PHP manual under the function mysql_insert_id() function they have the following line: The value of the MySQL SQL function LAST_INSERT_ID() always contains the most recently generated AUTO_INCREMENT value, and is not reset between queries. How do I get to use the function LAST_INSERT_ID()? When I use it in my php code it is not recognised. Regards, Morten -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] LAST_INSERT_ID()
I mean: mysql_insert_id() -Original Message- From: Rick Emery [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 21, 2002 2:28 PM To: 'Morten Nielsen'; [EMAIL PROTECTED] Subject: RE: [PHP-DB] LAST_INSERT_ID() use mysql_last_id() -Original Message- From: Morten Nielsen [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 21, 2002 2:30 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] LAST_INSERT_ID() Hi, In the PHP manual under the function mysql_insert_id() function they have the following line: The value of the MySQL SQL function LAST_INSERT_ID() always contains the most recently generated AUTO_INCREMENT value, and is not reset between queries. How do I get to use the function LAST_INSERT_ID()? When I use it in my php code it is not recognised. Regards, Morten -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Need Help with returning new id's
first, it helps if you show us your REAL code. The query statement you showed below would obviously not work (it's missing the mysql_query part. Second, when executing mysql_query() ALWAYS include the or die(mysql_error()) part to aid diagnostics. Third, your query could not possibly work at the mysql command line; you've misplaced the AS construct at the end of the query. $maxid = select max(tableid) as largestid from table; $result = mysql_query($maxid) or die(Error: .mysql_error()); list($mymaxidvalue) = mysql_fetch_array($result); echo $mymaxidvalue; -Original Message- From: Jason McCormack [mailto:[EMAIL PROTECTED]] Sent: Tuesday, March 19, 2002 12:31 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Need Help with returning new id's Hello All, I am trying to return the largest id for a table and then print the value to a page. My query works fine in MySQL, the problem is getting the value to show in a web page with php. This is what I am trying to process. TABLEID | VALUE 1 | Test 2 | Test 2 3 | Test 3 In the sample table above I am trying to pull back a value of 3 and print to a web page via php. $maxid = select max(tableid) from table as largestid; // db_connect is my database connection. I know this works because I have other pages that return // results based on my queries without any problems $run_query = ($maxid,$db_connect); This is were I get a bit lost. I have tried using all sorts of various mysql functions without success $row = mysql_fetch_row($run_query); $mymaxidvalue = $row[0]; echo $mymaxidvalue; As I stated above I have tried many different ways to get the desired results but have been unsuccessful. Any help would be greatly appreciated. Thanks, Jason -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] date problem
if( strcmp($date,-00-00) ) { do something} -Original Message- From: its me [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 14, 2002 12:16 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] date problem i have an input field in a form that accept date called $date and in databse i made it of type $date so its defualt is -00-00 the problem is when i say: if($date!=-00-00) {do something} he doesn't understand $date!=-00-00 Rehab M.Shouman - Express yourself with a super cool email address from BigMailBox.com. Hundreds of choices. It's free! http://www.bigmailbox.com - -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Delete problem
MySQL does not currently support sub-selects. The manual says: DELETE [LOW_PRIORITY | QUICK] FROM table_name [WHERE where_definition] [ORDER BY ...] [LIMIT rows] Did you review the manual first? -Original Message- From: Riccardi Moreno [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 13, 2002 9:48 AM To: Php List; Mysql List Subject: [PHP-DB] Delete problem Hi all, I'm trying to delete records with this query on php program: delete from Bands where ID_ALBUM IN (select ID_ALBUM from Albums where ID_GROUP = '$group') I use it on MSSQL and work fine but on mysql don't work, there's some other query that make the same result on mysql Thank's all - Moreno Riccardi - www.webtrade.it -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] SQL Question
SELECT DISTINCT city FROM addresses; -Original Message- From: Kevin Diffily [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 13, 2002 1:05 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] SQL Question Hello, I have a simple SQL Question. I would like to take the column city in database addresses and find out which cities are available in it. In other words if the following values are in there: city El Paso Burlington New York New York El Paso Burlington I would like it to return El Paso New York Burlington I know that it would something like SELECT `city` FROM `addresses` WHERE ?? Thanks Kevin Diffily InterNetWorkingSolutions Enterprise Class Solutions for All Enterprises 318 Last Road, Cabot, VT 05647 USA VOICE: 1.866.inetws.net (Toll Free) FAX: 1.888.726.9030? (Toll Free) Sales: [EMAIL PROTECTED] General Information:[EMAIL PROTECTED] Website Hosting:[EMAIL PROTECTED] Systems Administration Services: [EMAIL PROTECTED] Technical Support Training Services: [EMAIL PROTECTED] Shop For it On Amazon:http://kevin.inetws.net/amazon Instant Messaging Username: AIM, IRC, Jabber, MSN, Yahoo: inetwsnet ICQ: 120778694 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] select rows from more than one table, how?
First: show us your exact query Second: show us your exact error response Third: show us your exact code and table structure -Original Message- From: Sander Peters [mailto:[EMAIL PROTECTED]] Sent: Monday, March 11, 2002 3:03 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] select rows from more than one table, how? Hello, I want to make a query that will select rows from more than one query, does anybody know how to do that? I already tried this: SELECT * FROM table1, table2 WHERE (conditions) But I get a error with this query. I also looked at the mysql site for this case, but I didn't find any answer (I guess it's there but I just can't find it!) Can somebody help me? Thanks in advance! -- Met vriendelijke groet / With Greetings, Sander Peters site: http://www.visionnet.nl/ email: mailto:[EMAIL PROTECTED] webmail: mailto:[EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] how can i join this two selects
Vieliecht: SELECT kat_id,immo_id FROM immo_kat WHERE immo_id=318 (kat_id = '1' OR kat_id = '35' OR kat_id = '34') ORDER BY immo_id; -Original Message- From: Michael Plies [mailto:[EMAIL PROTECTED]] Sent: Monday, March 11, 2002 4:01 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] how can i join this two selects hy, maybe im blind about this problem: thats a row of my table(sql follows at the endof that mail) named immo_kat kat_id - immo_id - cr_uid - tstamp -- --- -- -- ... 35 - 318- 1- 1015874898 34 - 318- 1- 0 ... now i like to get all immo_id's which have the same kat_id's like the rows with the immo_id 318. With one query means a join between two selects - I. SELECT kat_id FROM immo_kat where immo_id = 318 an with the result : II. SELECT immo_id FROM immo_kat where kat_id = '1' OR kat_id = '35' OR kat_id = '34' Group by immo_id I'm sorry - sound really easy - but maybe its to late I would be very glad if someone can help me heres the sql if needed # # Tabellenstruktur für Tabelle `immo_kat` # CREATE TABLE immo_kat ( kat_id int(11) NOT NULL default '0', immo_id int(11) NOT NULL default '0', cr_uid int(11) NOT NULL default '0', tstamp int(11) NOT NULL default '0', KEY kat_id (kat_id) ) TYPE=MyISAM; # # Daten für Tabelle `immo_kat` # INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES (1,318,1,''); INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES (1,277,1,''); INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES (35,318,1,''); INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES (34,277,1,''); INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES (34,318,1,''); INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES (36,315,1,1015874898); INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES (34,315,1,1015874898); INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES (1,299,1,1015876885); INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES (34,311,1,1015876881); INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES (36,313,1,1015876875); INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES (34,327,1,1015875896); INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES (1,289,1,1015876892); INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES (34,289,1,1015876892); INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES (36,289,1,1015876892); INSERT INTO immo_kat (kat_id, immo_id, cr_uid, tstamp) VALUES (35,298,1,1015876904); -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] mysql LIMIT and ORDER BY problem
it works for me. What do your data and table structures look like? -Original Message- From: Fredrik Wahlberg [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 19, 2002 4:55 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] mysql LIMIT and ORDER BY problem I have a strange problem with LIMIT. When I use it like SELECT * FROM table LIMIT 0, 10 it works fine. When I add a sort and write the query like SELECT * FROM table ORDER BY col ASC LIMIT 0, 10 I get no results. What am I missing? /Fredrik -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] mysql and auto_increment
First, what do you mean by regs? If I understand your question, you want to know if mysql will re-use an old auto_increment value that has been deleted. The answer is yes and no. If you say: DELETE FROM mytable; then the next insertion will cause the auto_increment value to begin at 1 If you say: DELETE FROM mytable WHERE myfield0 then the next insertion will cause the auto_increment value to begin where the auto_increment left off. -Original Message- From: Nautilis [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 20, 2002 9:26 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] mysql and auto_increment Hi everyone My question is very simple, so i hope the answer will too :) Well i have an index field in my table which is set as auto_increment. Well question is, it's possible that mysql use values that have alredy been deleted from older regs? Thx in advance! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] SQL
I tried the HAVING clause. it fails. This requires sub-selects or multiple tables -Original Message- From: DL Neil [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 20, 2002 10:27 AM To: Jonathan Underfoot; Rick Emery; [PHP-DB] Subject: Re: [PHP-DB] SQL Jonathan, The original query doesn't work because the WHERE clause is evaluated earlier than the GROUP/COUNT(). Try putting num1 and num2 in a HAVING clause. Regards, =dn ok... authorizations and charges... two tables.. Card Number 1 gets authorized 20 times for use (20 rows in the authorizations table) and when the transaction is completed they get charged 20 times (20 rows in the charges table) .. however we've been finding that authorizations are not always ending in charges. (Essentially people are cheating the system) and I need to find out who. Card numbers are the same... I ran this without the num1=num2 and it gave me very bad results.. I think my counts are off base. num1 and num2 were the same for all of them. I know this isn't the case. so... SELECT authtable.cardnumber, count(authtable.cardnumber) as num1, count(chargetable.cardnumber) as num2 FROM authtable, chargetable WHERE authtable.cardnumber = chargetable.cardnumber AND num1 != num2 is what I'm shooting for logically.. once again.. I think the counts are messed up... (I might be completely off base here..) How could you possibly have such a condition exist? That is, what relation do the counts have to the contents of the name field? What ARE you trying to really accomplish? Is it possible to do a comparison of values from a count... for example... SELECT table1.name, count(table1.name) as num1, count(table2.name) as num2 FROM table1, table2 WHERE table1.name = table2.name AND num1 = num2 This sort of thing dosent work for me. How do I reffrence a count later in the where clause? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Problem displaying dates
Mate, what code/function are you using to convert the dates? what do your data look like in the table (structure, examples)? -Original Message- From: George Pitcher [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 19, 2002 8:01 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Problem displaying dates Hi all, I've just moved my MySQL db and php scripts over from W2K to Linux and for some reason my dates are coming across as '-00-00' even though, viewing the db in MySQLFront, they look fine (actual dates). When I hosted this on Win2K it worked fine. I use a function to convert the date format from '-00-00' to 'dd/mm'' but have tried displaying the dates with and without the use of this function with no success. Any suggestions? George in Edinburgh -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Need some code examples on creating tables for mysql in php
Huh $query = CREATE TABLE mytable (. field1 int,. field2 varchar(50),. field3 decimal(6,2),. field4 int,. field5 int ); mysql_query($query) or die(Error: .mysql_error()); -Original Message- From: CrossWalkCentral [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 19, 2002 12:26 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Need smoe code examples on creating tables for mysql in php Need some code examples on creating tables for mysql in php can any one help me on this . I searched the php.net site and only found info on creating a database I just want to create a php script that will make 2 tables with lets say 5 fields each in them. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] SQL
How could you possibly have such a condition exist? That is, what relation do the counts have to the contents of the name field? What ARE you trying to really accomplish? -Original Message- From: Jonathan Underfoot [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 19, 2002 2:57 PM To: [PHP-DB] Subject: [PHP-DB] SQL Is it possible to do a comparison of values from a count... for example... SELECT table1.name, count(table1.name) as num1, count(table2.name) as num2 FROM table1, table2 WHERE table1.name = table2.name AND num1 = num2 This sort of thing dosent work for me. How do I reffrence a count later in the where clause? Thanx -Jonathan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Problem connecting to db on Linux
Have you spelled the name of the database correctly, including case sensitivity? What error message are you getting to indicate failure? -Original Message- From: George Pitcher [mailto:[EMAIL PROTECTED]] Sent: Monday, February 18, 2002 8:21 AM To: Greg Donald; [EMAIL PROTECTED] Subject: Re: [PHP-DB] Problem connecting to db on Linux Greg, et al, This is the contents of the include file: ?php $link = mysql_connect ('localhost', 'root', '*') or die (Could not select db); mysql_select_db ('Heronsql') or die (Could not connect); ? I have also tried it with the following: ?php $link = mysql_connect ('localhost', 'root', '*'); echo mysql_errno().: .mysql_error().BR; mysql_select_db ('Heronsql'); echo mysql_errno().: .mysql_error().BR; ? Te results for this were: 0:0 0:0 I have reinstalled my Mandrake (MySQL/PHP4.0.6/Apache) and I am about to retest so I'll report back soon. George - Original Message - From: Greg Donald [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, February 18, 2002 2:08 PM Subject: Re: [PHP-DB] Problem connecting to db on Linux I've been working with PHP/MySQL on Win NT and Win 2000 for a few weeks. I've now set up a Linux machine (Mandrake 8.1 on Dell laptop) and have moved my files across. I use an include file which logs on to the MySQL server and then connects to the database. It performs the login ok but not the select db part. I tried creating a db using a php script and then selecting it and got the same problem. I'm new on Linux so it might be something in the configuration which needs working on. Any suggestions? Well, if you had posted some code, someone might have seen the error... :( Anyway, here is how i do it: if($db = mysql_pconnect($dbhost, $dbuser, $dbpasswd)){ mysql_select_db($dbname, $db); } else { echo mysql_error(); exit; } Greg Donald - http://destiney.com/ http://phprated.com/ | http://phplinks.org/ | http://phptopsites.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Problem connecting to db on Linux
Do you have your error messages crossed? I ask, because I would think your cannot select message would go with your mysql_select_db() and your cannot connect would go with your mysql_connect() -Original Message- From: George Pitcher [mailto:[EMAIL PROTECTED]] Sent: Monday, February 18, 2002 8:48 AM To: Rick Emery; Greg Donald; [EMAIL PROTECTED] Subject: Re: [PHP-DB] Problem connecting to db on Linux Rick, I snipped the code from my windoze system. I did have to change the case of the dbname to reflect the Linux version (all lc). The error message I got (not displayed on screen but visible on 'view source') was 'Could not connect' which, to me means that it got past the login to server and stalled on the select db part? George - Original Message - From: Rick Emery [EMAIL PROTECTED] To: 'George Pitcher' [EMAIL PROTECTED]; Greg Donald [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, February 18, 2002 2:31 PM Subject: RE: [PHP-DB] Problem connecting to db on Linux Have you spelled the name of the database correctly, including case sensitivity? What error message are you getting to indicate failure? -Original Message- From: George Pitcher [mailto:[EMAIL PROTECTED]] Sent: Monday, February 18, 2002 8:21 AM To: Greg Donald; [EMAIL PROTECTED] Subject: Re: [PHP-DB] Problem connecting to db on Linux Greg, et al, This is the contents of the include file: ?php $link = mysql_connect ('localhost', 'root', '*') or die (Could not select db); mysql_select_db ('Heronsql') or die (Could not connect); ? I have also tried it with the following: ?php $link = mysql_connect ('localhost', 'root', '*'); echo mysql_errno().: .mysql_error().BR; mysql_select_db ('Heronsql'); echo mysql_errno().: .mysql_error().BR; ? Te results for this were: 0:0 0:0 I have reinstalled my Mandrake (MySQL/PHP4.0.6/Apache) and I am about to retest so I'll report back soon. George - Original Message - From: Greg Donald [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, February 18, 2002 2:08 PM Subject: Re: [PHP-DB] Problem connecting to db on Linux I've been working with PHP/MySQL on Win NT and Win 2000 for a few weeks. I've now set up a Linux machine (Mandrake 8.1 on Dell laptop) and have moved my files across. I use an include file which logs on to the MySQL server and then connects to the database. It performs the login ok but not the select db part. I tried creating a db using a php script and then selecting it and got the same problem. I'm new on Linux so it might be something in the configuration which needs working on. Any suggestions? Well, if you had posted some code, someone might have seen the error... :( Anyway, here is how i do it: if($db = mysql_pconnect($dbhost, $dbuser, $dbpasswd)){ mysql_select_db($dbname, $db); } else { echo mysql_error(); exit; } Greg Donald - http://destiney.com/ http://phprated.com/ | http://phplinks.org/ | http://phptopsites.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Problem connecting to db on Linux
what is the error message you get? do you print otu mysql_error() ? -Original Message- From: George Pitcher [mailto:[EMAIL PROTECTED]] Sent: Monday, February 18, 2002 9:42 AM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Problem connecting to db on Linux Greg, et al, Now the re-installation is complete, I am getting past the original error -- only to hit another. My query is as follows (echoed to web page): SELECT DISTINCT Nickname, HEI_ID FROM customers WHERE Nickname '' ORDER BY Nickname I have checked case against db an it is correct. Am I missing something else which is obvious? George - Original Message - From: Rick Emery [EMAIL PROTECTED] To: 'George Pitcher' [EMAIL PROTECTED]; Rick Emery [EMAIL PROTECTED]; Greg Donald [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, February 18, 2002 3:19 PM Subject: RE: [PHP-DB] Problem connecting to db on Linux Do you have your error messages crossed? I ask, because I would think your cannot select message would go with your mysql_select_db() and your cannot connect would go with your mysql_connect() -Original Message- From: George Pitcher [mailto:[EMAIL PROTECTED]] Sent: Monday, February 18, 2002 8:48 AM To: Rick Emery; Greg Donald; [EMAIL PROTECTED] Subject: Re: [PHP-DB] Problem connecting to db on Linux Rick, I snipped the code from my windoze system. I did have to change the case of the dbname to reflect the Linux version (all lc). The error message I got (not displayed on screen but visible on 'view source') was 'Could not connect' which, to me means that it got past the login to server and stalled on the select db part? George - Original Message - From: Rick Emery [EMAIL PROTECTED] To: 'George Pitcher' [EMAIL PROTECTED]; Greg Donald [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, February 18, 2002 2:31 PM Subject: RE: [PHP-DB] Problem connecting to db on Linux Have you spelled the name of the database correctly, including case sensitivity? What error message are you getting to indicate failure? -Original Message- From: George Pitcher [mailto:[EMAIL PROTECTED]] Sent: Monday, February 18, 2002 8:21 AM To: Greg Donald; [EMAIL PROTECTED] Subject: Re: [PHP-DB] Problem connecting to db on Linux Greg, et al, This is the contents of the include file: ?php $link = mysql_connect ('localhost', 'root', '*') or die (Could not select db); mysql_select_db ('Heronsql') or die (Could not connect); ? I have also tried it with the following: ?php $link = mysql_connect ('localhost', 'root', '*'); echo mysql_errno().: .mysql_error().BR; mysql_select_db ('Heronsql'); echo mysql_errno().: .mysql_error().BR; ? Te results for this were: 0:0 0:0 I have reinstalled my Mandrake (MySQL/PHP4.0.6/Apache) and I am about to retest so I'll report back soon. George - Original Message - From: Greg Donald [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, February 18, 2002 2:08 PM Subject: Re: [PHP-DB] Problem connecting to db on Linux I've been working with PHP/MySQL on Win NT and Win 2000 for a few weeks. I've now set up a Linux machine (Mandrake 8.1 on Dell laptop) and have moved my files across. I use an include file which logs on to the MySQL server and then connects to the database. It performs the login ok but not the select db part. I tried creating a db using a php script and then selecting it and got the same problem. I'm new on Linux so it might be something in the configuration which needs working on. Any suggestions? Well, if you had posted some code, someone might have seen the error... :( Anyway, here is how i do it: if($db = mysql_pconnect($dbhost, $dbuser, $dbpasswd)){ mysql_select_db($dbname, $db); } else { echo mysql_error(); exit; } Greg Donald - http://destiney.com/ http://phprated.com/ | http://phplinks.org/ | http://phptopsites.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Problem connecting to db on Linux
so, you probably have something like, right? If not, change your code to: $query = SELECT DISTINCT Nickname, HEI_ID FROM customers WHERE Nickname ORDER BY Nickname; $result = mysql_query($query) or die(error: .mysql_error()); show us your code. I ask, because you appear to have an extra in fron of ORDER BY -Original Message- From: George Pitcher [mailto:[EMAIL PROTECTED]] Sent: Monday, February 18, 2002 9:53 AM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Problem connecting to db on Linux Rick, Sorry, here it is: Warning: Supplied argument is not a valid MySQL result resource in /var/www/html/HERONweb/home.php on line 32 I have 'echo mysql_errno();' just after the query is called but no number is being displayed. George - Original Message - From: Rick Emery [EMAIL PROTECTED] To: 'George Pitcher' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, February 18, 2002 3:46 PM Subject: RE: [PHP-DB] Problem connecting to db on Linux what is the error message you get? do you print otu mysql_error() ? -Original Message- From: George Pitcher [mailto:[EMAIL PROTECTED]] Sent: Monday, February 18, 2002 9:42 AM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Problem connecting to db on Linux Greg, et al, Now the re-installation is complete, I am getting past the original error -- only to hit another. My query is as follows (echoed to web page): SELECT DISTINCT Nickname, HEI_ID FROM customers WHERE Nickname '' ORDER BY Nickname I have checked case against db an it is correct. Am I missing something else which is obvious? George - Original Message - From: Rick Emery [EMAIL PROTECTED] To: 'George Pitcher' [EMAIL PROTECTED]; Rick Emery [EMAIL PROTECTED]; Greg Donald [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, February 18, 2002 3:19 PM Subject: RE: [PHP-DB] Problem connecting to db on Linux Do you have your error messages crossed? I ask, because I would think your cannot select message would go with your mysql_select_db() and your cannot connect would go with your mysql_connect() -Original Message- From: George Pitcher [mailto:[EMAIL PROTECTED]] Sent: Monday, February 18, 2002 8:48 AM To: Rick Emery; Greg Donald; [EMAIL PROTECTED] Subject: Re: [PHP-DB] Problem connecting to db on Linux Rick, I snipped the code from my windoze system. I did have to change the case of the dbname to reflect the Linux version (all lc). The error message I got (not displayed on screen but visible on 'view source') was 'Could not connect' which, to me means that it got past the login to server and stalled on the select db part? George - Original Message - From: Rick Emery [EMAIL PROTECTED] To: 'George Pitcher' [EMAIL PROTECTED]; Greg Donald [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, February 18, 2002 2:31 PM Subject: RE: [PHP-DB] Problem connecting to db on Linux Have you spelled the name of the database correctly, including case sensitivity? What error message are you getting to indicate failure? -Original Message- From: George Pitcher [mailto:[EMAIL PROTECTED]] Sent: Monday, February 18, 2002 8:21 AM To: Greg Donald; [EMAIL PROTECTED] Subject: Re: [PHP-DB] Problem connecting to db on Linux Greg, et al, This is the contents of the include file: ?php $link = mysql_connect ('localhost', 'root', '*') or die (Could not select db); mysql_select_db ('Heronsql') or die (Could not connect); ? I have also tried it with the following: ?php $link = mysql_connect ('localhost', 'root', '*'); echo mysql_errno().: .mysql_error().BR; mysql_select_db ('Heronsql'); echo mysql_errno().: .mysql_error().BR; ? Te results for this were: 0:0 0:0 I have reinstalled my Mandrake (MySQL/PHP4.0.6/Apache) and I am about to retest so I'll report back soon. George - Original Message - From: Greg Donald [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, February 18, 2002 2:08 PM Subject: Re: [PHP-DB] Problem connecting to db on Linux I've been working with PHP/MySQL on Win NT and Win 2000 for a few weeks. I've now set up a Linux machine (Mandrake 8.1 on Dell laptop) and have moved my files across. I use an include file which logs on to the MySQL server and then connects to the database. It performs the login ok but not the select db part. I tried creating a db using a php script and then selecting it and got the same problem. I'm new on Linux so it might be something in the configuration which needs working on. Any suggestions? Well, if you had posted some code, someone might have seen the error... :( Anyway, here is how i do it: if($db = mysql_pconnect($dbhost, $dbuser, $dbpasswd)){ mysql_select_db($dbname
RE: [PHP-DB] Time Difference
Are you saying you got two different return values with the exact same input values for $hour, $minute, $second, $month, $day, $year?? -Original Message- From: Lerp [mailto:[EMAIL PROTECTED]] Sent: Friday, February 15, 2002 8:46 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Time Difference Hi again. I have a date field in my mssql 7.0 db format : 2/14/2002 12:21:28 PM . I would like to know how to calculate the difference in seconds between 2 such timestamps. $starttime = mktime($hour, $minute, $second, $month, $day, $year); returns :1013776613 endtime = mktime($hour, $minute, $second, $month, $day, $year); returns: 1007303960 These are the number of seconds since epoch, correct? So obviously there's something I'm missing, but not sure what I've missed :) Your help is muchly appreciated, thx Joe :) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] formating w/ table
Your /table is inside your loop. So it is executed once to terminate the table. After that, the browser just sees the rest as straight text. -Original Message- From: jas [mailto:[EMAIL PROTECTED]] Sent: Friday, February 15, 2002 2:35 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] formating w/ table I am having a little problem formating data retrieved from a database into table cells... So far after connecting and querying the database table the data is put into table cells, however after the first entry is displayed in the table all the other entries loose the formating, HELP? ?php require 'scripts/db.php'; $result = mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not execute query, please try again later); echo table border=\0\ class=\newhead\ width=\100%\trtd align=\center\ colspan=\2\BCurrent Inventory/Bhr color=\33\/td/tr; $count = -1; while ($myrow = mysql_fetch_row($result)) { $count ++; echo trtd width=\30%\BType Of Car: /B/tdtd; printf(mysql_result($result,$count,car_type)); echo /td/tr\n; echo trtd width=\30%\BModel Of Car: /B/tdtd; printf(mysql_result($result,$count,car_model)); echo /td/tr\n; echo trtd width=\30%\BYear Of Car: /B/tdtd; printf(mysql_result($result,$count,car_year)); echo /td/tr\n; echo trtd width=\30%\BPrice Of Car: /B/tdtd$; printf(mysql_result($result,$count,car_price)); echo /td/tr\n; echo trtd width=\30%\BVIN Of Car: /B/tdtd; printf(mysql_result($result,$count,car_vin)); echo /td/trtrtd colspan=\2\hr color=\33\/td/tr/table\n; } ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] formatting w/ table
Further, I recommend replacing your echos with the following: echo trtd width=\30%\BType Of Car: /B/tdtd. $myrow['car_type']./td/tr\n; echo trtd width=\30%\BModel Of Car: /B/tdtd. $myrow['car_model']./td/tr\n; echo trtd width=\30%\BYear Of Car: /B/tdtd. $myrow['car_year']./td/tr\n; echo trtd width=\30%\BPrice Of Car: /B/tdtd$. $myrow['car_price'./td/tr\n; echo trtd width=\30%\BVIN Of Car: /B/tdtd. $myrow['car_vin']./td/tr; echo trtd colspan=\2\hr color=\33\/td/tr; } echo /table\n; ? -Original Message- From: jas [mailto:[EMAIL PROTECTED]] Sent: Friday, February 15, 2002 2:35 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] formating w/ table I am having a little problem formating data retrieved from a database into table cells... So far after connecting and querying the database table the data is put into table cells, however after the first entry is displayed in the table all the other entries loose the formating, HELP? ?php require 'scripts/db.php'; $result = mysql_query(SELECT * FROM cur_inv,$dbh) or die(Could not execute query, please try again later); echo table border=\0\ class=\newhead\ width=\100%\trtd align=\center\ colspan=\2\BCurrent Inventory/Bhr color=\33\/td/tr; $count = -1; while ($myrow = mysql_fetch_row($result)) { $count ++; echo trtd width=\30%\BType Of Car: /B/tdtd; printf(mysql_result($result,$count,car_type)); echo /td/tr\n; echo trtd width=\30%\BModel Of Car: /B/tdtd; printf(mysql_result($result,$count,car_model)); echo /td/tr\n; echo trtd width=\30%\BYear Of Car: /B/tdtd; printf(mysql_result($result,$count,car_year)); echo /td/tr\n; echo trtd width=\30%\BPrice Of Car: /B/tdtd$; printf(mysql_result($result,$count,car_price)); echo /td/tr\n; echo trtd width=\30%\BVIN Of Car: /B/tdtd; printf(mysql_result($result,$count,car_vin)); echo /td/trtrtd colspan=\2\hr color=\33\/td/tr/table\n; } ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Disable Right click w/ php?
You can't do this using PHP, because PHP is server-side. You will need JavaScript. -Original Message- From: jas [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 14, 2002 12:18 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Disable Right click w/ php? I have been looking on php.net for a function to disallow people to right click to view source... anyone have a good idea of how to accomplish this without using java-script? Thanks in advance, Jas -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Time Question
?php $t = date(m/d/Y h:i:s A, gettimeofday()); print $t; ? -Original Message- From: Lerp [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 14, 2002 12:45 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Time Question Hi there. Got a bit of a snag. I'm migrating an ASP app to PHP with a mssql7.0 backend. The snag is this, I have a 'starttime' field in my db using the 'datetime' format ... looks like this 2/14/2002 12:21:28 PM. Unfortuanely, I'm unable to convert this field to type integer at the present time. How would I get the current time in the same format as above (2/14/2002 12:21:28 PM) for insertion to the db in a datetime field datatype? Thx Joe :) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Time Question
CORRECTION: ?php $t = date(m/d/Y h:i:s A, time()); print $t; ? -- C:\php -f a.php 02/14/2002 12:49:50 PM -Original Message- From: Lerp [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 14, 2002 12:45 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Time Question Hi there. Got a bit of a snag. I'm migrating an ASP app to PHP with a mssql7.0 backend. The snag is this, I have a 'starttime' field in my db using the 'datetime' format ... looks like this 2/14/2002 12:21:28 PM. Unfortuanely, I'm unable to convert this field to type integer at the present time. How would I get the current time in the same format as above (2/14/2002 12:21:28 PM) for insertion to the db in a datetime field datatype? Thx Joe :) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Form Validation
addslashes() stripslashes() Your question is vague... -Original Message- From: jas [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 14, 2002 1:32 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Form Validation Anyone know of a good function to strip characters and stuff that would cause mysql to crash from forms? Jas -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] First and Last Record Query
Why are you iterating through the array? Why not just: $start_id = $row[0]; $end_id = $row[count($row)-1]; -Original Message- From: David Fudge [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 13, 2002 11:40 AM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] First and Last Record Query well, if you're using an array, you could use a for like this: $row = mysql_fetch_row($result); for( $i=0;$icount($row);$i++ ) { if( $i==0 ) $start_id = $row[$i]; elseif( $i == (count($row)-1) ) $end_id = $row[$i]; } - Original Message - From: Rankin, Randy [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, February 13, 2002 12:32 PM Subject: [PHP-DB] First and Last Record Query Does anyone know how to grab only the first and last record of a query. I have a table named periods with two fields, period_id and period_name. The user will select a start period and an end period from a drop down list, assigning $start_period and $end_period variables based on the period id. If I run this query: Select period_name from periods where period_id between '$start_period_id' and '$end_period_id' order by period_id An array is returned which could include one or more records, depending upon the user selection. I would like to grab the first and last record in the array so that the final result would be to echo something like This report is from $start_period through $end_period. Hope that makes sense ... Thanks in advance for any help. Randy Rankin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] undeclared variable error
change: if ($submit) { to: if (ISSET($submit)) { -Original Message- From: Dan Howard [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 13, 2002 12:21 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] undeclared variable error Folks, I am very new to PHP, and have been working through some tutorials. I have been able to post data from mySQL, but when I tried to do a form page to enter data into the database I get the following error: PHP Warning: Undefined variable: submit in c:\inetpub\wwwroot\testform.php on line 4 PHP Warning: Undefined variable: PHP_SELF in c:\inetpub\wwwroot\testform.php on line 14 Here is the code: html body ?php if ($submit) { // process form $db = mysql_connect(localhost, root); mysql_select_db(mydb,$db); $sql = INSERT INTO employees (first,last,address,position) VALUES ('$first','$last','$address','$position'); $result = mysql_query($sql); echo Thank you! Information entered.\n; } else{ // display form ? form method=post action=?php echo $PHP_SELF? First name:input type=Text name=firstbr Last name:input type=Text name=lastbr Address:input type=Text name=addressbr Position:input type=Text name=positionbr input type=Submit name=submit value=Enter information /form ?php } // end if ? /body /html Does anyone have any ideas, or where I need to look more to learn what the problem is here? TIA Dan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Passing form values with quotes, to itself
try: input type=text name=Body value=quot;?php echo $Body; ?quot; Also, please include a sample field value and the results of our tests -Original Message- From: Faye Keesic [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 13, 2002 12:03 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Passing form values with quotes, to itself Hi there. I have a form that contains several fields w/ text info (which may or may not contain single and double quotes). When the user clicks Preview, the form's action is set to call itself ($PHP_SELF), and the info is displayed nicely so they can read it over, and verify it before saving to the db. What I'm having problems with is that when the data has quotes, the text data cuts off. If I use: input type=text name=Body value= ?php echo $Body; ? then double quotes are cut off. If I use: input type=text name=Body value=' ?php echo $Body; ?' then single quotes are cut off. I want nothing cut off! I've tried addslashes()..still cuts off. I hope that all made sense... -- Faye -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] A while loop prob ?
Need to show us more code. For instance: where is $srchrow set? Next, change: if ($submit){ to: if (ISSET($submit)) { Why are you over-writing $name, $details, $price, $imgloc with list() before you even use them? -Original Message- From: Dave Carrera [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 13, 2002 1:40 PM To: php List Subject: [PHP-DB] A while loop prob ? Hi All What have I done wrong here. 3 yes 3 hours I have been plaing with this loop. All it shows is the last record in my db. It should show and record containing any string in the search. Error works Please help I beg you... As always thank you for any help Dave C - My Code Starts Here if ($submit){ if($search == ){ $error1 = font color=redNo Records found. Please use at least 1 character in search box/font; } else { $srchsql = select * from $tbn where name like \%$search%\ ; $srchresult = mysql_query($srchsql, $con); $name =$srchrow['name']; $details =$srchrow['details']; $price =$srchrow['price']; $imgloc =$srchrow['imgloc']; while (list($name, $details, $price, $imgloc)=mysql_fetch_array($srchresult)){ $display_srch_rows = trtd$imgloc/tdtd$name/tdtd$details/tdtd$price/td/tr ; } } } Dave Carrera Website Designer http://www.davecarrera.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] undeclared variable error
change: ?php echo $PHP_SELF? to: ?php echo $PHP_SELF;? note the semi-colon -Original Message- From: Dan Howard [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 13, 2002 2:34 PM To: Rick Emery; [EMAIL PROTECTED] Subject: RE: [PHP-DB] undeclared variable error Thanks Rick, That took care of the $submit error, but I still have the following error showing: PHP Warning: Undefined variable: PHP_SELF in c:\inetpub\wwwroot\testform.php on line 14 Here is line 14: form method=post action=?php echo $PHP_SELF? I still don't know what's going on here. Thanks for your patience and help for us newbies! Dan -Original Message- From: Rick Emery [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 13, 2002 12:11 PM To: 'Dan Howard'; [EMAIL PROTECTED] Subject: RE: [PHP-DB] undeclared variable error change: if ($submit) { to: if (ISSET($submit)) { -Original Message- From: Dan Howard [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 13, 2002 12:21 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] undeclared variable error Folks, I am very new to PHP, and have been working through some tutorials. I have been able to post data from mySQL, but when I tried to do a form page to enter data into the database I get the following error: PHP Warning: Undefined variable: submit in c:\inetpub\wwwroot\testform.php on line 4 PHP Warning: Undefined variable: PHP_SELF in c:\inetpub\wwwroot\testform.php on line 14 Here is the code: html body ?php if ($submit) { // process form $db = mysql_connect(localhost, root); mysql_select_db(mydb,$db); $sql = INSERT INTO employees (first,last,address,position) VALUES ('$first','$last','$address','$position'); $result = mysql_query($sql); echo Thank you! Information entered.\n; } else{ // display form ? form method=post action=?php echo $PHP_SELF? First name:input type=Text name=firstbr Last name:input type=Text name=lastbr Address:input type=Text name=addressbr Position:input type=Text name=positionbr input type=Submit name=submit value=Enter information /form ?php } // end if ? /body /html Does anyone have any ideas, or where I need to look more to learn what the problem is here? TIA Dan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] mysql_connect()
What is the exact error you are getting? I'm going to guess something along the lines of unidentified function mysql_connect(). If that's the case, that means you do not have mysql functionality compiled into your web server. Speaking of which: what is your Linux system (RedHat SuSe, etc)? What is your web server? -Original Message- From: Martin Allan Jensen [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 12, 2002 10:09 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] mysql_connect() Hi all. once again i need help... I tried a lot of stuff but my server (linux) (php 4.0.6) won't use the mysql_connect() command..?? Anyone else have an solution for the problem..?? Kind regards Martin Allan Jensen -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Drop Down Menus
FROM THE MANUAL: mysql_fetch_row() fetches one row of data from the result associated with the specified result identifier. The row is returned as an array. Each result column is stored in an array offset, starting at offset 0. Therefore: print(option value=\$row[0]\$row[0]/option\n); -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 12, 2002 10:10 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Drop Down Menus Hi wonder if anyone knows what I am doing wrong here. I have a drop down selection menu that is generated from a mysql database. In the database we have over 15 fields one of them contains text for the catergory that the entry belongs to. I have used the following code to generate my drop down menu but when i view it in the browser the drop down menu has not listed the categories instead we have blank entries for each selection. ? mysql_connect(localhost,user,password); mysql_select_db(database); $sql = select distinct category from books ORDER BY category ASC; $makes_result = mysql_query($sql); print (select name=\category\\n); print(option selected value=\\Please select a Category/option\n); while($row = mysql_fetch_row($makes_result)) { print(option value=\$row[1]\$row[1]/option\n); } print(/select); ? Thanks for the help. Barry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] mysql_connect()
Re-read my previous email. You do not have mysql functionality compiled into PHP and you web server. The clue is the phrase undefined function: mysql_connect(). How did you load PHP, MYSQL, etc? -Original Message- From: Martin Allan Jensen [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 12, 2002 10:26 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] mysql_connect() Sorry folks, last time i wrote it to fast! Well here is the hole story We got an organisation to install a new version of phpmyadmin, mySQL and PHP 4.0.6 on our Cobalt Raq 4r server (Linux) They got it installed and phpmyadmin is working finebut when i call fro a script souch as % ? // Connecting, selecting database $link = mysql_connect(127.0.0.10, phpcoder_dk, pdw) or die(Could not connect); print Connected successfully; mysql_select_db(phpcoder_dk) or die(Could not select database); // Performing SQL query $query = SELECT * FROM hits; $result = mysql_query($query) or die(Query failed); ? % The script writes this. % Fatal error: Call to undefined function: mysql_connect() in /home/sites/site2/web/sql.php on line 3 % You can test it at http://www.phpcoder.dk/sql.php I really hope that someone will help me cause i really can't find the problem by myself...! Kind regards Martin Allan Jensen -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] mysql and dropdown menus
When you include $Select in your URL, did you remember to urlencode() it first? If no, the spaces will blow your URL away...very nasty... BTW, it helps if you post code. -Original Message- From: jeff akerman [mailto:[EMAIL PROTECTED]] Sent: Monday, February 11, 2002 4:27 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] mysql and dropdown menus I'm working on a webpage that will display a list of names and locations held within a mysql db. Once the list is displayed, the names and locations are sortable Ascending and Descending by clicking on the column title. However, I'm trying to incorporate a drop down menu that will allow you to specify the location you want to view so that you don't have to look at the entire list, only those with the selected location. Within my dropdown menu the variable name is 'Select' which I then include in a mysql_query WHERE statement. For example mysql_query(SELECT * from data WHERE state = '$Select' $orderby $sortorder) the $orderby and $sortorder are strings which contain the statements for ordering and sorting. Very similar to Chap. 11 of PHP4 for Beginners (Wrox). I can get this to display correctly when originally done but if I want to the sort the smaller list, I cannot figure out how to get the $Select variable to continue to hold the correct state. What has been happening is when I click to sort either ascending or descending, that variable ends up with nothing in it and my results are way off. I'm using $PHP_SELF?show_namesstate=$Select (show_names is a function for listing the names and locations) but the $Select variable seems to be emptying out when I do this. My dropdown list is not contained within the function. Is this a problem? Hope this made sense. Any suggestions would be greatly appreciated. Thanks, Jeff Go Get It! Send FREE Valentine eCards with Lycos Greetings http://greetings.lycos.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Select rows where ?
select * from tablename where field NOT LIKE %A%; -Original Message- From: Dave Carrera [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 12, 2002 12:39 PM To: php List Subject: [PHP-DB] Select rows where ? Hi All How do I select the rows that DO NOT contain a certain character. I.e. : select * from tablename where field dose not contain A Any pointers as always appreciated. davec Dave Carrera Website Designer http://www.davecarrera.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] numeric string problem
The question is: why use varchar? Why not use INT, then format to includes commas when displaying? -Original Message- From: Mike [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 12, 2002 3:38 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] numeric string problem Hi, I am using VARCHAR for price column : 600,000 700,000 etc when I use : PRICERANGE='$Price' it works fine except when the $Price moves to 7 digit as 1,000,000 in other words the less than does not work when comparing 6 digit and 7 digit figures I am not sure how to compensate for this. Thanks Mike -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Required pages...
Verify that $HTTP_REFERER is the URL the user was supposed to come from. Somethig like (you may have to tweak it because I cannot test where I am now): if( strcmp($HTTP_REFERER,www.mydomain.com/login.html) ) { header(Location: http://www.mydomain.com/login.html;); exit; } -Original Message- From: jas [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 12, 2002 4:23 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Required pages... I am wondering if there is a way to force users to come from a certain page. For an example I am using a login page which once authenticated allows users to change the contents of a web site without knowing alot of code etc. What I would like to do is make sure that the content management system will not be accessed unless the user logs in. I am certain sessions is the way to go on this, however I am still new enough to not understand exactly how they work and how to impliment them on a site. I have read a little bit on a tutorial on php.net. If anyone can give me an example of how this could be accomplished I would appriciate it. Jas -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL / PHP Database Help
Yes, you can re-select from the same database without opeing a new connection. I recommend that you print the contents od $newquery to verify it contains the string you think it should. Perhaps the apostrophes you've enclosed the $row[] variable are not expanding. -Original Message- From: Jonathan Underfoot [mailto:[EMAIL PROTECTED]] Sent: Friday, February 08, 2002 7:43 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] MySQL / PHP Database Help I'm trying to write a script that checks for multiple entries on a table in a database. So far I've been plagued by MySQL errors. I'm fairly confident my scripting is ok (Then again, I've been wrong before.) I think moreover there might be some difficulty with my theory. Then again, I could try and do this with MySQL join statements. Any feedback would be appreciated. $sqlquery = mysql_query(SELECT * FROM local_shows); while ($row = mysql_fetch_array($sqlquery)) { $newquery = mysql_query(SELECT * FROM local_shows WHERE show_date='$row[show_date]' AND venue='$row[venue]'); while ($row2 = mysql_fetch_array($newquery)) { $num_rows = mysql_num_rows($row2); if ($num_rows1) { print etc etc (Do things with my $row2 data) I get loads of: Warning: Supplied argument is not a valid MySQL result resource in /home/ufr2/underfoot-www/admin/dupeshows.html on line 51 Can you not reselect in another while while selecting? Does that make any sense to anyone but me? I shouldent have to open another DB connection? Anyhow... your I would appreciate any help. -Jonathan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Can't get left join to work
Actually, the is the same as and. So it could be written as: mysql select e.id,fname,sum(m.miles) from employees e - left join mileage m on m.id=e.id and month(trip_date)=3 - and substring(year(m.trip_date),3,2) = '02' - group by e.id; I'm just lazy...easier to hit twice than type out and. You were on the right path. You simply needed to move the conditional statements from the WHERE to the JOIN clause. I learned that stuff from reading the comments/answers on the list from DuBoise, Zawodny, and others. -Original Message- From: paul wilczynski [mailto:[EMAIL PROTECTED]] Sent: Friday, February 08, 2002 5:42 AM To: Rick Emery Subject: Re: [PHP-DB] Can't get left join to work Thank you! I'm obviously going to have to read up on that 'on ... ' syntax - it's not something I'm familiar with. Paul Rick Emery wrote: And the answer is: mysql select e.id,fname,sum(m.miles) from employees e - left join mileage m on m.id=e.id month(trip_date)=3 - substring(year(m.trip_date),3,2) = '02' - group by e.id; -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Need to delete charcters from a string (Works)
$mystring = substr($mystring,0,-3); - Original Message - From: Renaldo De Silva [EMAIL PROTECTED] To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, February 07, 2002 8:56 PM Subject: [PHP-DB] Need to delete charcters from a string I need to delete the last 3 character of a string, what command can i use o do this. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Need to delete charcters from a string
You were close: $mystr = substr($mystr, 0, -3); -Original Message- From: Renaldo De Silva [mailto:[EMAIL PROTECTED]] Sent: Friday, February 08, 2002 7:36 AM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Need to delete charcters from a string This dosen't quite do what i need, this atually just displays the last 3 characters of the string removing everything else, I wanted to do the opposite, but thanks anyways. Joe Van Meer wrote: Why couldn't you use something like this: $mystr = substr($mystr, -3); Joe Jeroen Timmers [EMAIL PROTECTED] wrote in message 003001c1b026$97373cb0$7f6440d4@jeroen">news:003001c1b026$97373cb0$7f6440d4@jeroen... you can take the function substr from php in combination with strlen (lenght of a string) example $string = 1234567890; $rest = substr($string, 0, strlen($string)-3); // returns 1234567 Success Jeroen Timmers - Original Message - From: Renaldo De Silva [EMAIL PROTECTED] To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, February 07, 2002 8:56 PM Subject: [PHP-DB] Need to delete charcters from a string I need to delete the last 3 character of a string, what command can i use o do this. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Deleting characters from a string...
If you are certain the format will ALWAYS be as you indicate, then try: eregi(width=([0-9]*) height=([0-9]*), $mystring, $reg); $newstring = $reg[1], x .$reg[2]; NOTE: I don't have PHP here at work (I've got it at home). So you may have to tweak this. -Original Message- From: Luke [mailto:[EMAIL PROTECTED]] Sent: Monday, October 08, 2001 5:09 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Deleting characters from a string... Hi, I have a string that says width=123 Height =456 and I need to for mat the output as 123 x 456 is there a way to do this? Thanks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Exact String replace with eregi_replace()
First, the example you give will replace is with , if is is the ONLY work in the line. You indicate this with the ^$ construct. Are you trying to replace only the first occurrence if is? -Original Message- From: Desikan [mailto:[EMAIL PROTECTED]] Sent: Friday, February 08, 2002 6:42 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Exact String replace with eregi_replace() hi I'm trying to replace the exact match of 'is' with ','.. But all the matches of 'is' in the string gets replaced how can i avoid this??? ?php echo ereg_replace (^is$, ,, This is a dismissal of windows based technology); ? rgds, Desikan -- Desikan [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] MySQL / PHP Database Help
You don't need to use var_dump. Just use the following statements: $newquery = mysql_query(SELECT * FROM local_shows WHERE show_date='$row[show_date]' AND venue='$row[venue]'); print $newquery; -Original Message- From: Jonathan Underfoot [mailto:[EMAIL PROTECTED]] Sent: Friday, February 08, 2002 8:48 AM To: Jeroen Timmers Cc: [PHP-DB] Subject: Re: [PHP-DB] MySQL / PHP Database Help What does bool(false) mean? Thats off the vardump -J - Original Message - From: Jeroen Timmers [EMAIL PROTECTED] To: Jonathan Underfoot [EMAIL PROTECTED] Cc: [PHP-DB] [EMAIL PROTECTED] Sent: Friday, February 08, 2002 8:58 AM Subject: Re: [PHP-DB] MySQL / PHP Database Help Hello, something that you can help is the follow try var_dump($newquery); then you see the complete query and run it in phpmyadmin. Jeroen - Original Message - From: Jonathan Underfoot [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, February 08, 2002 2:43 PM Subject: [PHP-DB] MySQL / PHP Database Help I'm trying to write a script that checks for multiple entries on a table in a database. So far I've been plagued by MySQL errors. I'm fairly confident my scripting is ok (Then again, I've been wrong before.) I think moreover there might be some difficulty with my theory. Then again, I could try and do this with MySQL join statements. Any feedback would be appreciated. $sqlquery = mysql_query(SELECT * FROM local_shows); while ($row = mysql_fetch_array($sqlquery)) { $newquery = mysql_query(SELECT * FROM local_shows WHERE show_date='$row[show_date]' AND venue='$row[venue]'); var_dump($newquery); /* for example to see the query */ while ($row2 = mysql_fetch_array($newquery)) { $num_rows = mysql_num_rows($row2); if ($num_rows1) { print etc etc (Do things with my $row2 data) I get loads of: Warning: Supplied argument is not a valid MySQL result resource in /home/ufr2/underfoot-www/admin/dupeshows.html on line 51 Can you not reselect in another while while selecting? Does that make any sense to anyone but me? I shouldent have to open another DB connection? Anyhow... your I would appreciate any help. -Jonathan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] multiple entries in database
Show us you table data Show your PHP code as well -Original Message- From: Justin Hall [mailto:[EMAIL PROTECTED]] Sent: Friday, February 08, 2002 12:06 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] multiple entries in database I have worked my problem down to the mysql database. I have a table like so: Field Type Attributes Null Default Extra username varchar(16) No commID int(9) No auto_increment commState char(2) No commCity varchar(25) No commZip int(5) No 0 commName varchar(255) No commID is primaryKey. when I do an insert to this table without giving the ID a value inside the insert statement it duplicates the entry or increments another blank entry. the insert statement is not in a loop or recursive function. I have found out that if I take out the auto_increment that it adds it just fine if the ID value is added to the statement..without the ID value it enters the ID as '0'. I have another insert statement with another table that is doing the exact same thing. I'm kinda new and kinda not..so..any help is appreciated.. Justin Hall JD Media www.jdmedia.net [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Dealing with Quotation marks
First, you don't have to write your own function to remove slashes. Simply use: $newline = stripslashes($oldline); Second, write your lien containing slashes to the database. When you pull it from the database, use stripslashes(). -Original Message- From: Gary [mailto:[EMAIL PROTECTED]] Sent: Friday, February 08, 2002 10:35 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Dealing with Quotation marks Does anyone know how to deal with this problem? If a user enters in a text box; O'Connor's 2 x 3 When you print it out on the next web page it reads; O\'Connor\'s 2\ x 3\ I have written a function to take care of this, but when you try to write it to the database you get an error of unmatched quotation marks. Is there a function to handle this? Any help would be appreciated. Thanks, Gary -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Round a float to the next highest value despite the value after the point
ceil($myvalue) -Original Message- From: Renaldo De Silva [mailto:[EMAIL PROTECTED]] Sent: Friday, February 08, 2002 1:32 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Round a float to the next highest value despite the value after the point how can I round a float to the next highest value reguardless of the value after the point, does anyone have any suggestion, any help would be apreciated. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] multiple query string
cookies -Original Message- From: Renaldo De Silva [mailto:[EMAIL PROTECTED]] Sent: Friday, February 08, 2002 2:08 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] multiple query string Help! I'm designing a search page and I need to keep the search variable alive even after i refresh the page, I'm already using a string in the url and I can't register a global variable because that would limit the search page to one user at a time. How can I get the search string back into the pag? Any Ideas. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] multiple query string
sessions -Original Message- From: Renaldo De Silva [mailto:[EMAIL PROTECTED]] Sent: Friday, February 08, 2002 2:10 PM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] multiple query string isn't there any other way? Rick Emery wrote: cookies -Original Message- From: Renaldo De Silva [mailto:[EMAIL PROTECTED]] Sent: Friday, February 08, 2002 2:08 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] multiple query string Help! I'm designing a search page and I need to keep the search variable alive even after i refresh the page, I'm already using a string in the url and I can't register a global variable because that would limit the search page to one user at a time. How can I get the search string back into the pag? Any Ideas. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Query with numbers like 1, 3, 5..........
Yes, but the question is why? -Original Message- From: Raymond Lilleodegard [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 1:22 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Query with numbers like 1, 3, 5.. Hi! Is there a way to get the rows with id's like 1, 3, 5, and so on or 2, 4, 6, ...? Best regards Raymond -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Can't get left join to work
And the answer is: mysql select e.id,fname,sum(m.miles) from employees e - left join mileage m on m.id=e.id month(trip_date)=3 - substring(year(m.trip_date),3,2) = '02' - group by e.id; yeilds: +---++--+ | id| fname | sum(m.miles) | +---++--+ | 021021021 | Sam| 0.00 | | 121212121 | George | 0.00 | | 121212122 | George C. | 0.00 | | 121212123 | George | 0.00 | | 123123124 | Jake | 0.00 | | 123412342 | Paul | 0.00 | | 138501999 | Sherman| 0.00 | | 2 | Sam| 0.00 | | 3 | Fred Robert| 0.00 | | 4 | Paul | 0.00 | | 893458009 | Joan H | 0.00 | | 6902D | Ian| 1372.00 | | ABCABCABC | Ian|80.00 | | B | Bob| 0.00 | | Q | Joan Billy Bob | 7.00 | +---++--+ 15 rows in set (0.00 sec) -Original Message- From: paul wilczynski [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 1:26 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Can't get left join to work Here are the 2 tables and selected columns from each. Note there are only 4 employees who have trips (3 of those employees active, 1 inactive). If I do the following select, I only get 4 rows returned (or 3 if I say 'where active = 'A'). In addition to those, I want 1 row returned for each of the employees with 0 miles if there are no rows in the 'mileage' table for them. To put it another way, I always want the number of rows returned to be equal to the number of employees rows whose active_sw = 'A'. select e.id,lname,sum(m.miles) from employees e left join mileage m on e.id=m.id where month(m.trip_date) = 3 and substring(year(m.trip_date),3,2) = '02' group by e.id; CREATE TABLE IF NOT EXISTS employees ( id varchar(30) NOT NULL, fname varchar(25) NOT NULL, lname varchar(30) NOT NULL, password varchar(12) NOT NULL, accum_miles_for_year real(7,2), active_sw varchar(1) NOT NULL, registration varchar(10), engine_sizesmallint unsigned, fuel_reimburse_ratereal(3,2) default 0, PRIMARY KEY (id)) ID FNAME ACTIVE_SW 2SamA 3Fred RobertA 4Paul A 121212121George A 121212122George C. A 121212123George A ABCABCABCIanA BBobA QJoan Billy Bob A 123123124Jake A 021021021SamA 893458009Joan H A 6902DIanA 123412342Paul A 138501999ShermanI CREATE TABLE IF NOT EXISTS mileage ( recno mediumint not null auto_increment, id varchar(30) NOT NULL, trip_date date NOT NULL, trip_from varchar(30) NOT NULL, trip_to varchar(30), purpose varchar(30), miles real(7,2) unsigned NOT NULL, PRIMARY KEY (recno)) ID TRIP_DATEMILES 138501231 2002-03-01 5200.00 ABCABCABC 2002-03-0180.00 6902D 2002-03-0113.00 6902D 2002-03-0113.00 6902D 2002-03-0180.00 6902D 2002-03-0180.00 6902D 2002-03-0113.00 6902D 2002-03-0113.00 6902D 2002-03-0113.00 6902D 2002-03-0113.00 6902D 2002-03-0113.00 6902D 2002-03-0113.00 6902D 2002-03-0113.00 6902D 2002-03-0114.00 6902D 2002-03-0140.00 6902D 2002-03-0144.00 6902D 2002-03-0144.00 6902D 2002-03-01 800.00 6902D 2002-03-01 5.00 6902D 2002-03-01 148.00 Q 2002-03-01 7.00 --- Rick Emery wrote ... Show us your table structures and the data they contain. It appears your WHERE clause probably acting correctly. But without data, we can determine that. -Original Message- From: paul wilczynski [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 11:49 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Can't get left join to work I've got 2 MySQL tables: Employees, and Mileage. Mileage records trips for employees and there may be 0 or more Mileage rows for each Employee row. The Mileage table has a trip_date column. For testing purposes, the trip_date column in all rows is set to 2002-03-01. There are currently 15 rows in the Employees table. I want the result of the following select to be 15 rows (1 for each employee, whether or not there are any rows in the Mileage table for that employee). If I take the where clause out, I get all 15 rows (including a number of rows where sum(m.miles) = 0 (which is what I want). If I
RE: [PHP-DB] duplicate entries in db
Ya haven't given us much to go on. So... SELECT DISTINCT * FROM mytable WHERE some condition; -Original Message- From: Justin Hall [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 2:24 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] duplicate entries in db I have a script that calls a function to perform a query using the arguments sent to the function via http form processing. I get two entries into the MySQL database for one query. I only want one entry. Can someone point me in the right direction? Thanks in advance. Justin Hall JD Media www.jdmedia.net [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Query with numbers like 1, 3, 5..........
I think you're on the right path. It sounds like what you REALLY want is two equal length columns of products. In that case, instead of 1,3,5,7,... which will become upset when you add and delete products; use mysql_num_rows($result). That is: $query=SELECT * FROM products WHERE some condition; $result = mysql_query($query) or die(mysql_error()); $numrows = mysql_num_rows($result); $length = floor($numrows/2); if( mod($numrows,2)==1) $numrows++; for( $i=0; $i$numrows; $i++ ) { $rowLeft = mysql_fetch_array($result); $rowRight = mysql_fetch_array($result); ... print your data side-by-side ... } NOTE: you'll have to format for the situation where there are more left-side rows than right-side; that is, there ae an odd number of products to be displayed. -Original Message- From: Raymond Lilleodegard [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 3:37 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Query with numbers like 1, 3, 5.. Hi again Rick! : ) It is because I am trying to list all products that I have in a database into a menu page. And I would like to have two products beside eachothers. So... is it possible to get two datarows in one: do { } while (mysql_fetch_array() ); ?? or is this a stupid way to do it? Reagrds Raymond - Original Message - From: Rick Emery [EMAIL PROTECTED] To: 'Raymond Lilleodegard' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, February 07, 2002 8:55 PM Subject: RE: [PHP-DB] Query with numbers like 1, 3, 5.. Yes, but the question is why? -Original Message- From: Raymond Lilleodegard [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 1:22 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Query with numbers like 1, 3, 5.. Hi! Is there a way to get the rows with id's like 1, 3, 5, and so on or 2, 4, 6, ...? Best regards Raymond -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Rick Emery [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Yes, but the question is why? -Original Message- From: Raymond Lilleodegard [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 1:22 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Query with numbers like 1, 3, 5.. Hi! Is there a way to get the rows with id's like 1, 3, 5, and so on or 2, 4, 6, ...? Best regards Raymond -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Query with numbers like 1, 3, 5..........
I like Mike's WHILE-loop better than my solution. thanks, Mike -Original Message- From: Mike Gohlke [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 3:56 PM To: Raymond Lilleodegard; [EMAIL PROTECTED] Subject: Re: [PHP-DB] Query with numbers like 1, 3, 5.. ? whatever... ? table border=1 ? $qry = mysql_query(select * from tablename order by id); while ( $ref1 = mysql_fetch_object($qry) ) { $ref2 = mysql_fetch_object($qry) ?trtd$ref1-id nbsp;/tdtd$ref2-id nbsp;/td/tr? } ? /table btw, the nbsp; is to keep the internal cell borders from not appearing using netscape. (keeps it from being empty). Hope this helps Mike... Raymond Lilleodegard wrote: Hi again Rick! : ) It is because I am trying to list all products that I have in a database into a menu page. And I would like to have two products beside eachothers. So... is it possible to get two datarows in one: do { } while (mysql_fetch_array() ); ?? or is this a stupid way to do it? Reagrds Raymond - Original Message - From: Rick Emery [EMAIL PROTECTED] To: 'Raymond Lilleodegard' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, February 07, 2002 8:55 PM Subject: RE: [PHP-DB] Query with numbers like 1, 3, 5.. Yes, but the question is why? -Original Message- From: Raymond Lilleodegard [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 1:22 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Query with numbers like 1, 3, 5.. Hi! Is there a way to get the rows with id's like 1, 3, 5, and so on or 2, 4, 6, ...? Best regards Raymond -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Rick Emery [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Yes, but the question is why? -Original Message- From: Raymond Lilleodegard [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 1:22 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Query with numbers like 1, 3, 5.. Hi! Is there a way to get the rows with id's like 1, 3, 5, and so on or 2, 4, 6, ...? Best regards Raymond -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Resource link errors
The following means you have not opened a link to your database. Concerntrate your efforts there. Warning: Supplied argument is not a valid MySQL-Link resource in /var/www/html/list.php3 on line 26 -Original Message- From: Ken Thompson [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 3:23 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Resource link errors Hello all, I'm very new to php and have been beating my head on the wall over this for 2 days. I've searched through the php documentation but I guess I either don't know where or what to look for or don't understand what I'm seeing. I think this has to be an array but the original doesn't seem to think so.(see below) I've tried ($myrow = mysql_fetch_array($result)) and still get the same errors. The original that I used as an example works OK showing the results of Name, Position. They didn't include a data cell for $myrow[3] ... = THIS WORKS: ?php $title = Welcome to the Web-Site of; /*I commented this out and finaly removed it cuz I don't want the title echoed in the final page.*/ include(header.inc); $result = mysql_query(SELECT * FROM employees,$db); echo table border=1\n; echo trtdName/tdtdPosition/tr\n; while ($myrow = mysql_fetch_row($result)) { echo(trtd%s %s/tdtd%s/tr\n, $myrow[1], $myrow[2], $myrow[3]); } echo /table\n; include(footer.inc); ? === What I am trying to do is to return the results of the query into a table with these items: +---+-+--+-+-++ | Field | Type| Null | Key | Default | Extra | +---+-+--+-+-++ | id| tinyint(4) | | PRI | NULL| auto_increment | | year | int(4) | YES | | NULL|| | make | varchar(20) | YES | | NULL|| | model | varchar(20) | YES | | NULL|| | engine| varchar(20) | YES | | NULL|| | fuel | varchar(8) | YES | | NULL|| | trans | varchar(10) | YES | | NULL|| | condition | varchar(20) | YES | | NULL|| | price | varchar(10) | YES | | 0 || | location | varchar(20) | YES | | NULL|| +---+-+--+-+-++ These are the errors that show up when I run the page in the browser. The database is local and I'm on Linux-Mandrake 8.1 using Apache web server. I can get the results I want from the command line, that is I can make queries and get the proper info returned. what have I done to cause it not to work? Warning: Supplied argument is not a valid MySQL-Link resource in /var/www/html/list.php3 on line 26 Warning: Supplied argument is not a valid MySQL result resource in /var/www/html/list.php3 on line 32 THIS DOESN'T: I get the table and the item name e.g. Year, Make etc. Once I get the 3 cells returning the proper info, I want to add the rest of the cells needed to display all the info in the web page. I don't think it should be a problem, comments on this? ?php include(header.inc); //(Line 26 below, everything above ?php is plain html.) $result = mysql_query(SELECT * FROM autos,$db); echo table border=1\n; echo trtdYear/tdtdMake/tdtdModel/td/tr\n; //(Line 32 below) while ($myrow = mysql_fetch_row($result)) { //What does the '%s' mean? I read it someplace in the tutorial //but can't find it now. printf(trtd%s %s/tdtd%s/tr\n, $myrow[1], $myrow[2], $myrow[3]); } echo /table\n; include(footer.inc); ? -- Ken Thompson, North West Antique Autos Payette, Idaho Email: [EMAIL PROTECTED] http://www.nwaa.com Sales and brokering of antique autos and parts. Linux- Coming Soon To A Desktop Near You Registered Linux User #183936 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Need to delete charcters from a string
$str = substr($str,0,-3); -Original Message- From: Renaldo De Silva [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 07, 2002 1:57 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: [PHP-DB] Need to delete charcters from a string I need to delete the last 3 character of a string, what command can i use o do this. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Updating Database problem...
Jas, Why are you initiating an UPDATE command when you've not changed the information you wish to update? For instance, if $c_name is blank, you display a message to enter the data; yet, you DO NOT ASK the user to enter the correct information. Then, you do an UPDATE statment to enter that blank info into the record. You also update $formerr, yet do not use it. I've got a feeling you're not sharing all your code. Please do so if we are to help. You also need a WHERE clause in you UPDATE; otherwise, ALL records will be changed -Original Message- From: jas [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 31, 2002 11:14 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Updating Database problem... I am having a problem with a script that simply updates a few fields in a database however, I am having a problem having the script to not update the database fields if the form is invalid... Here is my script, I don't want you to fix it for me unless you show me where I am going wrong or can point me to a good tutorial on this type of function. Thanks in advance, Jas ?php # trim extra spaces from these variables $c_name = trim($c_name); $s_addy = trim($s_addy); $city = trim($city); $state = trim($state); $zip = trim($zip); $phone = trim($phone); if($c_name == ) { $c_nameerr = Please enter your Company Namebr; $formerr = $formerr + 1; } if($s_addy == ) { $s_addyerr = Please enter your Street Addressbr; $formerr = $formerr + 1; } if($city == ) { $cityerr = Please enter your Citybr; $formerr = $formerr + 1; } if($state == ) { $stateerr = Please enter your Statebr; $formerr = $formerr + 1; } if($zip == ) { $ziperr = Please enter your Zip Codebr; $formerr = $formerr + 1; } if($phone == ) { $phoneerr = Please enter your Phone Numberbr; $formerr = $formerr + 1; } # - connects to the mysql database to edit information $db_name = test; $table_name = www_demo; $connection = @mysql_connect(localhost, user, password) or die (Could not connect to database. Please try again later.); $db = @mysql_select_db($db_name,$connection) or die (Could not select database table. Please try again later.); $sql = UPDATE $table_name SET c_name=\$c_name\,s_addy=\$s_addy\,city=\$city\,state=\state\,zip=\z ip\,phone=\$phone\; $result = @mysql_query($sql, $connection) or die (Could not execute query. Please try again later.); # -- ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Is this possible?
Yes, you can do that easily. It is easier to answer your question if you show us your table structure. -Original Message- From: Raymond Lilleodegard [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 06, 2002 11:16 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Is this possible? Hi! I have this tricky case, at lest for me : ) I'm trying to get some data out of two tables and listing the data in a product/price site. But. : I have one table with productinfo and one with prices. And it is several columns with the same id in the pricetable, because every product have several sizes. So... how do I get only one row from the product table and two rows from the price table in one line in a page? Is it possible? Best regards Raymond -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Is this possible?
SELECT * FROM pristabell LEFT JOIN varetabell USING(varenr) WHERE pristabell.varenr=$item This statement will get all prices and quantities fro a given item ($item). Simply interate through the recordset and display the info in whatever format you wish. -Original Message- From: Raymond Lilleødegård [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 06, 2002 11:33 AM To: Rick Emery; [EMAIL PROTECTED] Subject: Re: [PHP-DB] Is this possible? My table look like this: Pricetable: (varetabell) (varenr, type, pris) VALUES (1, '6inch', 29), (1, '6inch meny', 51), (1, 'footlong', 45), (1, 'footlong meny', 66), (1, 'salat', 39), (1, 'salat meny', 51), (2, '6inch', 49), (2, '6inch meny', 69), (2, 'footlong', 75), (2, 'footlong meny', 96), (2, 'salat', 49), (2, 'salat meny', 69), Product table: (pristabell) --- (varenr, varenavn, innhold) VALUES ('1','Veggie Delite','Grønnsaker og ost'), ('2','Subway Club', 'Kalkun, skinke og roasbeef'), ('3','Classic Italian BMT', 'Skinke, salami og pepperoni'), And the query that I have tried looks like this: SELECT varetabell.varenavn, varetabell.varenr, varetabell.innhold, pristabell.pris FROM varetabell, pristabell WHERE pristabell.varenr=varetabell.varenr AND pristabell.type='6inch' AND pristabell.type='footlong' - Original Message - From: Rick Emery [EMAIL PROTECTED] To: 'Raymond Lilleodegard' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, February 06, 2002 6:23 PM Subject: RE: [PHP-DB] Is this possible? Yes, you can do that easily. It is easier to answer your question if you show us your table structure. -Original Message- From: Raymond Lilleodegard [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 06, 2002 11:16 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Is this possible? Hi! I have this tricky case, at lest for me : ) I'm trying to get some data out of two tables and listing the data in a product/price site. But. : I have one table with productinfo and one with prices. And it is several columns with the same id in the pricetable, because every product have several sizes. So... how do I get only one row from the product table and two rows from the price table in one line in a page? Is it possible? Best regards Raymond -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Search results
CHANGE: ? if ($Industry != ) { echo $msg; } else { echo $contact_list; } ? TO: if( mysql_num_rows($result) 0 ) { echo $contact_list; } else { echo $msg; } -Original Message- From: Todd Williamsen [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 06, 2002 12:17 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Search results I have done a search page based on a specific column name, but in some columns there is no results to be returned.. What I would like to do is display an error message stating that there is no results .. something like Sorry your search returned Zero Rows = Here is my code: ? $connection = @mysql_connect($databaseserver, $databaseuser, $databasepass) or die(Can't connect to DB); $db = @mysql_select_db($databasename, $connection) or die(could not select DB); $sql = SELECT id, FirstName, LastName FROM Canidate WHERE Industry = \$Industry\; $result = @mysql_query($sql, $connection) or die(could not execute query); $contact_list = ul; while ($row = mysql_fetch_array($result)) { $id = $row[id]; $FirstName = $row[FirstName]; $LastName = $row[LastName]; $contact_list .=lia href=\show_can.php?id=$id\$LastName, $FirstName/a; } $contact_list .=/ul; $msg = font face=\arial\p align=\center\Sorry, Your Search Results Returned Zero Records/p/font; ? html head titleYour Search Results/title meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 /head body p align=centerfont face=Arial, Helvetica, sans-serifuYour Search Results for b quot; ? echo $Industry; ? quot; /b/u/font/p == this is the code block that is stumping me ? if ($Industry != ) { echo $msg; } else { echo $contact_list; } ? p align=centera href=admin.htmfont face=Arial, Helvetica, sans-serifGo Back to Main Menu/font/a/P /body == -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Re: Simple Search Function
Mike is using MYSQL's REGEX; he's looking for a case-insensitive MYSQL function function similar to PHP's eregi(). -Original Message- From: Lerp [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 06, 2002 1:26 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Re: Simple Search Function Hi there, you might want to take a look at the eregi function for case-insensitive pattern matching. Joe :) Mike De Libero [EMAIL PROTECTED] wrote in message 001f01c1af1c$4d7dce00$6901a8c0@slugo">news:001f01c1af1c$4d7dce00$6901a8c0@slugo... Hi guys, I was wondering what the best way would be for me to do a search. The users have 2 options for tables and either can do keyword or exact matching. Right now I'm using REGEXP to do the work of the searching, only problem is that it is case sensitive. We are currently running MySQL 2.23.32 and have php 4 installed. I'm using the search with 5 different fields/columns in one table and 2 fields/columsn in another. Thanks for you help. TIA, Mike -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] query from two tables
Since you gave no real details of your table structure, I'll conjecture. Assume city table and advert table is defined as: CREATE TABLE city ( city_id int not null, auto_increment, city_name varchar(50) default ) CREATE TABLE adverts ( ad_id int not null auto_increment, ad_text varchar(200) default , city_id int not null ) SELECT c.city_name, a.ad_text FROM adverts a LEFT JOIN city c using(city_id) ORDER BY city; This will list every advert. Where an advert has no city. the city_name will display as NULL. To find cities with no adverts: SELECT c.city_name, a.ad_text FROM city c LEFT JOIN adverts a using(city_id) ORDER BY city; -Original Message- From: Ivan Balazs [mailto:[EMAIL PROTECTED]] Sent: Monday, February 04, 2002 6:26 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] query from two tables Hi! The situation: I have 2 tables in an adverising site. In one table, i have the cities used by advertisers, and in the other there are the ads.This ad table has a field which refers to the id of the city in that table. The problem: what mysql method should i use if i want to order the query by cities? I have tried multiple selection like select ads.*, cities.* from ads, cities , but it returns a nonsense. Any help would be appreciated Balazs -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php