Re: [PHP-DB] Placing a form on a page
Ethan Rosenberg, PhD wrote: On 05/06/2013 12:48 AM, tamouse mailing lists wrote: On Sun, May 5, 2013 at 11:22 PM, Ethan Rosenberg, PhD erosenb...@hygeiabiomedical.com wrote: Dear List - I apologize if I offended some of you. I will see that it does not repeat. I am trying to center a form on the top of a page. Here is the form: What you're asking about has nothing to do with PHP. You want help with HTML and CSS, and front-end design. snip You are absolutely correct. I meant to label the post as HTML - Placing a form on a page. My logic was that a PHP programmer will know HTML. If you are aware of a HTML/CSS mailing list, kit would be appreciated. If anyone on the list would be able to answer my question, it would also be appreciated. Ethan http://www.css-discuss.org/ rhetoricalAnd why are you giving an element fixed positioning and expecting it to align with floating elements?/rhetorical -- Cheers David Robley Freedom is just chaos with better lighting. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Processing Account Login
Ron Piggott wrote: Hi Everyone When I login to PayPal a total of 3 web pages are used: 1 ? A screen for the user to type in their user name password 2 ? A screen saying ? Logging in ?* 3 ? My Welcome / Personalized Account Summary Screen * During the 2nd web page my PHP script is going to be accessing the mySQL database to check the login credentials. - I would like to know how this is done - I would like to know how to re-direct the user to a ?incorrect password? screen if this is the case - I would like to know how to re-direct to a ?security question? screen as a secondary step for those users who want this additional security (such as what I am offered through my online banking sign in process) I don?t know what an effective search query is on Google. I don?t mind (nor will I take offense) on being directed to a tutorial. I want to ensure what I am putting into production is high quality and not hap hazard. Thank you for any help you are able to provide me with. Ron Piggott www.TheVerseOfTheDay.info Try 'php mysql login' as your Google search string -- Cheers David Robley File not found. Should I fake it? (Y/N) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Query will not work - SOLVED
Ethan Rosenberg, PhD wrote: What am I doing wrong?? Not checking the errors that mysql returns? -- Cheers David Robley Tennis in the Bible: Moses served in Pharaoh's court... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: SQL syntax
Karl DeSaulniers wrote: Hello Everyone, Hope your 2013 is treating you well. Quick question and apologies if it is a stupid question. Is this a viable syntax? $sql = SELECT orderid FROM ORDERS_TABLE WHERE orderstatus = 'Cancelled' OR (orderstatus = ('New' OR 'Denied' OR 'Expired' OR 'Failed' OR 'Pending' OR 'Refunded' OR 'Reversed' OR 'Under Review' OR 'Voided') AND orderdate '.mysqli_real_escape_string($yesterday).'); Namely the orderstatus = (a whole bunch of options). In my database `orderstatus` field is an enum() list btw. Or is there a better way to check multiple options against an enum inside your select statement? Reason I am doing this is to avoid having to do... $sql = SELECT orderid FROM ORDERS_TABLE WHERE orderstatus = 'Cancelled' OR (orderstatus = 'New' AND orderdate '.mysqli_real_escape_string($yesterday).') OR (orderstatus = 'Denied' AND orderdate '.mysqli_real_escape_string($yesterday).') OR (orderstatus = 'Expired' AND orderdate '.mysqli_real_escape_string($yesterday).') ... etc; TIA, Karl DeSaulniers Design Drumm http://designdrumm.com The best way to check if your SQL query is valid is to feed it to mysql which will return an error if the syntax is incorrect :-) So TIAS! Although it looks wrong to me. But you might try the IN operator - something like OR (orderstatus IN ('New', 'Denied', 'Expired', 'Failed', 'Pending', 'Refunded', 'Reversed', 'Under Review', 'Voided') AND orderdate '.mysqli_real_escape_string($yesterday).') Personally I would have used a lookup table for the order status. -- Cheers David Robley A cynic smells flowers and looks for the casket. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: PDO Mysql data truncation missing error
Matt Pelmear wrote: Hello, I'm trying to detect data truncation on insert to MySQL using PDO. As far as I can tell, this gets reported at least in some cases (ex: http://drupal.org/node/1528628), but I have been unable to see this myself. The test table I'm using has a column that is VARCHAR(5): mysql describe test; +---+--+--+-+-+---+ | Field | Type | Null | Key | Default | Extra | +---+--+--+-+-+---+ | id| int(10) unsigned | YES | | NULL| | | data | varchar(5) | YES | | NULL| | +---+--+--+-+-+---+ 2 rows in set (0.00 sec) My test script inserts a ten character string into the 5 character column: PHP TEST CODE $pdo = new PDO( 'mysql:host=localhost;dbname=test', 'username', 'password' ); $pdo-setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $retval = $pdo-query( 'INSERT INTO `test` (data) VALUES (1234567890)' ); print_r( $retval ); END TEST CODE This results in a new row in the `test` table, truncated after the 5th character as expected, but the truncation is not reported. (running in php 5.3.2 and 5.3.4) Running the same query directly in the mysql command line shows a warning as expected. Am I missing something simple here? Thanks, Matt Caveat: I don't use PDO but maybe the PDO::ERRMODE_WARNING attribute may do what you want? Cheers -- David Robley I'm not rude, I'm attitudinally challenged. Today is Pungenday, the 14th day of Bureaucracy in the YOLD 3178. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Multiple Access to Database
Ethan Rosenberg wrote: Dear List - I have a database: mysql show tables; +-+ | Tables_in_hospital2 | +-+ | Intake3 | | Visit3 | +-+ mysql describe Intake3; ++-+--+-+-+---+ | Field | Type| Null | Key | Default | Extra | ++-+--+-+-+---+ | Site | varchar(6) | NO | PRI | | | | MedRec | int(6) | NO | PRI | NULL| | | Fname | varchar(15) | YES | | NULL| | | Lname | varchar(30) | YES | | NULL| | | Phone | varchar(30) | YES | | NULL| | | Height | int(4) | YES | | NULL| | | Sex| char(7) | YES | | NULL| | | Hx | text| YES | | NULL| | ++-+--+-+-+---+ mysql describe Visit3; ++--+--+-+-++ | Field | Type | Null | Key | Default | Extra | ++--+--+-+-++ | Indx | int(4) | NO | PRI | NULL| auto_increment | | Site | varchar(6) | YES | | NULL|| | MedRec | int(6) | YES | | NULL|| | Notes | text | YES | | NULL|| | Weight | int(4) | YES | | NULL|| | BMI| decimal(3,1) | YES | | NULL|| | Date | date | YES | | NULL|| ++--+--+-+-++ I want Bob to have access to all tables and fields, with all privileges. I want John to have read access to Visit3: fields [Site, MedRec, Weight, BMI] 1] How do I do it? 2] In the case that I have two users with write access to a table, how do I lock the tables/fields so that the two users can not change the same varible at the same time? Thanks. Ethan Start with http://dev.mysql.com/doc/refman/5.5/en/privilege-system.html Cheers -- David Robley Heads I win, tails you lose. Today is Setting Orange, the 15th day of Chaos in the YOLD 3178. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Problem with mysql and php
Jason Pruim wrote: Given the following 2 queries: SELECT DISTINCT areacode FROM main WHERE state = '{$query_exploded[0]}'; SELECT DISTINCT areacode FROM main; The second displays ALOT faster Like by minutes... the first one is what I really want though Currently working with a dataset of 89 million records, will be expanding that to many many more times that... To the tune of possibly a couple billion records... Any ideas? :) Jason Pruim li...@pruimphotography.com Absolutely the first thing I would do is an EXPLAIN on the slow query, and work from the results of that. I'd hazard a guess that there might be indexing problems. http://dev.mysql.com/doc/refman/5.1/en/using-explain.html Cheers -- David Robley Insert inevitable trivial witticism of your choice. Today is Pungenday, the 41st day of The Aftermath in the YOLD 3177. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: PHP + SQLite - Issues with update
Prashant Prabhudesai wrote: Hello, I am running into some issues trying to update a column in a table in a SQLite database using PHP on Windows and was hoping could get some help on this mailer. Here is the create and insert statement - CREATE TABLE SERVER ( IPAddress varchar(100) not null unique primary key, Token varchar(100) unique ); INSERT INTO SERVER (IPAddress, Token) VALUES ('192.168.1.100', ''); I am trying to update the Token field using the following code - [snip] $db = new SQLiteDatabase('db/reg.s3db'); $intoken = uniqid(); $db-query(update SERVER set Token = '$intoken'); $res = $db-query(select * from SERVER); $row = $res-fecth(); $outtoken = $row['Token']; echo $outtoken; [snip] After the script exits successfully I inspect the value in the Token column and its empty. But the echo statement in the snippet above prints the proper value. Interestingly, if I error out the script with a syntax error or some such after the update but before it exits, the value shows up in the Token column. Any idea what is happening here and I need to do here. Seems like there is some sort of flush that needs to happen which happens only if the script errors out. Any help is appreciated. Thanks, Prashant. Spelling matters :-) $row = $res-fecth(); Wrong $row = $res-fetch(); Right Cheers -- David Robley Caterpillar: Scratching post. Today is Prickle-Prickle, the 2nd day of The Aftermath in the YOLD 3177. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Odd MySQL Problem...
Jason Pruim wrote: Hey everyone, Have a weird issue that I can't seem to figure out... Using PHP to insert phone numbers into the site... I have the Area Code, Exchange, and then dynamically create the last 4 digits... Once it's inserted it's dropping the leading zero's... Here's some samples: Copied from phpMySQL: Edit Inline Edit CopyDelete 212 200 0 681 Edit Inline Edit CopyDelete 212 200 1 682 Edit Inline Edit CopyDelete 212 200 2 683 Edit Inline Edit CopyDelete 212 200 3 684 Edit Inline Edit CopyDelete 212 200 4 echoed output from PHP: SQL: INSERT INTO phonesite (areacode, exchange, subscriber) VALUES(212, 200, 0001) SQL: INSERT INTO phonesite (areacode, exchange, subscriber) VALUES(212, 200, 0002) Actual PHP code: ?PHP //ini_set('display_errors', 1); //error_log(-1); set_time_limit(0); //set_time_limit(120); include includes.php; include databaseabstraction.php; include authentication.php; dbconnect(localhost, XX, XX, XX)or die(Unable to connect: . mysql_error()); function number_pad($number,$n) { return str_pad((int) $number,$n,0,STR_PAD_LEFT); } if (($handle = fopen(newyorktest.csv, r)) !== FALSE) { while (($data = fgetcsv($handle, 1000, ,)) !== FALSE) { print_r($data); foreach( range(0, ) AS $n) { //echo BRDATA: . $data[2] . BR; $padded_number = number_pad($n, 4); $sql = INSERT INTO phonesite (areacode, exchange, subscriber) ; $sql .= VALUES({$data[1]}, {$data[2]}, {$padded_number}) ; //mysql_query($sql) or die(Didn't insert you dumb ass FIX IT NOW CLOWN . mysql_error()); echo SQL: . $sql . BR; } } echo File Bitches!; fclose($handle); } ? Any ideas on what I'm missing? Thanks everyone! Jason Pruim li...@pruimphotography.com SQL: INSERT INTO phonesite (areacode, exchange, subscriber) VALUES(212, 200, 0001) SQL: INSERT INTO phonesite (areacode, exchange, subscriber) VALUES(212, 200, 0002) Note the lack of single quotes on the third value; mysql will treat those as integers - especially if subscriber is an integer type :-) If you absolutely have to store the leading zeros you'll need to store them in a char type and quote them when INSERTing or UPDATEing Cheers -- David Robley The information went data way Today is Boomtime, the 68th day of Bureaucracy in the YOLD 3177. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Working with large datasets
Jason Pruim wrote: Hey everyone, I am working with a database that has close to 8 million records in it and it will be growing. I have a state field in the data, and I am attempting to test some query's on it, all but 2 records right now have the same state. My test info won't get pulled up... I believe it keeps timing out the connection. Is there any advice for working with large datasets? I'm wanting this to be able to load quickly. Thanks in advance! Jason Pruim li...@pruimphotography.com Nobody else has mentioned it yet, so I'll throw EXPLAIN into the mix. http://dev.mysql.com/doc/refman/5.0/en/using-explain.html Amongst other things With the help of EXPLAIN, you can see where you should add indexes to tables so that the statement executes faster by using indexes to find rows. Cheers -- David Robley I've been to San Francisco said Tom heartlessly. Today is Prickle-Prickle, the 65th day of Bureaucracy in the YOLD 3177. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] PHP.ini file
Gavin Chalkley wrote: Is there no way of setting unique .ini? As I am running multi Dev sites from Xampp, of which require different includes and other settings On 2 May 2011 18:31, Barry Stear bst...@gmail.com wrote: You just need to update the php.ini file that you have making any changes necessary. I would suggest making a backup of your existing php.ini file first. Regards, Barry On Sat, Apr 30, 2011 at 4:27 AM, Gavin Chalkley gavin.chalk...@gmail.com wrote: Afternoon all. I have a dev server using XAMPP, and am wondering if somone could point how to add a custom php.ini file? I have the ability to do this on the live server but am unsure how to make this read on the dev server? Use a base php.ini for values common to all sites, then make variations as necessary in your vhost config files. http://php.net/manual/en/configuration.changes.php Cheers -- David Robley The calm confidence of a Christian with four Aces. - M.Twain Today is Pungenday, the 50th day of Discord in the YOLD 3177. Celebrate Discoflux -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: jpgraph and mysql passing array
Chris Stinemetz wrote: Hello, I hope you can help me. The Jpgraph forum seems to be pretty uneventful with participation. I am trying to pass arrays through the image tag to populate my variables for my graph. I keep getting an error that there is no input. Do you have any suggestions? I would greatly appreciate it! I have been trying to figure this out for several hours. Below is my code: I need some help with finding a solution. For some reason my graph is not showing up when it evident that my arrays are being passed. When I use: echo TEST DATA PRINT; print_r($datay,false); --- I keep getting the error: Empty input data array specified for plot. --- My php script is as follows: --- !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns=http://www.w3.org/1999/xhtml; head titleKCRF Dashboard/title ?php ini_set('display_errors', 1); error_reporting(E_ALL); $term=$_POST['term']; $term2=$_POST['term2']; $term3=$_POST['term3']; //include ('err_reporting.php'); require ('PHP_Scripts/config.php'); require_once ('jpgraph/jpgraph.php'); require_once ('jpgraph/jpgraph_line.php'); $sql = (SELECT * FROM evdobanding WHERE Market like '%$term' and Cell_Sect = '$term2' and Date = '$term3' ORDER BY distance asc); $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { $datay[] = $row[MBusage]; $datax[] = $row[Distance]; } echo TEST DATA PRINT; print_r($datay,false); ? snip Thank you, Chris If $datay shows as empty, my first step would be to check that your SQL query doesn't return an empty set. Cheers -- David Robley This ocean is calm, said the sailors specifically. Today is Pungenday, the 10th day of Discord in the YOLD 3177. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Prepared Statements
Ron Piggott wrote: I am just starting to use Prepared Statements and am in a learning curve. I am working on the code below. It is for a directory. This is to select the listing for updating. How do I tell if there are more than 1 search result? Am I correctly retrieving the results, if there is more than 1? I want to make a WHILE loop to display the search results for the listing the user is editing. (You can see where I have started the ul ... /ul ... I want that area in the loop) Ron $dbh = new PDO($dsh, $username, $password); $stmt = $dbh-prepare(SELECT `reference`, `organization`, `city`, `province_state`, `postal_zip_code`, `country` FROM `ministry_profiles` WHERE ( `reference` = :organization_reference ) OR ( `organization` LIKE %:organization_name% ) OR ( `telephone` LIKE %:organization_phone% ) OR ( `toll_free` LIKE %:organization_toll_free_phone% ) ORDER BY `organization` ASC); $stmt-bindParam(':organization_reference', $organization_reference, PDO::PARAM_STR); $stmt-bindParam(':organization_name', $organization_name, PDO::PARAM_STR); $stmt-bindParam(':organization_phone', $organization_phone, PDO::PARAM_STR); $stmt-bindParam(':organization_toll_free_phone', $organization_phone, PDO::PARAM_STR); $stmt-execute(); $result = $stmt-fetch(PDO::FETCH_ASSOC); echo ul\r\n; $search_result_organization_reference = $result['reference']; $search_result_organization = $result['organization']; $search_result_city = $result['city']; $search_result_province_state = $result['province_state']; $search_result_postal_zip_code = $result['postal_zip_code']; $search_result_country = $result['country']; echo listrong . $search_result_organization . /strong (Ref: . $search_result_organization_reference . )br /\r\n; echo $search_result_city . , . $search_result_province_state . . $search_result_country . . $search_result_postal_zip_code . /li\r\n; echo /ul\r\n; The docs are a good source of information. For instance, example 2 on http://php.net/manual/en/pdostatement.fetch.php looks to be one solution. Or http://php.net/manual/en/pdostatement.fetchall.php which gives you an array of all the result set rows. Cheers -- David Robley To shoot a mime, do you use a silencer? Today is Pungenday, the 43rd day of Chaos in the YOLD 3177. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Prepared Statements and mySQL
Ron Piggott wrote: I am trying to implement Prepared Statements on my web site and this is the first time I have ever used this. #1) I received the error ?class mysql not defined?. That is a reference #to the first line of code (below) where the database connection is #established. #2) How do I assign the auto_increment value to a variable use Prepared #Statements? In the syntax I am attempting below ?record? is an #auto_increment column. #3) Do syntaxes such as ?$stmt-bindParam(':account_suspended', #-00-00);? require the date -00-00 to be surrounded by ? ? Thank you to the many of you who have supported me this year when I have had questions. I am physically handicapped, although I don?t want to make a big deal about it. I have appreciated the opportunity to continue developing my PHP / mySQL programming skills in 2010. The Internet is a life line to me. Ron $dbh = new mysql('localhost', '$username', '$password', '$database2'); $stmt = $dbh-prepare(INSERT INTO `$database2`.`member` ( `record` , `first_name` , `last_name` , `address_1` , `address_2` , `address_3` , `address_4` , `address_5` , `email` , `prayer_community_alias` , `birth_month` , `birth_day` , `pass` , `validated` , `last_login` , `last_activity` , `birthday_records` , `greeting_reference` , `registration_ip_address`, `account_created` , `account_suspended` , `account_closed` , `referral_source` , `friends_of_ministry_package` , `security_question_1` , `security_answer_1` , `security_question_2` , `security_answer_2` , `security_question_3` , `security_answer_3` ) VALUES ( NULL , ':f1', ':l1', '', '', '', '', '', ':e1', '', ':birth_month', ':birth_day', ':validate_password', ':validated', ':last_login', ':last_activity', ':birthday_records', ':greeting_reference', ':registration_ip_address', ':account_created', ':account_suspended', ':account_closed', ':referral_source', ':friends_of_ministry_package', ':security_question_1', '', ':security_question_2', '', ':security_question_3', '' ) ON DUPLICATE KEY UPDATE `validated` = ':validated', `pass` = ':validate_password', `account_suspended` = ':account_suspended', `account_closed` = ':account_closed', `last_activity` = ':last_activity', `registration_ip_address` = ':registration_ip_address';); $stmt-bindParam(':f1', $f1); $stmt-bindParam(':l1', $l1); $stmt-bindParam(':e1', $e1); $stmt-bindParam(':birth_month', 0); $stmt-bindParam(':birth_day', 0); $stmt-bindParam(':validate_password', $validate_password); $stmt-bindParam(':validated', 5); $stmt-bindParam(':last_login', $todays_date); $stmt-bindParam(':last_activity', $todays_date); $stmt-bindParam(':birthday_records', 15); $stmt-bindParam(':security_question_1', 0); $stmt-bindParam(':greeting_reference', 0); $stmt-bindParam(':registration_ip_address', $registration_ip_address); $stmt-bindParam(':account_created', $todays_date); $stmt-bindParam(':account_suspended', -00-00); $stmt-bindParam(':account_closed', -00-00); $stmt-bindParam(':referral_source', 2); $stmt-bindParam(':friends_of_ministry_package', 0); $stmt-bindParam(':security_question_1', $security_question_1); $stmt-bindParam(':security_question_2', $security_question_2); $stmt-bindParam(':security_question_3', $security_question_3); // insert one row $stmt-execute(); $stmt-close(); The Verse of the Day ?Encouragement from God?s Word? http://www.TheVerseOfTheDay.info #1) I think you re confusing mysql and mysqli #2) Normal procedure is to eithr assign NULL to the auto-increment field, or not reference it; I imagine the same applies for prepared statements #3) Dates are entered aas strings, so need to be quoted as strings Disclaimer; I have also not used prepared statements, but have looked quickly at the mysqli docs :-) Cheers -- David Robley My software never has bugs. It just develops random features. Today is Boomtime, the 70th day of The Aftermath in the YOLD 3176. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: PHP Search DB Table
Oliver Kennedy wrote: Hello Everyone Apologies if I have not done this in the correct way, this is the first time I have turned to your for help so I am unaware if I have to submit this according to a certain protocol, if that is the case then please let me know and I will go through the proper channels. My problem is this. I have a very simple database consisting of 1 table, I want users here to be able to use a search function to query the database in order to return the information on a client by a specific ID number if it is in the database. My search form is this body div id=container form action='datasearch.php' method='POST' div id =options plabelSearch by Client IDbr /input type=text name=searchx //label/p pinput type=submit value=Search //p /div /div /form /body /html and my process form is this ?php $term = $_REQUEST['searchx']; mysql_connect(localhost, root, *) or die (mysql_error()); mysql_select_db(moneyl) or die(mysql_error()); $result = mysql_query(SELECT * FROM clients WHERE clientid = '$term') or die(mysql_error()); echotable border='1'; echo trthClient ID/th thFeeearner/th thFirst Name/th thMiddle Name/th thLast Name/th thHouse/Flat Number/th thAddress/th thPostcode/th thGender/th thDate of Birth/th thLandline/th; while($row = mysql_fetch_array( $result )) { echo trtd; echo$row['clientid']; echo/tdtd; echo$row['feeearner']; echo/tdtd; echo$row['firstname']; echo/tdtd; echo$row['middlename']; echo/tdtd; echo$row['lastname']; echo/tdtd; echo$row['hfnumber']; echo/tdtd; echo$row['address']; echo/tdtd; echo$row['postcode']; echo/tdtd; echo$row['gender']; echo/tdtd; echo$row['dob']; echo/tdtd; echo$row['landline']; echo/td/tr; } echo/table; ? I know the form is connecting an retrieving okay because if I change the WHERE client id = '' to a specific number of a client ID in the database then it comes back with that information, so essentially it is not pulling through the numbers entered into the search box the value for which I have used REQUEST for and specified it with the value $term. I am a beginner at this and am trying to do something to impress the powers-that-be at work, this is now the last stumbling block. Any help would be appreciated. Regards Oliver Try $query = SELECT * FROM clients WHERE clientid = '$term'; echo $query . 'br /'; $result = mysql_query($query); And see what is actually in the query. Cheers -- David Robley Reality is nothing but a collective hunch. Today is Pungenday, the 56th day of The Aftermath in the YOLD 3176. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Escaping an '
Ron Piggott wrote: For a query similar to: SELECT * FROM `tablle` WHERE `column` LIKE 'Sally's Hair Parlor' how do I escape the ' for 's? It's in the manual - assuming you use mysql, see http://php.net/manual/en/book.mysql.php Cheers -- David Robley I just won 1000 dollars, Tom said grandly. Today is Setting Orange, the 71st day of Bureaucracy in the YOLD 3176. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Stuck in apostrophe hell
paul_s_john...@mnb.uscourts.gov wrote: Yes, I may have mixed up the input and output from different iterations of running it. Let me try posting this again although it may not be an issue. Once again if I enter two sequential apostrophes in the name (O''Brien) the INSERT passes right through to MySQL without an error. THE INPUT: $sql_insert_registration = sprintf(INSERT INTO Registrations ( Class_ID, prid, Registrant, Company, Phone, Email ) VALUES ( $_POST[Class_ID], $_POST[prid], '%s',. parseNull($_POST['Company'])., '$_POST[Phone]', '$_POST[Email]' ), mysql_real_escape_string($_POST['Registrant'])); echo pre$_POST['Registrant.$_POST[Registrant]./pre; echo pre.mysql_real_escape_string($_POST[Registrant])./pre; echo pre.$sql_insert_registration./pre; THE OUTPUT: Brian O'Brien Brian O\'Brien INSERT INTO Registrations ( Class_ID, prid, Registrant, Company, Phone, Email ) VALUES ( 355, 257, 'Brian O\'Brien',NULL, '612-456-5678', 'someb...@somewhere.org' ) Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Brien', 'Class registration confirmation', ' This email ' at line 16 Paul S. Johnson U.S. Bankruptcy Court District of Minnesota paul_s_john...@mnb.uscourts.gov 612-664-5276 Check the settings for magic-quotes, and make sure you aren't using stripslashes somewhere? Also, echo the actual query that is being passed to mysql to check what is happening. Cheers -- David Robley Life is Roff when yer Stewpid Today is Sweetmorn, the 70th day of Confusion in the YOLD 3176. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: MySQL Wildcard
Karl DeSaulniers wrote: Hello All, What I want to do is get all the fields from a table without specifying which ID to grab from. I am trying to implement a wildcard in my query. What am I doing wrong? I keep getting... Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource CODE: function getOptGrps($ID){ if ($ID == All) { $ID = %; // % = MySQL multi character wildcard } $q = SELECT * FROM .OPT_GRPS_TABLE. WHERE OptGrpID LIKE '$ID' ; $result = $this-query($q); /* Error occurred, return given name by default */ if(!$result || (mysql_numrows($result) 1)){ return NULL; } /* Return result array */ $array_results = mysql_fetch_array($result); return $array_results; } AND this does not work either function getOptGrps(){ $q = SELECT * FROM .OPT_GRPS_TABLE; $result = $this-query($q); /* Error occurred, return given name by default */ if(!$result || (mysql_numrows($result) 1)){ return NULL; } /* Return result array */ $array_results = mysql_fetch_array($result); return $array_results; } TIA, Well, I'd hazard a guess that OPT_GRPS_TABLE may not be what you think it is; in any case, the first step in debugging would be to echo your query $q and see what it really contains. And does the class that handles your db query have an error reporting function? If so, try using it. Note that to retrieve all records, you could skip the WHERE, or use WHERE 1 Cheers -- David Robley Machine-independent: does not run on any existing machine. Today is Pungenday, the 55th day of Discord in the YOLD 3176. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Rounding up results
Ron Piggott wrote: Is there a way to round up in mySQL? This result may give 3.2 --- so I want the result to be 4? SELECT ( count(`reference`) / $items_per_page ) AS total_pages FROM `store_product_profile` WHERE `store_category_reference` =$reference AND `live` =1 Does your location not let you access the mysql documentation? http://dev.mysql.com/doc/refman/5.1/en/mathematical-functions.html Cheers -- David Robley CTRL-ALT-DEL is the key to success Today is Pungenday, the 68th day of Chaos in the YOLD 3176. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: mysql_query
Ron Piggott wrote: I have the syntax mysql_query(INSERT INTO );); If this is successful I want to do update a column in one of my tables $query = UPDATE ... ; mysql_query($query); How do I test if the INSERT INTO mysql_query, in order to trigger the UPDATE? Ron You could check the mysql section of the documentation, where you will find http://php.net/manual/en/function.mysql-affected-rows.php which will tell you how many rows were affected by your INSERT. Alternatively, if you are using Innodb tables, you could look at using transactions. Cheers -- David Robley Those who can't write, write help files. Today is Boomtime, the 3rd day of Bureaucracy in the YOLD 3175. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: PHP and table/view names with '$'
Mark Casson wrote: Hi, I am trying to access some of the v$ views using php on iis, with admin privileges. However, using: $stmt = OCIParse($conn, SELECT * FROM v$sql); gives me this error: PHP Notice: undefined variable: sql . . . Is there a way around this? Thanks Mark Try enclosing your query in single quotes so php doesn't try to expand what it sees as the variable $sql. For example $stmt = OCIParse($conn, 'SELECT * FROM v$sql'); Cheers -- David Robley I am Homer of Borg. Prepare to be assim... , donuts. Today is Pungenday, the 40th day of Discord in the YOLD 3175. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: session variable in select query showing picture from database
Mika Jaaksi wrote: I'm trying to show picture from database. Everything works until I add variable into where part of the query. It works with plain number. example ...WHERE id=11... ...picture is shown on the page. Here's the code that retrieves the picture. show_pic.php ?php function db_connect($host='', $user='', $password='', $db='') { mysql_connect($host, $user, $password) or die('I cannot connect to db: ' . mysql_error()); mysql_select_db($db); } db_connect(); $band_id = $_SESSION['session_var']; $query=SELECT * FROM pic_upload WHERE band_id=$band_id; $result=mysql_query($query); while($row = mysql_fetch_array($result)) { $bytes = $row['pic_content']; } header(Content-type: image/jpeg); print $bytes; exit (); mysql_close(); ? other page that shows the picture ?php echo img width='400px' src='./show_pic.php' /; ? Any help would be appreciated... Where does $band_id come from? If from a form, and you have register_globals set to (sensibly) OFF then you will need to use the $_POST or $_GET array, depending on the METHOD of the form (POST or GET) to retrieve the value of $band_id Echoing $query will give you some useful information. Cheers -- David Robley I hate Chablis, Tom whined. Today is Pungenday, the 43rd day of Chaos in the YOLD 3175. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Queries / variables
Ron Piggott wrote: What is the correct syntax for this? $description = mysql_result($image_result,0,photo_gallery_index.description_{$language}); I am offering a web page in multiple languages. $language is what language the user is requesting. There is a matching column in the table for each language. For example I may be trying to get the value of description_french I am trying to use the variable instead of having several mysql_result lines Ron mysql_result($image_result,0,photo_gallery_index.description_$language); Should work, I think. However, it seems you are returning all the language fields for each query but only using one. Why not just retrieve the specified language instead, based on the content of $language? Cheers -- David Robley Circular Definition: see Definition, Circular. Today is Sweetmorn, the 49th day of The Aftermath in the YOLD 3174. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Apache HTTP Server has encountered a problem and needs to close
S, Murgesan (GE, Corporate, consultant wrote: Hi, I have posted an error in http://bugs.php.net/?id=46519 Please help me to resolve it. Probably the best thing you can do at this stage is submit a backtrace as you were asked on the bugs site. Cheers -- David Robley Recovery program for excessive talkers: On-and-on-Anon. Today is Sweetmorn, the 24th day of The Aftermath in the YOLD 3174. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Form processing
ron.php wrote: I am trying to set up a form which will send e-mails for late breaking news and urgent e-mailings. If I have Today's news in the subject line on the e-mail it comes out with Today\'s news --- how can I prevent this from happening? Ron Check your magic_quotes_gpc setting, probably on and would be better off. Of course this may create havoc with database queries if you aren't already ignoring it and using the appropriate escaping for whatever db you use. Cheers -- David Robley Entropy isn't what it used to be. Today is Setting Orange, the 36th day of Bureaucracy in the YOLD 3173. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Connecting to mysql from another host
joefazee wrote: I want to connect to a database hosted on another server like from www.sample.com i want to connect to www.example2.com.what did i need to do? Thanks. First up you need to ensure that www.example2.com a) allows remote connections and b) has privileges for [EMAIL PROTECTED] Cheers -- David Robley Why doesn't the Bat Computer ever crash? Today is Setting Orange, the 69th day of Confusion in the YOLD 3173. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: mysql_real_escape_string
Ron Piggott wrote: The following PHP command $new_maintainers_notes = mysql_real_escape_string($new_maintainers_notes); returned this error while running in a ***cron***. Warning: mysql_real_escape_string(): Access denied for user: '[EMAIL PROTECTED]' (Using password: NO) in /home2/actsmin/actsministries-www/memberservices/administration/ministry_directory_annual_review_maintenance.php on line 39 Warning: mysql_real_escape_string(): A link to the server could not be established in /home2/actsmin/actsministries-www/memberservices/administration/ministry_directory_annual_review_maintenance.php on line 39 where $new_maintainers_notes = Listing has been set for it's annual review; But when I return it from the web --- ie http://www... no error. Any idea why the cron is upset? Ron mysql_real_escape_string needs to have an open connection to the db to work. From the docs - http://www.php.net/mysql_escape_string : link_identifier The MySQL connection. If the link identifier is not specified, the last link opened by mysql_connect() is assumed. If no such link is found, it will try to create one as if mysql_connect() was called with no arguments. If by chance no connection is found or established, an E_WARNING level warning is generated. and Note: A MySQL connection is required before using mysql_real_escape_string() otherwise an error of level E_WARNING is generated, and FALSE is returned. If link_identifier isn't defined, the last MySQL connection is used. Cheers -- David Robley Some days, nothing goes left. Today is Pungenday, the 45th day of Discord in the YOLD 3173. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: auto_increment
Ron Piggott wrote: Does anyone see anything wrong with the $query syntax? Ron mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( Unable to select database); $query=ALTER TABLE sessions auto_increment = '1'; mysql_query($query); mysql_close(); The value would be an integer, not a string but that shouldn't cause a problem. To quote the docs: ALTER TABLE t2 AUTO_INCREMENT = value; You cannot reset the counter to a value less than or equal to any that have already been used. For MyISAM, if the value is less than or equal to the maximum value currently in the AUTO_INCREMENT column, the value is reset to the current maximum plus one. It probably should be said that there is normally no reason to play with auto-increment values. Cheers -- David Robley An ulcer is what you get mountain climbing over molehills. Today is Prickle-Prickle, the 31st day of Discord in the YOLD 3173. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Using apostrophe's within a text field
Stephen Smith wrote: OK guys, here is my delima, which is probably very easy to solve, but I can't seem to find it. I am trying to get form fields to accept apostrophes within the input and stop crashing on me. I'm writing forms into a mysql database and everything works great unless the user enters a word like won't or can't. Them it crashes during the form submit. What can I do to fix this stupid thing anyway? thanks in advance. Steve Smith http://php.net/mysql_real_escape_string The manual is your friend. Cheers -- David Robley I'm Serfectly Pober. Today is Boomtime, the 14th day of Discord in the YOLD 3173. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: imagettfbbox
Mad Unix wrote: am trying to build a water mark on the web, when i call the function imagettfbbox() I get the following *Fatal error*: Call to undefined function imagettfbbox() in */usr/local/apache/htdocs/captcha.php* on line *60* OS: RHEL4 Pack: Apache2, PHP5.2, GD Config: './configure' '--with-apxs2=/usr/local/apache/bin/apxs' '--enable-shared' '--with-mysql=/usr/local/mysql' '--with-zlib-dir=/usr/lib/' '--enable-versioning' '--enable-track-vars=yes' '--enable-url-includes--enable-sysvshm=yes' '--enable-sysvsem=yes' '--with-gettext' '--enable-mbstring' '--enable-ftp' '--enable-calendar' '--with-config-file-path=/etc' '--with-oci8=/u01/app/oracle/oracle/product/10.2.0/db_1' '--enable-soap' '--with-gd' '--enable-xml' '--with-xml' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--with-regex=system' '--with-png' '--with-ttf=/usr/lib' '--enable-sigchild' '--with-jpeg-dir=/usr/local/lib/jpeg-6b' '--with-freetype-dir=/usr/local/lib/freetype' '--with-png-dir=/usr/lib/' gd GD Support enabled GD Version bundled (2.0.28 compatible) GIF Read Support enabled GIF Create Support enabled PNG Support enabled WBMP Support enabled XBM Support enabled any help -- madunix In phpinfo, under GD you should also have a line FreeType Supportenabled I'd guess that your configure for freetype is wrong, but I'm not sure where you might find it - perhaps /usr/local ?? Cheers -- David Robley Don't use no double negatives. Today is Prickle-Prickle, the 64th day of Chaos in the YOLD 3173. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Access denied for user...sometimes???
Peter Beckman wrote: On Wed, 21 Feb 2007, James Garfield wrote: I've got 5.0.27-standard installed on an Intel Mac, using the preinstalled version of Apache and my own installation of PHP 4.4.4. I use this machine for development work and don't make it available to anyone else. I've got an instance of a PHP application running, and it works...but not all of the time!!! I created the user that accesses my MySQL via the following commands; use [web_db_name]; grant select, insert, update, delete on *.* to '[new_user]'@'%' identified by '[new_password]'; I'm able to do everything expected from the command line mysql tool, but on the PHP side it fails more than half of the time: Warning: mysql_connect() [function.mysql-connect]: Access denied for user '[new_user]'@'[my_current_dhcp_ip]' (using password: YES) in /[path]/[to]/[page]/[on]/[server]/index.php on line 66 This leaves the question: since MySQL is behaving normally otherwise, I'm using a host of '%' and my IP isn't changing, does anybody know what the problem is with PHP??? TIA, James flush privileges And, as it's only you using mysql from the current machine, you don't need a network connection to your own machine - use localhost instead of your dynamic(?) IP, and set skip-networking (or whatever it is called) to on in your my.cnf file. Cheers -- David Robley Useless Invention: Checkered paint. Today is Pungenday, the 53rd day of Chaos in the YOLD 3173. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Filter array results... no copies
Matthew Ferry wrote: Hello everyone I'm back working on the website again... I'm having lots of fun. I have a sql query that looks at one field in a database. (result2 query) Then i have mysql_fetch_array statement. I then use this array to print links on the page. Works fine except I don't want duplicate links. It creates links for the states. If we have four customers from Pennsylvania. This current process gives me four different PA links on my page. I need a statement that says...if its already printed...don't print it... Thanks... Here is my code: html body ?php $db = mysql_connect(HOST, USERNAME, PASSWORD); mysql_select_db(DATABASE,$db); if ($_GET[area]==) { $master = mysql_query(SELECT * FROM egw_addressbook WHERE cat_id='8' ORDER BY org_name, $db); } else { $master = mysql_query(SELECT * FROM egw_addressbook WHERE cat_id='8' and adr_one_region='$_GET[area]' ORDER BY org_name, $db); } $result2 = mysql_query(SELECT adr_one_region FROM egw_addressbook WHERE cat_id='8' ORDER BY adr_one_region, $db); if ($area = mysql_fetch_array($result2)) { echo Sort by State: ; do { echo a href='index.php?area=$area[adr_one_region]'$area[adr_one_region]/a\n; echo - ; } while ($area = mysql_fetch_array($result2)); echo a href='index.php?area='ALL/a\n; } else { echo ERROR; } if ($myrow = mysql_fetch_array($master)) { echo CENTER\n; echo table border=0\n; echo img src=file.jpg width='611' height='136'\n; echo BR\n; echo BR\n; do { printf(tr td/tdtdb%s/b/tdtd/tdtd/tdtd%s/td/tr\n, $myrow[org_name], $myrow[fn]); printf(tr td/tdtd%s/tdtd/tdtd/tdtd%s/td/tr\n, $myrow[adr_one_street], $myrow[tel_work]); printf(tr td/tdtd%s, %s %s/tdtd/tdtd/tdtd/tdtd/td/tr\n, $myrow[adr_one_locality], $myrow[adr_one_region], $myrow[adr_one_postalcode]); } while ($myrow = mysql_fetch_array($master)); echo /table\n; echo /CENTER\n; } else { echo Sorry, no records were found!; } ? /body /html Hm, perhaps if you order by state first, then do something like (pseudocode only): set currentstate = ''; # Initialise variable to empty while (looping through result set) if currentstate != state_from_dataset echo $state endif display other stuff do any other stuff in loop set currentstate = state_from_dataset endwhile Cheers -- David Robley Auntie Em: Hate you, hate Kansas, taking the dog. -Dorothy Today is Boomtime, the 12nd day of Chaos in the YOLD 3173. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Retrieve text from Oracle Text
Choy, Wai Yew wrote: Hi, My company have a Oracle9i database ...One of the field (text) in this database is a text file (VARCHAR2) with a length of 100 characters.The text inside this field is carriage return return. When we retrieve this field (select text from db.text_field), it only shows the first line. The second and the rest of the line does not show up. Can I know how to I retrieve all the lines in this field? Thanks.. You probably are retrieving all the lines in the field; if you are then outputting the contents direct to the browser, the browser will ignore the newlines - View Source should confirm that this is the case. You should use nl2br() on the retrieved data before passing it to the browser. Cheers -- David Robley Buy me something to drink? said Tom drily. Today is Setting Orange, the 71st day of Bureaucracy in the YOLD 3172. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: pulling numbers from a column and getting a total
Dave W wrote: Hi, I was just wondering on how I could get a whole column full of integers and added them up and display that total? I currently use a for loop to display the whole column in a table, but I wanted to add all those numbers up. Thanks. You could use the SUM function in your DB to do the work for you. Cheers -- David Robley Power corrupts; absolute power is even more fun. Today is Pungenday, the 62nd day of Confusion in the YOLD 3172. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Linux Commands
Manoj Singh wrote: Hello All, Is it possible to run the Linux Commands through php functions or code? If anyone knows, please help me out. Regards Manoj php.net/manual/en/ref.exec.php Cheers -- David Robley User Error: replace user and press any key to continue. Today is Prickle-Prickle, the 8th day of Confusion in the YOLD 3172. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Automatically +1 every 30 mins to a value in the database.
Alex Major wrote: Hi there. I've posted this up on both this list, and the mysql list as I'm not sure whether this is something that I'd need to do with the php or mysql. Basically, I am making an add-on to my small website which is a mini online game. Every user will have gold, and every 30mins I'd like their amount of gold to go up by 1 (or say a variable say $goldupdateamount). I'd like to know which would be the best way of doing this, and if there is a command in php which would achieve this. Regards, Alex. Assuming you are on a *nix system, you could run a CLI script every $period from cron; for Windows I think there is a task scheduler (or similar name) that allows the same thing. Cheers -- David Robley I tried to daydream, but my mind kept wandering. Today is Pungenday, the 7th day of Confusion in the YOLD 3172. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Warning, Subscribers please read!
JeRRy wrote: Hi Subscribers, This message is not for PHP/MySql help in anyway but is posted due to the high level of spam on this lately and some new people to the internet may not be aware of the possible risks people can get into if they follow any of the spam emails on here. If the topic is not related to a list but was sent via the list do not respond to it, either in-directly via this list or the list your on or direct to the reply-to email. But if your the curious person and want to visit a website listed please do not just simply click the link that is displayed in the email. Copy/Paste it into your web browser and surf it. NEVER click a website link directly from a email, even if you trust the sender, it's so easy to send fake emails that may appear to be from REAL PEOPLE but their not! Get into the habbit of copy/pasting it. It's a good habbit. Never send money to people you DON'T KNOW! Never trust an email from someone that you don't know asking to send and or deposit money into a bank account or paypal account. Normally it's a scam and the money is just going to the scammer. PayPal emails, please update your account info etc. Never trust emails with an paypal address. Never click it, copy/paste it or simply visit http://www.paypal.com/ and login to your account, if their is a problem with it they will list it as you login. Never run with scissors! There was a message from Rasmus recently which indicated that there had been a problem with the spam filter - problem had been resolved. Cheers -- David Robley If I can't fix it, it's probably dead. Today is Sweetmorn, the 58th day of Discord in the YOLD 3172. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] if() and else() help needed
JeRRy wrote: Well the way I have it over 2 PHP calls works, as 'nickname' is a UNIQUE key entry in the db. So multiple entries are not an issue. So if it can't insert, as it will try and fail it will update. But if the insert works I am guessing it's going to do an update straight after it for the same result, So it double entries I persume. But what worry would this be? None I am guessing, it's just doing a double entry as long as the data is not lost. And only occours on entering tips for the first time. J Chris [EMAIL PROTECTED] wrote: JeRRy wrote: Hi, Yes the user is logged in. The system knows who is tipping by their nickname and unique id system. So if I put the update query in the else statement would this be the easy fix? Don't know - I was offering a suggestion only. Without the full code we can't really help much (I doubt anyone will want the full code to help you clean it up, sorry). You don't specify which database you are using, so I'll just make the generic suggestion that you look into INSERT ... ON DUPLICATE KEY UPDATE, INSERT IGNORE and REPLACE as possible tools to solve your problem, if your DB supports these statements. Cheers -- David Robley NUMBER CRUNCHING: Jumping on a Computer. Today is Pungenday, the 15th day of Discord in the YOLD 3172 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] help with file downloads from MySQL
Mickey Martin wrote: I guessed that 0a is the code for a new line, but cannot find where it is in my code. This is the entire code that I'm using for the download: ?php if ($id_files) { mysql_select_db($database_ctnwww, $ctnwww); $query_Attachment = sprintf(SELECT bin_data, filetype, filename, filesize FROM IssueAttach WHERE id_files=%s, $_GET['id_files']); $Attachment = mysql_query($query_Attachment, $ctnwww) or die(mysql_error()); $row_Attachment = mysql_fetch_array($Attachment); $data = $row_Attachment['bin_data']; $name = $row_Attachment['filename']; $size = $row_Attachment['filesize']; $type = $row_Attachment['filetype']; header(Content-type: $type); header(Content-length: $size); header(Content-Disposition: attachment; filename=\$name\); header(Content-Description: PHP Generated Data); echo $data; } ? I have also tried putting a string in front of the file on the echo line: echo TEST TEXT, $data; When the file is saved, it begins with 0a followed by TEST TEXT and then the start of the file without another instance of 0a. Mickey -Original Message- From: Oskar [mailto:[EMAIL PROTECTED] Sent: Friday, March 24, 2006 1:59 AM To: Mickey Martin; PHP db Subject: Re: [PHP-DB] help with file downloads from MySQL Mickey Martin wrote: From what I can tell, the 0a is not in the file, but is being inserted either with the echo or by the browser when it receives the file. Does anyone know if a proxy server would cause this? There shouldn't be one involved, but I am going to contact my IT department to find out how it is configured today. Thanks, Mickey 0a is new line character code. Check your script you must be somewhere displaying it. For a wild guess - is ?php the first line in your script? If there is an empty line above it, that could cause the extra EOL character. Cheers -- David Robley My other car is a broom! Today is Prickle-Prickle, the 11st day of Discord in the YOLD 3172 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Cut down threads please!
JeRRy wrote: Hi, This is a Discussion Board, previous threads/posts are logged, recorded, saved to the WWW. I see no point to continue threads over and over and over again. Why not cut the threads down to a few lines that are important to the reply your making? If people need to know more about it there is a free website they can visit and look at it. It's quite annoying to follow a thread and find each time the thread is continued over and over in 5 lots of emails from the same person. Makes going through the list alot slower. I am not going to mention the one recently but most would be aware, the thread was continued, and still is, over about 10 replies, in all none has been removed from any reply. We're talking about 300 lines.. That's just stupid, CUT THEM DOWN PLEASE! Save everyone the hassle, I know of a few others a bit concerned on this also. Just thought I'd express my opinions. There is enough SPAM on the web already without things being repeated over and over again, yes maybe I am here but I am making a valid point. With that said, let's continue. No corrospondence entered into. J Well, whilst we are having a bitch about things, perhaps everyone could turn on word wrap in their favourite mailer/newsreader. Starting with you, please? Cheers -- David Robley People say I'm apathetic, but I don't care. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] slow loading page
Micah Stevens wrote: Not enough information there to make any sort of diagnosis, but here are some things to try to narrow down the problem: 1) ssh into the server, and run 'top' to watch the process list. Then while watching that, hit reload in the browser to see if the HTTP process pegs out while you're waiting for the page. If it does, for some reason apache/php is struggling. Otherwise it's likely something else. 2) run 'ngrep' on port 80 of the incoming network interface (eth0, or whatever it's hooked to), and reload the page again. Are you immediatly seeing the request come though or does it take a while? This type of thing could be caused not by the webserver, but instead by a badly configured router, or something in the network. If it takes a while to come through, you need to look at your network configuration. 3) Is this a DNS issue? If you're accessing via a domain name, and not a direct IP type URL, a shoddy DNS connection could make things really take a long time. 3a) If so, is hostname lookup turned on for apache logging? This may result in yet another query to the DNS. I'm not sure however whether that lookup might delay delivery of the document, or whether the document is served independently og logging actions; I would guess the latter. Cheers -- David Robley I'm never anywhere on time, Tom related. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: first record not displayed
Paul Bern wrote: Hi, I have the feeling I'm missing something very obvious here, but it's driving me nuts! Using this select statement: $result = mysql_query(SELECT * FROM latlong ,$link); $nrows = mysql_num_rows($result); and either of these to display the results: for ($j=0; $rec=mysql_fetch_array($result); $j++){ print j=$j id={$rec[id]} seq={$rec[seq]}\n; } while($row = mysql_fetch_array($result)){ echo id={$row[id]} seq={$row[seq]} \n; } The very first record gets dropped/not displayed. The number of records returned ($nrows) matches what I get from MySQL and the first record gets displayed (using PHPMyAdmin). Even if I change the select to pull only certain records, the very first one does not get displayed. Can anyone shed any light on this for me? Thanks! Paul That sounds like you may somewhere have a mysql_fetch_array() from which you are not using the result; thsat ill fetch the first record, and if you then start using the data from a while($row = mysql_fetch_array it will start with the second record. Something looks odd about your for loop, but my brain is a bit tired at the moment and I can't pinpoint it :-) Cheers -- David Robley This library isn't safe - I just stumbled on an idea. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] auto_increment and INSERT INTO
On Sun, 22 Jan 2006 15:08, Ron Piggott (PHP) wrote: I have various tables where a column is set to auto_increment in my table structure. I have been using the following INSERT query format: INSERT INTO table VALUES ('$auto_increment_variable','$variable_1', '$variable_2') and then in applications where I have needed to know the value of the $auto_increment_variable I have immediately queried the table for $variable_1 and $variable_2 and used $reference = mysql_result($result,$i,reference); to determine what numeric value was assigned. Is there a way I may find out what value was assigned to the $auto_increment_variable when the INSERT INTO query is issued? Yes. Again, it's in the PHP docs if you look in http://www.php.net/mysql for Get the ID generated from the previous INSERT operation Really, you should try the docs first instead of falling back on the soft option of asking the list. Also, just as a side note, you don't need to provide a value for the auto-increment field; that's why it is called auto as it does the incrementing automatically. If your response to that is I need the values in a specific order then you have the wrong idea of what the auto-increment field is for. Cheers -- David Robley Set laser printers to stun. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: SELECT
Ron Piggott (PHP wrote: Yesterday I asked how to get the date time 90 minutes ago and I received several responses. Thanks. I don't think this select statement is working correctly. (Correctly being what I am intending it to do) I took a look at the table this morning. One record remains that was created 2006-01-19 at 23:55:37. These are the values of date_created and time_created. The current values are approximately 2006-01-20 and 05:50:00 This is the select statement I am writing about: SELECT * FROM `table` WHERE `date_created` = '$date_90_minutes_ago' AND `time_created` = '$time_90_minutes_ago' Intellectually I know the problem: 05:50:00 is much earlier than 23:55:37 ... thus my AND is not allowing both conditions to exist together. Is there a way that I may modify this SELECT statement so the present conditions continue to exist and add a second part to the SELECT statement that if the time is 01:30:00 or higher that records from the previous day are selected? This continues to allow the 90 minute time frame for users logged into my web site ... I am not sure how you would add an OR function to the above without messing up what presently works :) (I am writing a SESSION function for my web site using mySQL and a cron. The select statement I quoted above is part of the cron.) Ron It would seem you have different columns for date and time? Seems to me that a little judicious use of CONCAT and DATE_SUB might solve your problem. In other words, create a valid date/timestamp value with CONCAT then use DATE_SUB to determine -90 min. I've given a Mysql based solution as this is php.db :-) Cheers -- David Robley I'm an ordained minister, said Tom reverently. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Add or Subtract
On Thu, 19 Jan 2006 22:55, Ed wrote: I've been considering doing a little project for my community site which allow people to sell and buy players ... They would have a limit of 2,000,000 upon sign up .. However i'm not sure how i'd update this figure Say player sells for example Alan Shearer for £300,000 he'd then have 2,300,000 how would i make it add to whats in the db already? same goes for if he was sold and it went down to 1,700,000. Ed You haven't read the mysql docs much, I guess. Assuming you are storing your limit as an integer: UPDATE table SET value = value + $newamount WHERE [something to identify the record to be updated] where $newamount is the positive or negative value of the increase passed in from wherever. Cheers -- David Robley Press any key to continue or any other key to quit... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Problem with creating parallel connections with mysql_connect
On Wed, 18 Jan 2006 19:51, Aarno Syvänen wrote: Hi List, decided to try non-permanent connections for now. So now I have: ? /* db.php */ $db_server=127.0.0.1; $db_user = asterisk; $db_pass = bozzo984; $db_db = bebbicell; $db_account_server=127.0.0.1; $db_account_user = asterisk; $db_account_pass = bozzo984; $db_account_db = asterisk; $allow_multiple = true; //$level= error_reporting ( 0); $bid=mysql_connect($db_server,$db_user,$db_pass, $allow_multiple); echo mysql_error(); //error_reporting ( $level); mysql_select_db($db_db,$bid); echo mysql_error(); //$level= error_reporting ( 0); $accid=mysql_connect($db_account_server,$db_account_user, echo mysql_error(); $db_account_pass, $allow_multiple); //error_reporting ( $level); mysql_select_db($db_account_db, $accid); echo mysql_error(); ? Still I have same error: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /var/www/bebbicell.ch/signup.php on line 212 Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in /var/www/bebbicell.ch/signup.php on line 213 Offending statements are: $res = mysql_query($sql,$accid); echo mysql_error(); $err = mysql_error($accid); Note that I use php-5.1.2RC1 compiled for Darwin Kernel Version 8.3.0 and Macintosh powerpc Aarno Try the above to find exactly where your problem is Cheers -- David Robley If I had anything witty to say, I wouldn't put it here. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] FTPing within PHP
On Thu, 19 Jan 2006 14:38, Ron Piggott (PHP) wrote: I am wondering if I may delete a file by FTPing within PHP. I found the followed on the PHP web site: fopen(ftp://user:[EMAIL PROTECTED]/somefile.txt, w); Is there a way for me to delete somefile.txt ? The FTP program on my computer gives the command DELE /path/somefile.txt Is there a way for me to send this command through? I also need to know the command to disconnect --- and wonder if someone could tell me it. Ron All is revealed at http://php.net/ftp Cheers -- David Robley FLOPPY DISK: Serious curvature of the spine. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Refreshing text question!
JeRRy wrote: Hi, Thanks for people that have commented and responsed. One stated my question had nothing to do with PHP and MySQL. Hang on to your horses, 90% oif the people that responded responded in an incorrect method I needed. Hence the appologies soon blooded in but thanks for the meta refresh but I know how to do this but thanks again! Now regarding It's not a PHP/MySQL question You too have FAILED to read my question correctly. It's certainly the funny season. I stated in my posting I will throwing the slogans/quotes in a db, fetching them and handling them in a db. Hence it will be as it's on a PHP page as I stated. Well, seeing you are maybe serving this using apache, perhaps it is more properly an apache question? But wait, apache runs under $OS so really it is a question for the $OS mailing list? :-) Sure, you might be getting the data via php/mysql, but the actual method you use to make the outcome how you want it, is not php. I just had to say that before the real pedants on the list get started :-) Cheers -- David Robley If you're not confused, you're not paying attention. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Importing CSV into MySQL
On Thu, 12 Jan 2006 11:18, Miguel Guirao wrote: Hi all, I remember reading in a book that there is a function to import the content of a CSV file into a MySQL table, am I alright? what is that function? Of course, the first option could be reading the CSV file line by line and using explode() to get each column value for each row. I think LOAD DATA INFILE might be one option Cheers -- David Robley Are you really American if your ethnicity has to be hyphenated? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] inserting due date into database
On Wed, 4 Jan 2006 07:37, Ruprecht Helms wrote: Hi, how can I calculate the due date from the date of an invoice and insert the result into a mysql-database. The daydifference is 14 days. Actualy I have tried something with mktimes, but I only get the timestamp of the due date. I have troubles to write that into a dabasefield that was set to datetype. Regards, Ruprecht You don't say what format the date is presented, but you could probably look at doing the calculation with mysql's DATE_ADD; see http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html for more information. Cheers -- David Robley Don't be a sexist, broads hate that. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] range_alloc_block_size
On 12/16/05, Murat Beyhan [EMAIL PROTECTED] wrote: Hello, Im using PHP and MySQL I try to import txt file to mysql Database But file size bigger than 2048KB so I could not import it It is related with range_alloc_block_size Because in mysql this veriable is 2048. If it is possible how can I change this variable. Please If somebody knows this help me.. Thank you... Murat Aaron Koning wrote: This could be a number of things. Are you uploading the file in the script? Then the max_upload_size may have been exceeded. If not, then it could be the memory_limit, or the max_execution_time. Check your httpd/php error log (commonly at: /var/log/httpd/error_log) and adjust the referenced variables in the PHP ini value or using ini_set(). Read this post also: http://aspn.activestate.com/ASPN/Mail/Message/php-db/2931073 I can't imagine this is a DB problem. Aaron It might well be. There is a config setting in mysql called max_allowed_packet which might be relevant in this case. IIRC it defaults to quite a small value. Yes, the default is 1 Mb in versions 3 and 4 of mysql. Cheers -- David Robley I joined the Lion's Club, said Tom pridefully. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: file_get_contents
Ron Piggott wrote: I have given the command file_get_contents($web_page_address); (I changed this from an array last week) But after 1015 characters of typing file_get_contents is truncating the text. I am wondering if there is a PHP setting which is causing this to happen. But I don't know which PHP setting to change when I use the phpinfo() command. Any suggestions? I am in an apache environment where I am able to set a local command with .htaccess file. Ron Some code would be helpful to try and resolve the problem. Presumably you are assigning the result of file_get_contents to a variable and then displaying that variable somehow? Perhaps the string being displayed contains a character that would foul up the display? More information, please. Cheers -- David Robley #define QUESTION ((bb) || !(bb)) - Shakespeare. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] file_get_contents
Ron Piggott wrote: This just got interesting. It does this error just through e-mail. If I run an 'echo $message;' the entire file which has been loaded displays correctly. My mail syntax is mail($to,$subject,$message,$headers) where $message is the HTML file text I am attempting to e-mail. file_get_contents is working correctly. This changes the entire problem now. Is there a limit to how many characters mail() will accept? No, but there may be limits on line length. The point where your message is breaking is on the longest line of text in that page; perhaps if you were to try wrapping the lines to around 80 characters you might get over the problem. If not, amybe it is the World Wide Web getting its own back for you using such a lengthy URL :-) BTW, your HTML syntax on that page is not correct. Cheers -- David Robley It's two, two, two mints in one, Tom said certainly. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: printing errors
(umeed wrote: most of the time wen dealing with mysql, i get error bt i want to exactly know wt the error is due to. how can i print specific error tht wil make it easy to know u cn us mysql_error() n prnt ur qry as well And perhaps if you write properly your questions may be better understood Cheers -- David Robley Change is inevitable, except from a vending machine. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Batch queries in the same mysql_query()
Denio Mariz wrote: Hi, I'm trying to execute multiple queries using mysql_query() function and I'm getting an error to check SQL syntax. My PHP code looks like: //- $sql=select x from y ; insert into y values ( 1, 2 ); mysql_query( $sql ) or die( mysql_error() ); //- Maybe the problem resides on the character ;, but this queries run without problems when typed on mysql command-line tool. So, if it works on mysql command line, why it doesn't work using mysql_query() ? Any hint ? If you look at php.net/mysql_query it will tell you that the query shouldn't end with a semicolon ; What it really should say is the query shouldn't _contain_ a semicolon. This is php attempting to protect you from SQL injection. Just do a separate mysql_query for each query. Cheers -- David Robley Friction can be a drag sometimes. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: xml to mysql tables using php
babu wrote: Hi all, I have seen in zend.com about parsing an xml document using php. i have also seen an interesting article which uses perl or java to move data from xml to database and vice versa. Does php has such functions to do so. Thanks It certainly does support parsing XML - see http://php.net/xml for all the gory details. Of course, you'll need to write your own code to insert the parsed data into your favourite database. Cheers -- David Robley Everything bows to success, even grammar. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: PHP Mail command
Ron Piggott wrote: I have a mail() question. Take a look at this sample code below: Pay attention the $message variable ? $to=[EMAIL PROTECTED]; $subject=Test e-mail; $headers = From: [EMAIL PROTECTED]; $message = But prove yourselves doesn't and not only hears. ; mail($to, $subject, $message, $headers); ? I have a mySQL database of quotations that one is randomly being e-mailed out daily. The trouble is that some quotations have marks in this such as the example above. This bit of code doesn't work because the computer is looking for a ; following the . Elsewhere in the quotation database there is the use of ' . Is there a way to do a search and replace for to ' ? The e-mails that are sent out are plain text e-mails. I have used the $quotation = mysql_real_escape_string($quotation); to be able to insert quotes with ' into the mySQL table; is there a similar way to get around this problem I am having? I suspect you want str_replace() Cheers -- David Robley Useless Invention: Brown undershorts. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Re: Select
Miguel Guirao wrote: You are right David, I have an auto_increment field!! What about this: $items2 = mysql_query(SELECT DISTINCT rev FROM rev ORDER BY rev, $link); where rev is a revision field for parts in my wharehouse!!! Does it will work in this case? Thanks -Original Message- From: David Robley [mailto:[EMAIL PROTECTED] Sent: Martes, 17 de Mayo de 2005 03:42 p.m. To: php-db@lists.php.net Subject: [PHP-DB] Re: Select Miguel Antonio Guirao Aguilar wrote: Hi!! I have this query in PHP: $items2 = mysql_query(SELECT DISTINCT * FROM rev ORDER BY rev, $link); I have three rows with the same data on it, and DISTINCT seems to be not working, since I got all the rows, any ideas of what is going wrong? Without knowing how many fields you have and what they are, no. But you should realise that DISTINCT looks at _all_ selected fields in a record, so if you have an auto_increment id field in amongst those selected, all the records will be different. David That should work as you expect it to. David -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Select
Miguel Antonio Guirao Aguilar wrote: Hi!! I have this query in PHP: $items2 = mysql_query(SELECT DISTINCT * FROM rev ORDER BY rev, $link); I have three rows with the same data on it, and DISTINCT seems to be not working, since I got all the rows, any ideas of what is going wrong? Without knowing how many fields you have and what they are, no. But you should realise that DISTINCT looks at _all_ selected fields in a record, so if you have an auto_increment id field in amongst those selected, all the records will be different. David -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Just can't get it to work.. variables
Gavin Amm wrote: Hi All, I just can't for the life of me get the variable to output a value from the array: (all preceding script in place to make this work..) The start date retrieved from the database is, for example, 20050412 (mmdd). The example output for each variable (w/o quotes) is: $monthInt outputs 04 $monthVal outputs ### CODE FOR DEBUGGING PURPOSES ### while ($row = mysql_fetch_array($result)){ $monthName = array (, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec); $monthInt = substr($row['start'], 4, 2); echo \$monthInt = $monthIntbr; $monthVal = $monthName[$monthInt]; echo \$monthVal = $monthValbr; echo pb.$monthVal. .substr($row['start'], 6, 2)./bbr\n.$row['details'].\n/p\n\n; } That would indicate that you are actually saying: $monthVal = $monthName[04]; where the 04 is actually a string; you have no element '04' in your array. Cast $monthInt to an integer before you use it as an array element. Alternatively, if you are using MySQL, you can use DATE_FORMAT to achieve the same result. ### ORIGINAL CODE ### while ($row = mysql_fetch_array($result)){ $monthName = array (, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec); echo pb.$monthName[substr($row['start'], 4, 2)]. .substr($row['start'], 6, 2)./bbr\n.$row['details'].\n/p\n\n; } David -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Re: Just can't get it to work.. variables
Gavin Amm wrote: Yeah, I ended up doing that (associative array) then reading your e-mail.. Oh well, thanks. I couldn't cast the var as an int. in the database it's setup as a timestamp(8) (mmdd), not sure why I set it up as such.. Cheers, Gavin I guess I didn't fully explain that I meant cast as an int in php :-) David -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Connecting To Mysql through php/mysqli
On Thu, 3 Feb 2005 13:49, Graeme wrote: I like the idea of a mysqli_queasy() function. Maybe it would allow you to sumbit SQL statements that don't conform to any standard? ;) graeme. Bastien Koert wrote: the second error is a misspelling in the mysqli_query command bastien Call to undefined function mysqli_quesry() in C:\Apache Or it vomits on your monitor if there is a syntax error? -- David -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Excel to MySQL
On Tuesday 25 January 2005 08:07, Novice Learner wrote: Hello, I have an Excel worksheet with a database in it. I would like to move this data to the database on the server that would work with my .php files. Is there a way? I apologize if I posted this question on the wrong list. Thank you, One option might be to export the Excel data as csv, then use whatever option your database provides to import the csv data. -- David Robley Nostalgia isn't what it used to be. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Returns Blank
On Thu, 20 Jan 2005 14:20, Squeakypants wrote: I can't figure this out, it just shows blank... $user=$_POST['user']; $pass=$_POST['pass']; mysql_connect($host,$username,$password); @mysql_select_db($database) or die( Unable to select database); $query = SELECT credits FROM krypto WHERE user = ' . $user . ' AND pass = ' . $pass . '; $result = mysql_query($query); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; } echo mysql_result($result, 3); mysql_free_result($result); mysql_close(); A couple of possibilities come to mind; there is no matching record and therefore no output; there is a matching record but because you have selected one field and asked for the fourth field there is no output. Try checking the number of rows returned to see if the is in fact a matching row, and try echoing some text to ensure there is output to the browser. Also a check of the document source might help. -- David Robley This steamroller really works, said Tom flatteringly. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: ssh tunneling with phpmyadmin
On Tue, 11 Jan 2005 14:09, Graham Anderson wrote: is it possible to ssh tunnel with phpmyadmin I want to access my remote db [on shared server] from my phpmyadmin on my laptop my ISP wonderfully disabled phpmyadmin's relational features :( seems a bit hard to find the info so I thought I would ask here :) I am using Mac OS X if it matters many thanks g If your ISP allows you to make a remote connection to mysql, just point your local phpmyadmin at that. -- David Robley I've gone back to my wife, was Tom's rejoinder. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Looping within a string?
On Fri, 17 Dec 2004 13:54, Chris Payne wrote: Hi there, Well basically I have a list of items and their prices etc . which have to be sent via email, so I need to store the data in a string. I THOUGHT I could execute the loop with all the elements (Such as table rows etc ...) inside a string, but I was wrong, so how can I store the data PLUS the table data into a string? It has to be an HTML email and I'm stumped. I can send an email no problem, but not with all the data, just the last row in the data. Chris On Friday 17 December 2004 10:33, Chris Payne wrote: I?m having to send an email with looped results, but I?m having problems. I can send an email no problem, and this code works OUTSIDE of the string, but not inside, can anyone see what is going wrong? Please explain what you are doing. A string is a string. Code doesn't execute inside a string. What else are you doing to the string? Create the output in the same manner as you would use if you were displaying it; in other words, loop through the source (database, whatever) adding the formatting as required. Instead of echoing the output to screen, append it to a variable. Voila, you have the data all in one variable. -- David Robley My pencil is dull, said Tom pointlessly. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Using a loop on a result destroys array??
On Thu, 25 Nov 2004 01:36, Mark Benson wrote: On Wednesday, November 24, 2004, at 02:40PM, Norland, Martin [EMAIL PROTECTED] wrote: The real problem you're having is the statement says while there are results in this query, grab them - once you reach the end of the first while loop, there are no more results, so the second one is skipped right over - it's condition *never* evaluates true. So by running a while (mysql_fetch_array($result) loop over a fetch array you effectively empty it? Not really. What is happening is that each time you get a row from the result set, an internal pointer is advanced to the next row; if the final row has been requested, the pointer points to 'nowhere' and can't be further advanced without resetting it to the first row. Cheers -- David Robley I won't finish in fifth place, Tom held forth. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: How do I reverse-finding root entry in tree-structure ?
On Sun, 31 Oct 2004 13:10, -{ Rene Brehmer }- wrote: Hi gang This is possibly insanely simple, but I've been coding on it for the past 11 hours, so my head's gone a little fuzzy. been through the MySQL manual, but it's not really agreeing with me on finding anything useful... I've got a table of categories, organised in a tree structure: table wp_categories catID int(10) UNSIGNED parentID int(10) UNSIGNED rootID int(10) UNSIGNED level tinyint(3) UNSIGNED cat_title varchar(255) cat_desc text catID being the primary key, parentID the parent's ID, and rootID the ID of the root category of the branch this category belongs to. Level is simply a number as to how deep in the tree the given category is. I only use it to make it simpler to build the graphics. Here comes the problem: I need to be able to build visually the branch from root to a given folder, using only the given folder's ID as starting point. That is, traversing backwards up the branch from any given folder, and reattaching the branch till the root is reached. Building the entire tree from root down is easy enough, but for some reason I've got a brainfart as to how I can go backwards. That said, I know I could probably do this using recursive SQL statements, but I'd rather use as little talking with the DB as possible. The goal is to do this one task with as few SQL calls as entirely possible, preferably 1, 2 at most... since I found building arrays and traversing them is much faster than SQL calls... the root ID is 0, so any category in root, will have parentID of 0, and rootID of 0. I figure using the rootID to just pull the relevant branch might be part of it, but my problem comes with reattaching the branch correctly, and finding the root folder and stick the branch to it ... and doing all of this in reverse since that's what I need for the visual part... Using MySQL btw ... I don't know if you have seen http://www.sitepoint.com/print/hierarchical-data-database but it may provide some help. Cheers -- David Robley Don't use no double negatives. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Finding the highest number in a column?
On Thu, 28 Oct 2004 13:03, Chris Payne wrote: Hi there everyone, I am working with a very complex system where not all numbers are assigned 1, 2, 3 ?? etc ?? so there could be a row with the number 1 and then the next row could be 40 and so on ?? Is there a way with PHP and MySQL to find out what the highest number is in a particular column easily when the numbers are auto-incremented so aren?t necessarily one after the other? I would really appreciate any help on this as it?s really bugging me. Chris Does SELECT MAX(column) do what you want? -- David Robley Me know gammar. Me cood use it gud. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: I can't seem to get Max() to work
On Thu, 28 Oct 2004 14:35, Chris Payne wrote: Hi there everyone, I can?t seem to get the below to work with PHP and MySQL: $sql = SELECT MAX(FoodItemNumber) FROM menuitemsubs; What am I doing wrong? I need the highest number from the column FoodItemNumber, but it doesn?t return anything unless I change the MAX() to a * and I don?t want that I need it to be the MAX() number as it isn?t an auto-increment field. Works a treat for me; au_linkid is a smallint which is not autoincrement, nd not indexed at all. mysql select max(au_linkid) from categ_link; ++ | max(au_linkid) | ++ |540 | ++ 1 row in set (0.03 sec) FoodItemNumber is an integer type? -- David Robley I Have To Stop Now, My Fingers Are Getting Hoarse! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Converting Date for mysql
On Fri, 15 Oct 2004 17:26, Stuart Felenstein wrote: See below: --- John Holmes [EMAIL PROTECTED] wrote: Are you sure it's the date that's causing the rejection? What does mysql_error() say? No, I'm not sure. At first the date was being accepted but wrong in the database. It was setting it to 1/1/2000. Someone suggested I add '' around the value. Apparently it didn't like that and started saying I had a SQL error. I've tried a number of things, so far without success. This is the current error: 0: 1064: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '', 1, 1, 24, 25, 10/28/2004)' at line 5 While this is probably a waste of bandwidth here is my statement: $query = INSERT INTO CorrectTableName(RecordID,UserID,ProfileName, Edu, WorkAuth, WorkExp, CarLev, Secu, Confi, Relo, Telecomu, City1, State1, City2, State2, TravelPref, SalaryAnnual, SalaryHourly, Available) VALUES (null, null, '$f1a', $f2a, $f2c, $f2d, $f2e, $f2g, '$f5b', '$f3m', '$f3n', '$f3e', $f3f, $f3g', $f3h, $f3i, $f3j, $f3k, $f3l); Outside of the date I don't see where the error could be coming from. Fields with quotes are string values. I have no idea. You seem to be missing a single quote at the beginning of $f3g May I suggest that as well as echoing mysql_error() you also echo your query; that way you can see _exactly_ what is being passed to mysql and you can resolve problems like this simply and without resorting to the mailing list. -- David Robley Terminal glare: A look that kills... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: error
On Tue, 28 Sep 2004 20:28, [EMAIL PROTECTED] wrote: Dear friends, Script writes to database, however gives this error while on internet web server, on local host doesn't give same error. Any guidance, please Thank you - Back to Main Notice: Undefined index: op in \\premfs15\sites\premium15\mrbushforpeace\webroot\replytopost.php on line 9 You probably have different error_reporting settings in the php.ini files on the different servers. Test if the value is set. -- David Robley I commanded a group of ships for a week, Tom said fleetingly. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Finding the value of the COMMENT in a table column
On Sun, 19 Sep 2004 21:19, Ross Honniball wrote: Hi all, Anyone know how to access the optional COMMENT you can add to columns during table creation? eg. create table x (fldx char(1) COMMENT 'some comment', fldy char (1) COMMENT 'another comment') I want to 'get' the COMMENT field. I know it should be in the manual, but I can't find it. Thanks ... Ross . . Ross Honniball. JCU Bookshop Cairns, Qld, Australia. SHOW TABLE STATUS LIKE 'pattern' or SHOW CREATE TABLE tablename will return the table comment, along with other info - you'll have to parse it out of the returned data. If there is a better way, I haven't found it yet :-0 Not sure how this will work with column comments. Cheers -- David Robley May I introduce the family Stone? Tom asked slyly. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Socket Errors
On Fri, 17 Sep 2004 08:56, Joseph Crawford wrote: Can anyone shed any light on this error, i have googled and found out it is a winsock error but i havent a clue why i am getting it, one minute this worked the next it didnt. Warning: fsockopen() [function.fsockopen]: unable to connect to news.php.net:119 (A non-blocking socket operation could not be completed immediately. ) in D:\htdocs\WebReader\System\NET\Sockets\Socket.php on line 25 The nntp server at news.php.net seems to have been out of action for quite some hours. -- David Robley Constant change is here to stay. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Name searches for the spelling impaired
On Mon, 6 Sep 2004 11:09, Pete Holsberg wrote: Is there a way to program MySQL so that it can find the name Smyth if the user looks for Smith? And similar mispellings that are similar in sound. The SOUNDEX string function in mysql may be what you want. http://dev.mysql.com/doc/mysql/en/String_functions.html Something like SELECT fields FROM table WHERE SOUNDEX(name) = SOUNDEX('searchvalue') Cheers -- David Robley Lead me not into temptation, I can find it myself. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] I have a CR-LF problem when pulling stuff out of my DB
On Fri, 20 Aug 2004 01:31, Michael Cortes wrote: I found part of the answer.. when doing a search in vim you can hit ctrl-m as long as you hit ctrl-v first. ctrl-v tells vim to treat the following as a character, not to do the action i.e... carriage return. Now I need just one more piece, if anyone has the answer: ctrl-m is a carriage return. Does anyone know what ctrl seqence is line feed? Thanks Add these to your list of useful vim character codes: Ctrl-H = Backspace Ctrl-I = horizontal tab Ctrl-J = Line feed Ctrl-K = vertical tab Ctrl-L = form feed Cheers -- David Robley Would you like to buy an alarm? asked Tom self-righteously. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Php if statement in a form
On Fri, 6 Aug 2004 11:04, Justin Baiocchi wrote: Still no joy. The parse error actually refers to the -- if ($row[timeout] IS NULL); --- line. Please trim your replies. IS NULL is for mysl - try if ($row[timeout]=== NULL) -- David Robley Heads I win, tails you lose. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: sendmail
On Tue, 3 Aug 2004 04:01, Aaron Todd wrote: So far, I have been doing ok with PHP. I feel that I have picked it up rather easily. But now I need some help. I am trying to use the sendmail functions to send data entered in a form to my email address. Currently its not working at all. I am getting a Fatal Error: Call to undefined function: sendmail() in /home/virtual/site341/fst/var/www/html/register.php on line 87 I havent found very much info on the sendmail function so I was shooting in the dark with it. I did read in the manual some stuff about seting it u in the php.ini file that just went over my head. Can anyone enlighten me on this function. Thanks, There are no sendmail functions in php - there is the mail() function that should interface with whatever mta you have, if php was compiled with the mta already installed. Cheers -- David Robley It's as easy as 3.14159265358979323846264338327950... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Converting an MS Access DateTime in PHP
On Wed, 4 Aug 2004 07:39, Andrew wrote: If I retrieve a DateTime variable from an MS Access database, how can I convert/format it in PHP? Thanks. andrew Not knowing what format Access provides its dates in, I suggest you look at the Date and Time functions that PHP has, and pick one to suit. http://www.php.net/manual/en/ref.datetime.php -- David Robley OK, I'm weird! But I'm saving up to become eccentric. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: JOIN question
On Wed, 28 Jul 2004 14:00, Chris Payne wrote: Hi there everyone, I'm transferring a client's product from a Visual Basic .NET ACCESS 2000 application to run on a custom install of Apache/MySQL/PHP which I created (With a custom installer which sets everything up for them). My question though, is on looking through their ACCESS database, there seem to be table joins - or at least that's what I understand they would be under MySQL 4. How can I read information from 3 tables at the same time? I am a little confused, I gather you use JOIN but I'm not sure how it works, could someone please show me an easy to follow example? Thanks, I really appreciate it. Oh and so far, on the pages that I haven't had to use JOINS, I can honestly say that MySQL is FAR faster than ACCESS from what I'm seeing in my development here. Chris Check out http://dev.mysql.com/doc/mysql/en/JOIN.html for the syntax and examples, and also http://www.google.com/search?q=sql+tutorial as a starting point for some SQL tutorials which will cover joins in more detail than you will probably get here. -- David Robley Shh! Be vewy quiet, I'm hunting wuntime errors! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: php/mysql error
On Wed, 28 Jul 2004 02:36, Redhat wrote: I am getting a weird error on one of my servers that says something about query requires full tablescan. I was not getting this error until today that I noticed. I Googled for a minute and saw where a ton of other sites had the same problem but no reason why. I did find one board that said to turn off mysql.trace_mode in the php.ini file. I did this and it fixed the problem. Is there something different that I should be doing when I write code? Have I just band aided the problem or solved the problem? thanks, Doug You are possibly using a query without indexes. Try running EXPLAIN on your query, and have a look at this page from the mysql site which tells more about table scans. http://dev.mysql.com/doc/mysql/en/How_to_avoid_table_scan.html Cheers -- David Robley Help! I'm lost somewhere in the Generation Gap. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Query returns duplicate rows
On Thu, 22 Jul 2004 05:59, Brock Jimmy D Contr 74 Mdss/Sgsi wrote: My query is returning duplicates rows. table: elements elementId standardId elementtext category mcode linenum table: scores scoreId taskId scores Here's my query: SELECT distinct elementtext,cateogy,mcode,linenum,scores,scoreId FROM elements, scores WHERE scores.taskId='12' AND elements.standardId='APR.05' This is returning duplicate rows, even though I'm using the DISTINCT keyword. If I remove the field scoreId it is fine. Any suggestions? I think you may misunderstand exactly what DISTINCT does. The keyword applies to the entire record, not individal fields, and will effectively delete any duplicate rows. ScoreId is presumably a unique ID for the record; that being the case you can expect all selected rows will be different. Cheers -- David Robley Backups? We don' *NEED* no steenking backups. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] problem....
Water_foul wrote: i fixed those things and it didn't fix it :( :( :( :( :( :( :( :( :( is there a icq chatroom for php?) Shahmat Bin Dahlan [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Your SQL statement: 'SELECT Rune, username FROM RuneRunner RuneRunner_1 WHERE (User_ID = 3)' What is RuneRunner and RuneRunner_1? Are these two different tables. If it is, you might want to separate them with a comma. Why not try getting rid of the brackets surrounding User_ID=3? And also wrap single quotes around the digit 3. - Original Message - From: water_foul [EMAIL PROTECTED] Date: Wednesday, June 23, 2004 8:58 am Subject: Re: [PHP-DB] problem I checked em all they were right Daniel Clark [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Sounds like it doesn't like your SQL statement. Perhaps a field or table name is incorrect? Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in ... Daniel Clark [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] What error are you getting? why doesn't this work: $pic=mysql_query('SELECT Rune, username FROM RuneRunner RuneRunner_1 WHERE (User_ID = 3)',$connection); $pic=mysql_fetch_array($pic); Two suggestions for debugging mysql problems: 1) Create your query as a variable so you can echo it and see exactly what is being passed to mysql $query = SELECT Rune, username FROM RuneRunner, RuneRunner_1 WHERE User_ID = 3; 2) Use mysql_error() to get the actual error from mysql $result = mysql_query($query,$connection); echo mysql_error(); $pic=mysql_fetch_array($result); -- David Robley I'd like to learn a new card game, Tom said wistfully. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Re: CSV update Mysql feature
Kenny wrote: Well the problem is how would I create the query? -Original Message- From: Uzi Klein [mailto:[EMAIL PROTECTED] Sent: 01 June 2004 07:36 To: [EMAIL PROTECTED] Subject: [PHP-DB] Re: CSV update Mysql feature It's kinda clear. What isn't clear is what the problem? Kenny [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] hi all, What I am trying to achieve to no avail is the following I export values from a Mysql db into CSV format for quick updates and that works fine.. http://www.xarex.com/jantar/admin/pick_csv.php www.xarex.com/jantar/admin/pick_csv.php But as you can see from the page you can select the options that you want to d/l I am going to make ID compulsory but its not necessary for the time being, The problem that I am having is with the update Mysql feature What I need to happen is the first line of the CSV is the headings (db field names) So that when I do the update it only updates the fields that were chosen on the pick_csv page. Now I will have no way of knowing before hand what fields will be chosen so I will have to create the update Mysql query on the fly, I hope this is clear enough any help will be great I haven't looked at your page; but the general idea would be to test what options are selected and dynamically build your query accordingly. Eg, assuming your info is coming from POST: $query = SELECT id; if(isset($_POST['name'])) { $query .= , name; } // more of the same for each field $query .= FROM table WHERE where ORDER BY whatever; Or something like that. Then you output in csv format with echo or print or sprintf or whatever -- David Robley Don't hate yourself in the morning - sleep till noon. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Multi search function (help)
Nabil wrote: hi all Is there a way to condition your search: -I have a form for four text boxes for search my Mysql... -I don't want to write 4 conditions and for SQL statements incase he decided not to search with all keywords (fields) - I have by example : name, lastname , nickname and phone form... I need a way to select my records even one or more field were null (searching only on of the above) because the following SQL will generate null result $name=$_POST['naame']; $lastname=$_POST['lastname']; $nickname=$_POST['nickname']; $m_date=$_POST['m_dateY']; echo $name.$lastname.$nickname.$m_date; $sql = mysql_query(SELECT id, name , lastname , m_date from users where name like binary '%$name%' and lastname like binary '%$lastname%' and nickname like binary '%$nickname%' and m_date= YEAR('$m_date') order by id ASC ) or die(mysql_error()); Thanks in advanced Use isset to test whether the POST values are set and only include in the query if there is a value. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Multi search function (help)
Nabil wrote: David Robley [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Nabil wrote: hi all Is there a way to condition your search: -I have a form for four text boxes for search my Mysql... -I don't want to write 4 conditions and for SQL statements incase he decided not to search with all keywords (fields) - I have by example : name, lastname , nickname and phone form... I need a way to select my records even one or more field were null (searching only on of the above) because the following SQL will generate null result $name=$_POST['naame']; $lastname=$_POST['lastname']; $nickname=$_POST['nickname']; $m_date=$_POST['m_dateY']; echo $name.$lastname.$nickname.$m_date; SELECT id, name , lastname , m_date from users where name like binary '%$name%' and lastname like binary '%$lastname%' and nickname like binary '%$nickname%' and m_date= YEAR('$m_date') order by id ASC ) or die(mysql_error()); Thanks in advanced Use isset to test whether the POST values are set and only include in the query if there is a value. thanks .. but my question is not for isset... i m thinking consider that i have 10 search fields... if i have to do a combination then i need a day to right the various SQL statements So do something like: $query = SELECT id, name , lastname , m_date from users where 1 ; if (isset($_POST['name'])) { $query .= AND name like binary '%{$-POST['name']}%' ; } if (isset($_POST['lastname'])) { $query .= AND name like binary '%{$_post['lastname']}%' ; } //etc etc $query .= order by id ASC ; $sql = mysql_query($query) or die(mysql_error()); -- David Robley Only cosmetologists give make-up exams. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: Regular Expression
[EMAIL PROTECTED] (Andy Amol) wrote in news:[EMAIL PROTECTED]: hi, Thanks for the reply. I want to know how to include char - i.e a dash . I want to test for it. eg: COSC-3006. I should be able to test that string as valid. Also is there a way in which the form validation fails but when the user goes back to the same form its previous values are retained. eg: Suppose the user enters its name, age and phone number. But the phone number is wrongly entered. Then he goes back, the old values should still be displayed. Only the phone number should be cleared. Also how to program for such a back button. In what I have done is simply called the previous form, so it clears all the values. Any help in appreciated. Call the previous form but pass it the values as hidden fields. Or better, do all the input, validation and etc in the same script, passing the values each time. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Fatal error: Call to undefined function: mysql_connect()
[EMAIL PROTECTED] (Tim) wrote in news:[EMAIL PROTECTED]: Setup: 2 servers, one with PHP 4.1.2 and no MySQL installed, the other has MySQL and PHP 4.1.2 Problem: I am attempting to connect to the MySQL server from the server without MySQL, but I get the error that shows in the subject. Fatal error: Call to undefined function: mysql_connect() in /folder/index.php on line 11 I was told that maybe the extension for MySQL was not setup in PHP. I thought that maybe it was just because MySQL wasnt installed on the system I am working on, but it makes sense that I am not trying to access a database on the system I am working from, but trying to access one on a different server all together. What do you think? I think the error message tells it all - there is no mysql support in the php you are using. You'll need to recompile with php support, or load a mysql extension library. Cheers -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Hi I am new to PHP
[EMAIL PROTECTED] (Andy Amol) wrote in news:[EMAIL PROTECTED]: I have posted my problem at No: 33892 of this mailing list. I have received 1 reply. No: 33897 My exact problem with second file is as follows: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource on line 15 Can you help me to solve problem, any help would be appreciated. Thanks. Your sql syntax is probably wrong. Somewhere before line 15 you are presumably using mysql_query to submit your query. Try adding to that line or exit( 'Error: ' .mysql_error() ); which will halt your script and return a useful error string from mysql if there is an error. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Query Help!
[EMAIL PROTECTED] (Jerry) wrote in news:[EMAIL PROTECTED]: Hi Everyone, Happy Easter to you all. I have this query, reasoning for posting on this Mailing List is under it. :) SELECT `username` , `score` FROM round . $round_number . WHERE 1 ORDER BY `score` DESC LIMIT 0, 30 Is there a way to make it output the $round_number -1 (minus one number)? I need this to be a temp. meassure as I only need the number previous to the current $round_number for a few days. Is there a way in the query I can subtrack the value by 1 and change it later when I want to show the current round? If it's too much hassles I can add $prev_round_number and change the values each week but thought there might be another way. Have you tried SELECT `username` , `score` FROM round . ($round_number -1) . WHERE 1 ORDER BY `score` DESC LIMIT 0, 30 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Sort Order Description
[EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: How can I have the explanation above a php table on a sort come out as something different than the sort coding? For example, the sort line below results in the following text above the sorted table: Data Set Sorted by (ssa1202.total/vapall.vapall)*100 in Descending Order. I'd prefer simply Data Set Sorted by Percent in Descending Order. I tried naming the sort field as Percent but that didn't change anything. echo tddiv align='center'font size='3'bPercenta href='ssa1202.php?sort_field=(ssa1202.total/vapall.vapall)*100sort_ord er=desc' target='_self'font size='2'brSort/a/b/font/div/td\n; Ken Without seeing the code that produces the text above the table, its a bit hard to give any suggestions. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Using results for next query
In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... Hi People, Am needing a little help on the following scenario. Selecting user_id from one table for all entries that match the required criteria. Now I want to use the user_id's that are returned by the previous query in another to obtain more information from another table. Basically using the results of one query to become the critera for another query and do this for all the responses from the first query. Any assistance would be greatly appreciated. Cheers, Shannon If there is a direct link between the tables, for instance the user_id, you could probably use a join to achieve this with just one query. Something like: SELECT user_id, othertablea, othertableb FROM userid_table, othertable WHERE [userid criteria] AND userid_table.user_id = othertable.user_id Cheers -- Quod subigo farinam A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: passing parameter to function
In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... Hi, Say I have a script that knows the value of a variable $codename. The script contains a function that needs to know the value of $codename. What is the syntax for passing the parameter to the function? Example: the script knows that $codename = blah. The function has to pass 'blah' on to another script as a hidden value in a form using the POST method. The other script is not receiving the value of $codename. Thanks for any help. Robbie There are some examples at http://www.php.net/manual/en/functions.php which should give you some ideas. -- Quod subigo farinam A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Starters question: mysql PHP.INI
In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... Dear all, I'm trying to get the horde applications working. The horde people have redirected my question to this list. Here it comes: How should I change the PHP.INI file in order to work with mysql session data, instead of files? Have a look at http://www.php.net/session_set_save_handler for more information I ask this, because googling did not reveal any parameters to put in the ini file. I also tried to change the path from /var/www/tmp to /var/www/html/tmp, but files keep on being written to /var/www/tmp. How can this be? You realise that you need to restart Apache to have the changes in php.in read? Thanks, Jeroen -- Quod subigo farinam A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: resultset problem
In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... HI all, I am querying a db and getting the resultset, then to get out each individual field of the resultset (which is a single unique line all the time) as mysql_result($result2, 0, p_company). the problem is that if the actual field has a space in it say Sun microsystems, I only get sun and it doesnt give me anything after the first space. I have looked at the manual but as far as im concerned its really vague in its description of alot of the mysql functions. any idea what could be causing this?? thanx Angelo How do you _know_ you are only getting back up to the first space? Depending on how you are trying to display the results, your html may be incorrect, giving the false impression that you have missing information. If, for example, you are displaying in a text field like this: INPUT TYPE=TEXT VALUE=php echo $value then you need to quote the value to avoid the problem you describe. If this is not the case, perhaps a snippet of code that illustrates the problem might help us to help you. -- Quod subigo farinam A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: php/mysql weblog - addnews function problems
In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... hey, I've been working on a PHP/MYSQL weblog and I've got most of it working apart from the adding new news function and a login section. I've set the form up but it is coming up with a few errors and the actual submitting of data doesn't work as of yet. The code is too long to include in this post and its hard to explain exactly where it is going wrong because I'm fairly new to PHP and MYSQL - this is my first stab at them both. Just wandering if anyone could take a couple of minutes to look at my php code and tell me what is wrong with it? (it's probably something blindingly obvious;)) thanks very much slippy Perhaps if you were to post the errors returned and the few lines of code leading up to the line where the error occurs... -- Quod subigo farinam A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: PHP command not function after upgrade to 4.22
In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... Hi, I've upgrade the PHP 4.06 to PHP4 .2.2 in Redhat 9.0. after that, it was found the following script can't work well. the empty seems not function. Any one can help! ... If (empty ($A) . else ... Best regards, Raymond Check the value of register_globals in php.ini or phpinfo(). If it is set to Off and $A is passed from another page, you'll need to use $_POST or $_GET to retrieve the passed value. -- Quod subigo farinam A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Keeping the mailing list sain
In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... Hi guys, So that I don't drive members of the mailing list insane: In Outlook XP (2002), I want to enable the Out of office feature; what I don't want to do is have it reply to every message posted to the PHP mailing list. Does anyone know how to create a rule, to do this? I really don't want to unsubscribe subscribe to the list every time I go out of the office... Thanks, Gav Can't tell you how to do a rule in Outhouse as I don't use it, but the rule would be to check the To: field to see if it contains the mailing list address - [EMAIL PROTECTED] for this list Cheers -- Quod subigo farinam A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Display Mysql Result in drop down list
In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... Hi all, Right now I'm trying to retrieve one of the column tutor_name and display al the tutor's name in a drop down list. The problem now is, the drop down list only manage to display 1 record from that row instead of all tutor's name under tutor_name column...wonder where the problem lies?? Hope to get some help soon. Below is a snip of the code: Drop me a msg if anyone needs the entire code. SELECT NAME=tutor_name class=textarea ? $sql = mysql_query(SELECT DISTINCT tutor_name FROM tutor ); if ($row = mysql_fetch_array($sql)) replace the above with while ($row = mysql_fetch_array($sql)) If will be true, but will only produce one result. You want to iterate through all results, which is why you use while. It will return as many results as are available. { print OPTION VALUE=\$tutor_name\ SELECTED .$row [tutor_name]. /option; } $result = $db-query($sql); ? /select Thanks in advance =) Irin. -- Quod subigo farinam A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Where's the mix-up?
In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... Help: snip $sql = select id1 from GCN_Salesmen where username = '$PHP_AUTH_USER'; $user_id = mysql_query($sql) or die(mysql_error()); /snip Produces: You have an error in your SQL syntax near 'id #2' at line 1 snip $sql = select id1 from GCN_Salesmen where username = $PHP_AUTH_USER; $user_id = mysql_query($sql) or die(mysql_error()); /snip Produces: Unknown column 'robert' in 'where clause' I have even tried like instead of = and still getting errors. I know this is a stupid error, but... Thanks, Robert ~~~ Money is like manure - it is meant to be spread around. ~~~ Try $user_id = mysql_query($sql) or die(mysql_error().BRQueryBR.$sql); so you can check your SQL; post the results if you cannot resolve it yourself. Cheers -- Quod subigo farinam A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php