Re: [PHP-DB] How to know the name of a function ?
On 9 Nov 2008, at 21:41, Jean-Philippe Battu wrote: In a function, what is the best way to know the name of this function ? I read the documentation and found only func_num_args(), func_get_arg() and func_get_args which are relative to the arguments given to the function. What is the equivalent to $0 (bash) in php ? The constant __FUNCTION__ will give you this. -Stut -- http://stut.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql_select_db
On 20 Oct 2008, at 13:03, Stan wrote: UBUNTU Server v8.04 On a web page: CODE: require_once 'frames_includes/navigationDB.inc'; $navigation_connection = mysql_connect($navigation_hostName, $navigation_userName, $navigation_passWord) or die("Failed to connect to MySQL on the nasServer ... call Stan"); mysql_select_db($navigation_databaseName,$navigation_connection) or die("Selection of 'navigation' database failed ... call Stan"); $navigation_data = mysql_query("SELECT * FROM " . $navigation_databaseName . ".navigate " . "ORDER BY navigateHandle", $navigation_connection) or die("SELECT * FROM navigate table failed ... call Stan"); END CODE: works when the UBUNTU server is attached to the same subnet as the MySQL server. If I move the UBUNTU server to a different subnet (through an ipCop machine), making appropriate adjustments to network configuration, including punching a hole in the firewall for port 3306 from the UBUNTU server to the MySQL server and authorizing the user at the new IP to MySQL, the mysql_connect works but the mysql_select_db fails. I need help debugging this, please? MySQL permissions are tied to IP or hostname as well as username and password. Sounds like the user you're connecting as has different permissions when it comes from a different subnet. Check the MySQL manual for detailed info on permissions. -Stut -- http://stut.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Timestamps
On 30 Apr 2008, at 16:29, Jason Pruim wrote: Okay... So I know this should be simple... Trying to store a timestamp in a MySQL database... The timestamp I am making like so: $modifiedTimestamp = time(); and then just $sql = "Update `mytable` set timestamp='$modifiedTimestamp' where Record='1'"; Simple right? Not quite...in my database it's storing a "0" in the timestamp field which is a int(10) field. I have googled, and searched manuals, but have not been able to figure out what is going on Any Ideas? timestamp is a reserved word. Try putting it in backticks. -Stut -- http://stut.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Resource id #5
On 27 Mar 2008, at 17:51, Richard Dunne wrote: Can someone explain how I can translate Resource id #5 which is what I am getting from the code below? $result = mysql_query("Select answer from answers") or die(mysql_error()); $resultArray = explode(',',$result); for ($i=0;$i For the love of $DEITY, please read the frickin' manual: http://php.net/mysql . You've been asking similar questions around this topic for the past few days and you clearly haven't moved forward in your understanding. The mysql_query function returns a resource. If you print a resource you get the text "Resource id #n" where n is replaced with its ID. To make use of this resource you need to use functions like mysql_fetch_array, mysql_fetch_assoc or one of the many others detailed in, you guessed it, the manual. Try it, you might like it. -Stut -- http://stut.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] SELECT query with multiple "WHERE" Clause
On 27 Feb 2008, at 23:44, Nasreen Laghari wrote: Thank you for increasing my knowledge about PHP/MYSQL. The question you ask below is basic SQL syntax. Please read the MySQL manual before asking here - answers at this level are all in there. http://mysql.com/doc Oh, and once you have it working try entering ';delete * from gig;select * from gig where Name=' (including quotes) into the gig_name form field. When you get over the loss of all your data go read about sanitising your input: http://php.net/mysql_real_escape_string -Stut -- http://stut.net/ I am creating a SEARCH, by only using one table. The search form is same as Inserting item (search has form of all fields in table ), difference is SEARCH page doesnt have validation . Therefore user can enter information in any of field. I would like to know how to write a SELECT query which has multiple where clause with OR operator. shall we write: $query = mysql_query("SELECT * from gig WHERE Name='$name' || WHERE gig_fdate='$sdate'"); OR $query = mysql_query("SELECT * from gig WHERE gigName='$gig_name' OR WHERE gig_fdate='$sdate'"); OR $query = mysql_query("SELECT * from gig WHERE gigName='$gig_name' || gig_fdate='$sdate'"); Regards Nasreen Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] How to recognize which 'case' is being echoed by switch statement
On 22 Feb 2008, at 11:01, Tim Daff wrote: "; } else { echo "Contacta>"; } ?> $page = case; will be raising a notice which you're obviously not seeing. So, step 1 is to edit PHP.ini on your development machine so error_reporting is E_ALL, and display_errors is on. You'll need to restart your web server for this change to take effect. The case keyword is not valid outside a switch block. What you want to be doing is comparing "contact" etc with $_GET['page'] which is the variable the switch statement is using. Additionally you are using a single = which is the assignment operator, so each if statement is assigning the quoted string to $page not testing for it. You need to use == to do that. I would suggest you buy a book on PHP for beginners, or Google for an introductory tutorial because these are pretty basic syntax mistakes. -Stut -- http://stut.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] About mysql_connect()
On 6 Feb 2008, at 14:45, js wrote: Use PDO and try/catch. I think it's much easier. Easier than checking the return value for FALSE? OP: The manual is your friend, it tells you exactly how to detect failures from any function. http://php.net/mysql_connect -Stut -- http://stut.net/ On Feb 6, 2008 7:07 PM, Prabath Kumarasinghe <[EMAIL PROTECTED]> wrote: Hi All When I stop mysql database whole application will break in mysql_connect() function even without giving any error message.Is there are any way to put exception handling with mysql_connect() function. Cheers Prabath Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] String comparision issue with change of databases
Tamkhane, Pravin wrote: Hi All, I am trying to write a simple user verification(not using MD5 hash) . I have users table in database which contains login_id and passwd for registered users. I am using PDO for this purpose. If i use MySQL database, following code for user verification works well without any problem. But if change $dsn to use PostgreSQL database, code fails at if( $passwd === $records[0]['passwd']). After some experiementation, I realized that $passwd holds password string ( assume '1234' for time being) In case of MySQL $records[0]['passwd'] holds password string '1234' as expected and code works. But in case of PostgreSQL, $records[0]['passwd'] holds 1234 rather than '1234' and hence comparison fails. Since I am using same code to register users in both cases, I doubt there would be any issue there. You're using === which does a type *and* value comparison. I'm guessing that the MySQL driver does the conversion to an integer, whereas the PostgreSQL driver doesn't. Change it to == and it'll work just fine. -Stut -- http://stut.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Phpmailer sending duplicate messages...
Stephen Sunderlin wrote: It seems to be ccing each email to everyone and I'd like it to only include one email address with each email. I've tested in on three of my personal emails and I see to get six messages in my inbox. I'm also sending about 4000 emails and would like some pointers to avoid time out errors. Finally for the life of me can't figure out how to execute an insert statement to record a history of each email sent. When I include the insert statement, no emails are send. Following is the code. Any help or direction would be greatly appreciated. Thanks. ** include ("cxnfile"); $cxn = mysqli_connect($host,$user,$password,$database) or die ("Couldn't connect to server"); $query = "select * From db where groupid = groupid"; $result = mysqli_query($cxn,$query) or die("Couldn't execute select query."); while($row = mysqli_fetch_assoc($result)) { extract($row); $mail->IsSMTP(); $mail->Host = "host.com"; $mail->From = "[EMAIL PROTECTED]"; $mail->From = "[EMAIL PROTECTED]"; $mail->FromName = "Company"; $mail->AddAddress("$email", "$Contact"); $mail->IsHTML(True); $mail->Subject = "$Subject"; $mail->Body = "$PR"; $mail->WordWrap = 50; if(!$mail->Send()) { echo 'Message was not sent.'; echo 'Mailer error: ' . $mail->ErrorInfo; } else { echo 'Message has been sent.'; } } You're re-using the same message each time around the loop. Each time you call AddAddress you're, erm, adding another address. You either need to reset the recipients or reset the message each time round the loop (I'm not familiar with Phpmailer so I have no idea how to do this). -Stut -- http://stut.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Trouble with Text Area
Stephen Sunderlin wrote: When I put his line outside of the php tags I get the correct size: That's not how you specify the value of a textarea. It should be between the tags like so... $String And I'm assuming that $String has already had htmlentities run on it. When I put this line inside the php tags the size comes out about 2 rows by 10 columns regardless of the value of rows and cols. Check the source of the page being created. I'm guessing $String contains a single quote and then a sequence of characters that is causing this behaviour. Any ideas on how to format this would be greatly appreciated. The mySQL db column TYPE I am calling is Blob not null. -Stut -- http://stut.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] How can i test it?
joefazee wrote: Thanks for your replay. Sorry, didn't mean to repeat myself. Please if you have done anything on socket programming with php before where did you save it before testing and how did you tested it? I use Ubuntu on my development machine, so that's where I test stuff, but I don't think that's likely to help you. It sounds to me like you want hand-holding through the development process. I can do that but I'd expect to be paid market rates!! There are lots of resources around this area all over the Internet. I suggest you use Google to find some. Stut wrote: joefazee wrote: i`m writing a socket application using the php socket() function, the problem is, how can i run it, i read in some tutorial that i should copy it to the server root. which server root?, Apache?. or did i need to install windows server? but i did not have two system. my development system is what i`m using with Apache to test the web applications. can somebody tell me how to setup this server and run a network application? By "socket application" do you mean a client or a server? If it's a client is it web-based, cli or gui? Actually it doesn't matter, running a client that uses sockets is no different to running a client that doesn't use sockets. I'm assuming you mean a socket server, in which case you probably want to run it on the command line and shove it into the background. This is basic shell stuff and not really to do with PHP. I suggest you find a beginners guide to the OS you're using and do some research on how to run a daemon. -Stut -- http://stut.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] How can i setup a server to run a socket programme
joefazee wrote: i`m writing a socket application using the php socket() function, the problem is, how can i run it, i read in some tutorial that i should copy it to the server root. which server root?, Apache?. or did i need to install windows server? but i did not have two system. my development system is what i`m using with Apache to test the web applications. can somebody tell me how to setup this server and run a network application? By "socket application" do you mean a client or a server? If it's a client is it web-based, cli or gui? Actually it doesn't matter, running a client that uses sockets is no different to running a client that doesn't use sockets. I'm assuming you mean a socket server, in which case you probably want to run it on the command line and shove it into the background. This is basic shell stuff and not really to do with PHP. I suggest you find a beginners guide to the OS you're using and do some research on how to run a daemon. -Stut -- http://stut.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] use of str_split
Asim wrote: Hi when i try to use this function str_split() it shows me as invalid function Are you using PHP 5? That function does not exist in PHP 4. what is solution i want to split certain length of string into an array // NB: UNTESTED $string = 'This is a string'; $certainlength = 5; $pos = 0; $stringlen = strlen($string); $array = array(); while ($pos < $stringlen) { $array[] = substr($string, $pos, $certainlength); $pos += $certainlength; } // $array now contains an element for every $certainlength characters // in $string -Stut -- http://stut.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] connection id mystery
Charles Whitaker wrote: Using persistant connections simply means that you will be given a connection from a pool of open connections rather than creating a new one each time. There is no guarantee you'll get the same connection from request to request. Right. I had assumed that I would get a connection previously initiated by me, and that there would therefore be only one, so I would always get the same connection. So much for assumptions. I would suggest you add another field to the table you are trying to lock. Put an ID in there that you can pass from request to request. Use the locking feature to lock the table, read that value for a record, if it's not set to something write your ID to it then unlock it. If it does already contain an ID you treat it as locked. you just need to make sure you unlock the row when you're done (probably by setting that value to NULL. If you're already using sessions I would strongly recommend using the session ID as the lock ID. If not you can easily generate one but you'll need to pass it manually from request to request. I did as you suggest, and it seems to work fine. I surrounded the lock code with get_lock() and release_lock(), to make it quasi-atomic. Thanks for the suggestion, and thanks to Charles Morris as well for his response. No problem, but please include the list when replying in future. -Stut -- http://stut.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] connection id mystery
Charles Whitaker wrote: Since I'm requesting persistent connections, why don't I get the same connection each time? Or, to ask it another way: I notice that the number of threads slowly increases as I continue to access records -- why would this happen if I'm using persistent connections? I assumed that the first time I did 'new PDO' I'd create a connection, and each time after that I'd get the same connection. At least that's how I read the documentation. Using persistant connections simply means that you will be given a connection from a pool of open connections rather than creating a new one each time. There is no guarantee you'll get the same connection from request to request. Can anyone point me in the right direction? Thanks. I would suggest you add another field to the table you are trying to lock. Put an ID in there that you can pass from request to request. Use the locking feature to lock the table, read that value for a record, if it's not set to something write your ID to it then unlock it. If it does already contain an ID you treat it as locked. you just need to make sure you unlock the row when you're done (probably by setting that value to NULL. If you're already using sessions I would strongly recommend using the session ID as the lock ID. If not you can easily generate one but you'll need to pass it manually from request to request. That may not be as clean as a pure SQL solution, but it will work. You may also want to add a timestamp row to allow for a timeout on the lock. -Stut -- http://stut.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Slooooow query in MySQL.
Stut wrote: Chris wrote: Stut wrote: Chris wrote: Rob Adams wrote: I have a query that I run using mysql that returns about 60,000 plus rows. It's been so large that I've just been testing it with a limit 0, 1 (ten thousand) on the query. That used to take about 10 minutes to run, including processing time in PHP which spits out xml from the query. I decided to chunk the query down into 1,000 row increments, and tried that. The script processed 10,000 rows in 23 seconds! I was amazed! But unfortunately it takes quite a bit longer than 6*23 to process the 60,000 rows that way (1,000 at a time). It takes almost 8 minutes. I can't figure out why it takes so long, or how to make it faster. The data for 60,000 rows is about 120mb, so I would prefer not to use a temporary table. Any other suggestions? This is probably more a db issue than a php issue, but I thought I'd try here first. Sounds like missing indexes or something. Use explain: http://dev.mysql.com/doc/refman/4.1/en/explain.html If that were the case I wouldn't expect limiting the number of rows returned to make a difference since the actual query is the same. Actually it can. I don't think mysql does this but postgresql does take the limit/offset clauses into account when generating a plan. http://www.postgresql.org/docs/current/static/sql-select.html#SQL-LIMIT Not really relevant to the problem though :P How many queries do you run with an order? But you're right, if there is no order by clause adding a limit probably will make a difference, but there must be an order by when you use limit to ensure the SQL engine doesn't give you the same rows in response to more than one of the queries. Oops, that was meant to say "How many queries do you run *without* an order?" -Stut -- http://stut.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Slooooow query in MySQL.
Chris wrote: Stut wrote: Chris wrote: Rob Adams wrote: I have a query that I run using mysql that returns about 60,000 plus rows. It's been so large that I've just been testing it with a limit 0, 1 (ten thousand) on the query. That used to take about 10 minutes to run, including processing time in PHP which spits out xml from the query. I decided to chunk the query down into 1,000 row increments, and tried that. The script processed 10,000 rows in 23 seconds! I was amazed! But unfortunately it takes quite a bit longer than 6*23 to process the 60,000 rows that way (1,000 at a time). It takes almost 8 minutes. I can't figure out why it takes so long, or how to make it faster. The data for 60,000 rows is about 120mb, so I would prefer not to use a temporary table. Any other suggestions? This is probably more a db issue than a php issue, but I thought I'd try here first. Sounds like missing indexes or something. Use explain: http://dev.mysql.com/doc/refman/4.1/en/explain.html If that were the case I wouldn't expect limiting the number of rows returned to make a difference since the actual query is the same. Actually it can. I don't think mysql does this but postgresql does take the limit/offset clauses into account when generating a plan. http://www.postgresql.org/docs/current/static/sql-select.html#SQL-LIMIT Not really relevant to the problem though :P How many queries do you run with an order? But you're right, if there is no order by clause adding a limit probably will make a difference, but there must be an order by when you use limit to ensure the SQL engine doesn't give you the same rows in response to more than one of the queries. -Stut -- http://stut.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Slooooow query in MySQL.
Chris wrote: Rob Adams wrote: I have a query that I run using mysql that returns about 60,000 plus rows. It's been so large that I've just been testing it with a limit 0, 1 (ten thousand) on the query. That used to take about 10 minutes to run, including processing time in PHP which spits out xml from the query. I decided to chunk the query down into 1,000 row increments, and tried that. The script processed 10,000 rows in 23 seconds! I was amazed! But unfortunately it takes quite a bit longer than 6*23 to process the 60,000 rows that way (1,000 at a time). It takes almost 8 minutes. I can't figure out why it takes so long, or how to make it faster. The data for 60,000 rows is about 120mb, so I would prefer not to use a temporary table. Any other suggestions? This is probably more a db issue than a php issue, but I thought I'd try here first. Sounds like missing indexes or something. Use explain: http://dev.mysql.com/doc/refman/4.1/en/explain.html If that were the case I wouldn't expect limiting the number of rows returned to make a difference since the actual query is the same. Chances are it's purely a data transfer delay. Do a test with the same query but only grab one of the fields - something relative small like a integer field - and see if that's significantly quicker. I'm betting it will be. If that is the problem you need to be looking at making sure you're only getting the fields you need. You may also want to look into changing the cursor type you're using although I'm not sure if that's possible with MySQL nevermind how to do it. -Stut -- http://stut.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] sql statement - complex order by
Bryan wrote: SELECT * FROM productgroup WHERE groupid = $productid AND label = 'Cats' ORDER BY title SELECT * FROM productgroup WHERE groupid = $productid AND label != 'Cats' ORDER BY label,title I'd like to find a way to combine these 2 statements. I want to list out all the products, ordered by title but listing out all the Cats products first. Any way to do that without having separate statements? Thanks... select * from productgroup where groupid = $productid order by (label = 'Cats') desc, title And I do hope you're properly validating and escaping $productid. -Stut -- http://stut.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Problem with passing variable to mssql
Please include the list when replying. William Curry wrote: Thanx for the quick reply, I left out the concats in my sample here is the exact statement: $qry1 = "SELECT *,CONVERT(Char(24),CALL_ENTRY_DATE,101) as MYDATE from PcarsCallComplete where Location_address = " .$Location2. " order by CALL_NO"; and as echoed with the $Location2 value inserted: SELECT *,CONVERT(Char(24),CALL_ENTRY_DATE,101) as MYDATE from PcarsCallComplete where Location_address = '1121 800N,TOT,TOT' order by CALL_NO $Location2 is passed in the URL when the user clicks a hyperlink for a certain address record from a list of possible matches. $qry1 returns 0 records in the page, but 10 records in SQL QA. I run the URL var through a stripslashes and add the '%' before inserting it into the string. I've, never used the str_replace function, and generally get the same results with similar statements. baffled 1) The str_replace is necessary to protect against SQL injection attacks. If you don't know what that means, Google it. 2) Are you checking return values for errors? If not, try that. Aside from that I have no idea. If there are no errors and you are still getting different results from the script and from QA with the same SQL statement then by definition something *is* different. -Stut -- http://stut.net/ >>> Stut <[EMAIL PROTECTED]> 6/28/2007 8:30 AM >>> William Curry wrote: > I have issues I cant understand passing a sql statement to mssql, most > of which work fine, however in some cases, a statement like > "SELECT * FROM tblX where value like 'variable%' " will return 0 > records when I know they are there. No errors, just 0 records. > > When I echo the sql string to the page, cut and paste it into SQL query > analyzer, the exact same statement returns the expected records. > > Anyome point me to the answer?? It's over there -> Sorry, couldn't resist. Anyhoo, are you expecting variable to be replaced with the contents of $variable? If so that's never going to work. Try this instead... "SELECT * FROM tblX where value like '".str_replace("'", "''", $variable)."%' " -Stut -- http://stut.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Problem with passing variable to mssql
William Curry wrote: I have issues I cant understand passing a sql statement to mssql, most of which work fine, however in some cases, a statement like "SELECT * FROM tblX where value like 'variable%' " will return 0 records when I know they are there. No errors, just 0 records. When I echo the sql string to the page, cut and paste it into SQL query analyzer, the exact same statement returns the expected records. Anyome point me to the answer?? It's over there -> Sorry, couldn't resist. Anyhoo, are you expecting variable to be replaced with the contents of $variable? If so that's never going to work. Try this instead... "SELECT * FROM tblX where value like '".str_replace("'", "''", $variable)."%' " -Stut -- http://stut.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Creating all key combinations passwords
Lasitha Alawatta wrote: I’m going to create all key combinations; simple-letter passwords and store those in to MySql DB. Using = a-z (simple letters) Password length = 6 Number of possibilities = 26 x 26 x 26 x 26 x 26 x 26 = 308,915,776 This is my code: $val){ // Inserting to DB } function createPwd() { $lower = "abcdefghijklmnopqrstuvwxyz"; $seed_length += 26; $seed .= $lower; for($x=1;$x<=6;$x++){ $ strPwd.= $seed{rand(0,$seed_length-1)}; } return($strPwd); } ?> What is the easiest way to get my output? 1. Because above code will stuck the PC (for($i=0;$i< 5;$i++){). 2. I use 5 instead of 308915776, because createPwd() function will duplicating the password. Suggesting, comments, code samples are highly appreciate. The only reason I can see to do such a thing is to build a brute-force password cracker, and seeing as you're not smart enough to realise that you can do so incrementally instead of randomly, I don't see much reason to help you. Enjoy. -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Extracting data from Arrays in ISAM table
[EMAIL PROTECTED] wrote: I have a table with between 100k and 200k rows. One field, `names`, is populated, in each row, with an imploded array of up to 4 names. I require to create a list of names, without repeats, of all the names in `names` field to use in an html form. Any advise would be appreciated. I have no ideas on how to start. The best option would be to normalise the data by breaking the names out to a separate table. However, if that's not feasible my suggestion is similar to that itoctopus sent, but a bit more memory efficient. Inside the loop getting the records, do the following... foreach (explode(',', $single_result['name']) as $name) $arr_all_names[$name] = 1; Then after the loop, to get an array of the names... $arr_all_names = array_keys($arr_all_names); -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PHP-WIN] automatic-click flash?
bedul wrote: nope.. that's can be dangerous since some activeX today are a food for a worm.. be safe on NET It has absolutely nothing to do with security. It's all about patents... http://channel9.msdn.com/ShowPost.aspx?PageIndex=2&PostID=169255 Fight the FUD. -Stut - Original Message - From: "Gustav Wiberg" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, May 04, 2007 4:06 PM Subject: [PHP-WIN] automatic-click flash? Hi there! I searched the Internet about "Click to activate this control"... Why it is viewd in IE... "Q. Why do I see "Click to activate this control."? Microsoft® changed the way ActiveX controls behave so Dynamic HTML (DHTML) events related to user interaction, such as onblur and onclick, are automatically blocked. To activate an interactive control, either click it or use the TAB key to set focus on it and then press the SPACEBAR or the ENTER key. Interactive controls loaded from external script files immediately respond to user interaction and do not need to be activated. Basically, you now need to click the control to "approve" it before the Flash and navigation buttons will work." and after this reading,... I've been thinking. Is it possible to make an automatic click in Javascript to an embedded flash-object? /Gustav -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] querying results from postgresql
Kirk Wythers wrote: I am having trouble with a db query that was working not too long ago. I did upgrade from php4 to php5 and wonder if there are some differences that could explain my issue. Below is the code where I suspect things are breaking down. // build sql query from form values $select_query = "select * from grid_cell where township = $township and range = $range and rdir_shortname = '$rdir_shortname' and section = $section and forty_name = '$forty_name'"; //echo $select_query; // use for debugging sql query // retrieve the query info from postgresql //this returns a resource, so put the resource into a variable $result = pg_query($select_query); //echo $result; // use for debugging sql query // process results. First argument pg_result is the returned result set ($grid_cell), // second argument is the row offset, and the third argument is the column offset. $forty_grid = pg_result($result, 0, 0); //echo $forty_grid; // use for debugging sql query If I uncomment echo $select_query, the scrip prints the proper query like this: select * from grid_cell where township = 67 and range = 1 and rdir_shortname = 'W' and section = 1 and forty_name = 'NWNW' However, if I uncomment echo $result, the script prints: Resource id #2 and also the error: Unable to jump to row 0 on PostgreSQL result index 2 I think that the variable $result is getting the result from pg_query and subsequently $forty_grid is not receiving what it expects either. Does anyone see what I'm not doing right here? Just because the query returned a resource ID does not mean it contains any results. An empty result set is what you're getting, and you need to check for that before trying to use the results. -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PHP] slow performance
Henning Eiben wrote: I wrote a small sample-application once using PHP (with propel and smarty) and once using Java (JBoss, EJB3, JSP & Servlets). Both apps are being served from a windows server (2x Xeon 1,3GHz, 2 GB RAM), but the performance of the PHP version is much slower than the Java version. I already installed an php-accelerator (eAccelator) which increased the overall performance, but still the performance is quite poor. Are there any "tweaks" to tune PHP performance? Don't use Windows. If you *must* use windows, use FastCGI. -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] database password
Roberto Mansfield wrote: Bastien Koert wrote: store your password/access credentials outside the web root and use php to read the data in. This is good for web attacks, but I'm thinking of an account break in where someone is accessing files directly on the server. I suggest you think about this for a second before you start designing with a really pointless obfuscation system. Say someone is accessing files directly on the server... if they can get at the file that contains the password then they can also get at the PHP code that will de-obfuscate it. Spend your time locking the doors rather than putting 5-minute obstacles in the path. -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Accessing Oracle
Robert Hicks wrote: I have been away from PHP for a while and was wondering what is the preferred method of accessing Oracle? With modesty and respect, walk slowly towards it bowing your head at all times and being careful not to relieve yourself all over the floor. Alternatively Zend have an offering in this area: http://www.zend.com/products/zend_core/zend_core_for_oracle -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] help with mysql connect error
Tim McGeary wrote: Thank you for the link. I think that's probably the best way to go in this case, since it's only on a dev/test server. When I build the production server, I should probably upgrade to PHP5 anyhow. I assume that should not have this problem, right? It might. PHP5 can be built against libs for MySQL 4 or 5, so just make sure that you match the version used for PHP to the server version and you'll be fine. Thanks for your help, Stut!!! No probs. -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] help with mysql connect error
Tim McGeary wrote: But I do have a MySQL 5 client: [EMAIL PROTECTED] html]# rpm -qa MySQL* MySQL-shared-compat-5.0.27-0.rhel3 MySQL-client-standard-5.0.27-0.rhel3 MySQL-python-0.9.1-6 MySQL-server-standard-5.0.27-0.rhel3 MySQL-devel-standard-5.0.27-0.rhel3 or are you saying that the PHP libs have a MySQL 4 client in there? If that is the case, how should I rebuild PHP? Yes, and it depends on what OS, where it originally came from, etc. The alternative is to change the password of the MySQL user you're using - the link in my last post explains how to do this. -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] help with mysql connect error
Tim McGeary wrote: Oh, duh! Ok. I wrote this: mysql_connect($hostname, $username, $password) or die(mysql_error()); mysql_select_db($dbname) or die(mysql_error()); $result = mysql_query("SELECT * FROM Requestor_type") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { echo 'value="'.$row['description'].'">'.$row['description']." "; } ?> And got this as output: Warning: mysql_connect(): Client does not support authentication protocol requested by server; consider upgrading MySQL client in /var/www/html/mysql_test.php on line 7 Client does not support authentication protocol requested by server; consider upgrading MySQL client I'm not sure I understand it. Maybe my CLI PHP script is not correct? I'm returning to PHP after 5 years of not writing in it. This basically means that you're trying to access a MySQL 5 server with MySQL 4 client. You have two choices... 1) Rebuild PHP with the MySQL 5 client libs 2) Use the old password mechanism in MySQL See here for more info... http://dev.mysql.com/doc/refman/5.0/en/old-client.html -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] help with mysql connect error
Tim McGeary wrote: Please include the list in replies. Sorry, I meant to, but hit the wrong button. Tim McGeary wrote: Stut wrote: Tim McGeary wrote: I am new to this list today, so if I should be sending this to another specific PHP list, please let me know. I am getting the following error via the PHP web page I am building: Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13) in /var/www/html/software/index.php on line 18 Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13) Given that you can connect through the socket on the CLI, I'm gonna guess that it's a permissions issue. Does the user that Apache (or whatever web server you're using) runs as have access to mysql.sock? Currently mysql.sock is owned by mysql.mysql with S777 permissions. Should the ownership be different? Despite the ownership, wouldn't S777 allow any user to access it? Indeed it should. Have you tried writing a CLI script and seeing if that works? I confess I don't know what at CLI script is. What would I write? To be run on the command line. Same as a web-based PHP script, but no need to output any HTML. Just write a script that tries to connect to the database and spits out success or failure. Then run php script.php on the command line (CLI === Command Line Interface) and see what happens. -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] help with mysql connect error
Tim McGeary wrote: I am new to this list today, so if I should be sending this to another specific PHP list, please let me know. I am getting the following error via the PHP web page I am building: Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13) in /var/www/html/software/index.php on line 18 Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13) Given that you can connect through the socket on the CLI, I'm gonna guess that it's a permissions issue. Does the user that Apache (or whatever web server you're using) runs as have access to mysql.sock? -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Am I missing something?
Alexander wrote: They should have data. here's the form code: function write_form() { echo ""; echo "Enter url of large picture: name='picture' />"; echo "Enter url of thumbnail: name='thumbnail' />"; echo ""; echo ""; } I've done everything excatly how my PHP book says to /* i now officially hate all code examples in books, they never work */ The book is probably expecting you to have register_globals enabled. DO NOT ENABLE IT! Instead, read the following and adapt what the book is giving you to work without it. Reasons for not enabling register_globals are also given on this page... http://php.net/register_globals -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] textarea value assignment
Brad Bonkoski wrote: [EMAIL PROTECTED] wrote: Hello how I could assign a textarea with a variable value? Although I tried to achieve an allocation like a normal it does not work so I have no success with textarea. The code looks like following fragment. $problem_val = mysqlclean($_SESSION, "problem_eb", 500, $connection); cols="1" rows="1" name="problem_eb" value="$problem_val?>"> Best regards, Joerg Kuehne There is no value attribute of textarea...to put text in there, you place it between the tags. i.e. cols="1" rows="1" name="problem_eb" >?> Also worth mentioning that you may run into problems if you don't use htmlentities on $problem_val, like so... cols="1" rows="1" name="problem_eb" >htmlentities($problem_val); ?> -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Php 5 and Mysql on Windows
[EMAIL PROTECTED] wrote: > I did that already. Step (8) of setting up php. Oops, sorry, missed that. > Do I need to move any files around or add anything else to the path? Long time since I've actually set up a Windows server but I seem to remember there are some DLLs in the distribution that need to be on the path for MySQL to function. You may also want to check that where you've put php.ini is where PHP is expecting it to be. A phpinfo() page will tell you that. -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Php 5 and Mysql on Windows
[EMAIL PROTECTED] wrote: > I setup Mysql as follows: > > 1. Download the 5.x installer > 2. Run the installer > 3. Run the configuration tool ater the installer > > When I run the following script, the error "Fatal error: Call to > undefined function mysql_connect() in Test.php on line 3" is returned. > > $conn = mysql_connect('localhost', 'root', 'password') Installing MySQL is not enough - you need to enable the mysql extension in your php.ini. -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] user directory from a form
Neil Jackson wrote: > I would like to extract the path from the users machine. Assuming I'm understanding you correctly, you can't do that. The location of a file uploaded via HTTP is not available - you cannot get it since it doesn't get sent with the file, only the filename itself is sent. -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] ViewSonic VX724
On Tue, 19 Sep 2006 03:30:24 +0100, Ron Piggott (PHP) <[EMAIL PROTECTED]> wrote: I realized this is off topic; I am not sure where I would look online. Off topic? It's not even in the same continent!! Try a Linux mailing list - that's what they're there for!! -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Direct Access to an Array Item?
Peter Beckman wrote: > if (($row = mysql_fetch_row($result))[3] == 'foo') { > $user = $row; > } > > or > > $bar = explode('#', $str)[2]; PHP does not currently support this type of syntax in any form. You must assign the return value of a function to a variable if you want to access it as an array. -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: making an array from data in textfile
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Dave W wrote: > I figured it out before, but I didn't hit reply all. I used files() and > newlines to create it. Would using explode be a more reliable way? I assume you mean the file() function, not files(). The only problem with doing it that way is that each element of the array will have a newline on the end. Maybe this is what you want, but I doubt it. - -Stut -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFEw3tl2WdB7L+YMm4RAg3xAJ0SPUPR+00PXVIfJhDfg4WrBWVi/ACgsFOu 9usmbLbhNrXUCef+uCyzAY4= =RXbe -END PGP SIGNATURE- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: making an array from data in textfile
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Dave W wrote: > Currently, here is my code: > >$file = 'ip.txt'; >$fh = fopen($file, 'r'); > $theData = fread($fh, filesize($file)); > fclose($fh); > $ips = array($theData); > ... > > Since it's a numeric array, I shouldn't need quotes around the ip octets. > OK, well I did a debug and this is whats coming out: > > Array > ( >[0] => 127.0.0.1,127.0.0.1,127.0.0.1 > ) PHP doesn't know what separates each element of the array, so you need to tell it... $ips = explode(',', $theData); - -Stut -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFEw2cA2WdB7L+YMm4RAlmaAJ4+cRJulnESdiZMZ5XtGWZ6Su5TzQCguSSY fAqVdvlg4xX+RgrMepUJbc0= =jI3V -END PGP SIGNATURE- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Using MAX with COUNT?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Skip Evans wrote: > I have a table like this: > > boroughIDArea > = > 1Chelsea > 1East Village > 1West Village > 1So Ho > 2Prospect Park > 2Brooklyn Heights > 3Prospect Heights > > What I want to know is which boroughID has the most area's assocated > with it, and how many. > > So I tried this: > > SELECT max(count(*)) FROM `bsp_area` GROUP BY boroughID > > ...and got an "Invalid use of group function" error. > > Anyone think of another way to do this in a single SQL statement, or > some other simple method? select boroughID, count(*) as thecount from bsp_area group by boroughID order by thecount desc limit 1 - -Stut -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFEw2YG2WdB7L+YMm4RAqkyAJwIHMzDeDNBanlDpjARF4ElRasBYwCgmpIl HGbI5JrIlTPf0c5r6Tg6+o8= =jRmZ -END PGP SIGNATURE- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Submitting form from
Dave W wrote: The problem with GET is that a user that looks at the source code of the html can easily just input what they want for the argument. Can you say SQL injection? Can you say input validation? Regardless of where user input comes from, whether it's in the URL, in POST vars or in cookies they should all be subjected to the same validation. Trust nothing. -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] detecting negative numbers
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Dave W wrote: > Currently I have this: > > if($quant > $amount) {echo "You don't have that many!"; } > > $quant is the user inputted amount and $amount is the amount that they > actually have. Is there any way of checking if the result is negative > rather > than doing what I have above? Not sure which way around you want it, but I think this is what you are after... if (($quant - $amount) < 0) { echo "You don't have that many!"; } I don't mean any offense, but the possibility that someone who couldn't figure that out is writing PHP code scares me. You might want to think about Googling for an absolute beginners guide to programming before continuing. - -Stut -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFEusYz2WdB7L+YMm4RAqGPAJ0QqkgfApO6h0GR9lXa47WyAhSsugCfaymW Ba+bqZRbrcv6CuZ6g7FJJjw= =ktnc -END PGP SIGNATURE- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] need help on setting up tables for db (NFL Football)
Karl James wrote: Team, Heh! I was wondering if anybody can help me or guide me On what tables to make. I want to do all the data entry I just do not know what to do. It's for a fantasy football League. Here is my project! Let me know if anyone can help me directly, through Email, AIM, or MSN. http://www.theufl.com/ufl_project.htm Your help would be greatly appreciated. I would be using phpmyadim for this. Sure. How much do you pay? -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Generating forms and form elements
Micah Stevens wrote: Stut wrote: Bastien Koert wrote: Not commenting on the appropriateness or security of the eval function. Merely offering a possible path. It is up to the OP to decide if that solution is the correct one. I would accept that if you'd mentioned, or at least hinted at the issues that need to be addressed when using eval. You didn't so I thought it needed to be pointed out. I think we, as a community, have a responsibility to point out the potential security and stability pitfalls of the possible solutions we provide. But that's just me. Last time I handed someone a rope, I didn't tell them to not hang themselves. :) Then you assumed they knew what a rope was and that it's generally a bad idea to use it to suspend themselves in the air by their neck. Likewise you assumed the OP knew that eval was dangerous. -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Generating forms and form elements
Bastien Koert wrote: Not commenting on the appropriateness or security of the eval function. Merely offering a possible path. It is up to the OP to decide if that solution is the correct one. I would accept that if you'd mentioned, or at least hinted at the issues that need to be addressed when using eval. You didn't so I thought it needed to be pointed out. I think we, as a community, have a responsibility to point out the potential security and stability pitfalls of the possible solutions we provide. But that's just me. -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Generating forms and form elements
Bastien Koert wrote: whoops eval ($code); Someone relatively famous[1] once said "If eval is the answer then you're asking the wrong question." The eval function is dangerous. Extremely dangerous. From every point of view there is. If there's another way to do what you're doing (and there almost always is), do that instead. In this case a description of the form would be a better thing to store in the DB rather than the code to generate it. -Stut [1] Rasmus, a while back, can't recall when, but it stuck in my mind Bastien From: "Bastien Koert" <[EMAIL PROTECTED]> To: [EMAIL PROTECTED], php-db@lists.php.net Subject: RE: [PHP-DB] Generating forms and form elements Date: Tue, 20 Jun 2006 16:44:22 -0400 eval$code); bastien From: Mark Fellowes <[EMAIL PROTECTED]> Reply-To: Mark Fellowes <[EMAIL PROTECTED]> To: php-db@lists.php.net Subject: [PHP-DB] Generating forms and form elements Date: Tue, 20 Jun 2006 15:37:10 GMT Hi, Hitting up the list for maybe a decent link(s) or pointers. I need to figure out how to generate forms and form elements from php code inside database tables. Hope this makes sense. It's not a complete picture of what I need to do but the first step I'll need to take. TIA Mark -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] How can I get in PHP the number of files in a directory
suad wrote: This is for reading a file: How can I get in PHP the number of files in the directory (rasmus) and the files names in a loop? http://php.net/glob or http://php.net/readdir -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Processing a web form / loop etc.
Ron Piggott (PHP) wrote: I have a web form that accepts up to 3 suggested categories. In the form they are part of I have named these variables $suggested_category_1 $suggested_category_2 $suggested_category_3 I have come up with this simple code to store the suggestion in a table: if ( $suggested_category_1 <> "" ) { #the user could leave the suggestion blank because what is already provided is sufficient mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "INSERT INTO table_name VALUES ( '$variable' , '$reference_number', '$suggested_category_1')"; mysql_query($query); mysql_close(); } Is there any way to create a loop to check all three instead of me repeating this code twice more changing $suggested_category_1 to _2 and _3 ? for ($num = 1; $num <= 3; $num++) { $varname = 'suggested_category_'.$num; $val = $$varname; // Stick your code here replacing references to the $suggested_category_1 var with $val } Incidentally, I do hope that code was simplified for brevity. There should be extensive use of mysql_real_escape_string in there. -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql searching with fulltext indexing
Bevan Christians wrote: Is there any to query a mysql table to get it to return the field names that it currently has marked as Fulltext Indexes? |SHOW COLUMNS FROM sometable -Stut | -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Date Conversion in RFC822 format
Manoj Singh wrote: I am developing a site in php implementing the concept of rss feeds. For that i want to convert the standard date into RFC822 format. If any one have idea about it, please help me. Go to http://php.net/date and search the page for RFC822. If you need further help read the rest of that page. -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: Sending filing attachments using PHP
#x27;m not understanding what Perl gives you that makes it easier to manage than PHP. Please explain it to me so I can As I stated I'm not doing a Perl vs PHP rant I'm doing an "anything but PHP" rant :) And that justifies it how? All I'm getting is an "I hate PHP and nothing you say will sway me from that opinion". Is that accurate? Because if it is I have better things to do with my time. learn something from this exchange. You clearly feel quite passionate about it, so please share. Actually since most everyone has expressed an interest in stopping this thread, I think I will. Teh facts are there do as you wish :) Agreed, we should probably both give up. The "facts" are still in dispute, but each to his or her own. A solution is a solution, PHP is just one tiny option, I was offering an easier to work with alternative. Without adequately explaining why it's easier. And more to the point you Sure I did, no one wants to hear it though :) are still on a PHP list, and as I've stated before, the question was clearly asking for a PHP solution. True enough, but if you want to be strict then why not send them to a none DB list? Fair point, but it was still a *PHP* list not a generic DB list. Feel free to ignore the rest of this post, which I hope you'll take in the spirit it is meant, but please answer me this. What has PHP done to you? Why are you so anti-PHP? And specifically why are you on a PHP list suggesting people use a different technology? PHP has all the problems I've been specifying, that costs time and money, and I'm sick of it :) Yeah, I got that already :). What I haven't grok'd is what specifically makes Perl easier and therefore cheaper to manage. As I stated I'm not doing a Perl vs PHP rant I'm doing an "anything but PHP" rant :) Which in fact PHP4/5 + --with-mysql[i] *is* a huge example of what makes PHP the last choice for any project. Again, this is a statement that makes no sense to me. You've made a statement saying you hate something without explaining why. Do you see Because its got *s* many problems, security, development, admin wise - details throughout this thread :) Yeah, about those security problems. You mentioned phpBB as an example. You must be aware that nearly every problem related to security that has ever been found in relation to PHP has been down to poor implementation on the part of the script developer and not PHP itself. All other languages and tools are open to the same type of problems, but popularity and user-base of PHP cause bad press. why it's very hard to learn from you when you don't justify your hatred? What's the problem with the MySQL modules available for PHP? I Those configure flags have so many combinations to get unpredicatabel behavior this is the pseudo thought process while doing it: --with-mysql (make sense so far) but lest add the super duper mysqli stuff: Oi crap what arg do you give it depending on what --with-mysql 's value is? --with-mysql=/usr --with-mysqli=path_to_mysql_config --with-mysql --with-mysqli=/usr Please enlighten me as to how other tools find the MySQL libs. As far as I'm aware they do it in exactly the same way, namely an automatic search which will occasionally fail which requires the ability to specify it in the configure command. Is all of that mess the same on PHP 4 and 5 ? Pretty much. What if you have mysql 4.0, 4.1, or 5 ? Doesn't matter. and once you get your head wrapped around it are all the badly named funitons gogin to behave the same? Badly named functions? There are some dodgy ones still in there for BC reasons, but this has improved a lot since PHP 4 & 5 arrived. personally have never had a problem with them, but if there is a better way I'm all ears. yep, use Perl's DBI modules or some other API (C, Python, Ruby, *anything*) to MySQL that is consistently easier to setup and use Again, we'll have to agree to disagree. For me PHP makes setting up and using MySQL a breeze. Anyway, I think we should end this here since we're clearly not making a dent in each others opinion of PHP. Feel free to reply to me offlist if you really want to continue, but I don't think there would be much point. -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: Sending filing attachments using PHP
JupiterHost.Net wrote: Stut wrote: What planet are you on? Seriously? Because PEAR does not need to be compiled into PHP. Zend Optimizer is no different to the optimizers I was referring to --with-pear, sorry "compiled" was not the right word * I'm not familiar with the switch you are referring to. If you look into in PHP source: ./configure --help I've had a look and it would appear that all that switch does is install PEAR for you during the build process. That doesn't change the fact that it's still just a collection of PHP classes and does not require rebuilding of PHP to benefit from it. PEAR a bit closer you will find that it is simply a package of classes. It does not need any changes to your PHP binary for it to work correctly. available for other scripting languages. Version mismatches are a fact I was referring to how Zend Opt is "required" for some stuff mainly because its necessary to offset the bloat. * I'm not sure what gives you the impression that Zend Optimizer is "required" for anything. ZO is a system for pre-compiling PHP code to If a PHP system has been "Optimized" then it requires ZO. Most admins need to have ZO since at least one of theri users will want to use sucha PHP system. I think you're grossly over-estimating the number of PHP systems that use Zend Optimizer, not so much as an actual number but more as a percentage of all software written in PHP. You're also making it sound like adding ZO to a PHP installation is a mammoth task... it's not. It's just as simple as building PHP itself. bytecodes such that the PHP source files do not need to be interpreted each time they are run. While it is true that some commercial software written in PHP is encoded and requires ZO, but this is a choice of that particular developer and is not attributable to PHP as a language or as a technology. But it does epitomize PHP's overall paradigm of "you want to add funtionality for XYZ? ok lets drunkenly add support for it without tryign to be consistent or plan for anything in the future. How so? Take any other interpreted language, and you don't usually get pre-compilation for free. Correct me if I'm wrong but this goes for Perl as much as it does for PHP. You have to 'jump through hoops' to get it. I'll freely agree that there are a number of things that exist in PHP that are not ideal, and could appear to have been implemented by a drunken developer trying to meet a deadline. However, having been a lurker on the PHP-Dev list for a long time now I can say with absolute confidence that most of the decisions made regarding what gets into PHP and what doesn't are well-justified. PHP is not a small system, and it takes a huge effort to manage the ongoing development. Mistakes have been made and undoubtedly will continue to be made, but I'm sure the same can be said for any similarly-sized open-source project. of life with all tools, deal with it. And last but not least, you do not And PHP tends to have a greater majority of them, have you ever managed PHP on multiple servers? If you have you kwo exactly what I'm referring to. I maintain 13 servers in total, each of them have PHP installed, and try 13000 :) 13 is child's play and can be easily managed. IMHO, 13,000 servers should be just as easy to manage as 13 - it all depends on the infrastructure (in terms of tools) you have in place to assist you in the task. Out of curiosity, why do you find it easier to manage Perl on 13,000 servers? What specific advantages does it have over PHP when it comes to this? have to be root to do anything with PHP, or indeed Apache except to I was referring to building PHP/Apache in general * You do not need to be root to build PHP or Apache, or in fact anything else, so I'm not sure where you're getting that requirement from. So any user on your systems can recompile apache or PHP at will? Yeah, I don't stop them - more hassle than it's worth. But they'll be compiling it in their own directories, they'll be running their own copies. They can't interfere with the systems installation of either because file permissions don't let them, but that doesn't stop them working on their own copies of it. Any user with shell access with the required build tools available to them will be able to do the same. If you think otherwise I encourage you to try it. listen on a port lower than 1024, which is true for all tools since it's a platform limitation. * I'm speaking in generalitites of working with PHP not specifics components of the technology. In that case I would point out that your personal experiences with PHP are not necessarily a reflection on PHP. I hope you don't take offense My personal experiences
Re: [PHP-DB] Re: Sending filing attachments using PHP
Let me start by apologising if my posts came across as personal. Check the archives for my posts, primarily on php-general and you will see that I have a very sarcastic personality. No offence was meant or is meant by what follows. JupiterHost.Net wrote: What planet are you on? Seriously? Because PEAR does not need to be compiled into PHP. Zend Optimizer is no different to the optimizers I was referring to --with-pear, sorry "compiled" was not the right word * I'm not familiar with the switch you are referring to. If you look into PEAR a bit closer you will find that it is simply a package of classes. It does not need any changes to your PHP binary for it to work correctly. available for other scripting languages. Version mismatches are a fact I was referring to how Zend Opt is "required" for some stuff mainly because its necessary to offset the bloat. * I'm not sure what gives you the impression that Zend Optimizer is "required" for anything. ZO is a system for pre-compiling PHP code to bytecodes such that the PHP source files do not need to be interpreted each time they are run. While it is true that some commercial software written in PHP is encoded and requires ZO, but this is a choice of that particular developer and is not attributable to PHP as a language or as a technology. of life with all tools, deal with it. And last but not least, you do not And PHP tends to have a greater majority of them, have you ever managed PHP on multiple servers? If you have you kwo exactly what I'm referring to. I maintain 13 servers in total, each of them have PHP installed, and I've never had a problem with version issues. And I have to say that in my experience other tools have more problems with this. Perl used to be a nightmare for us until we rewrote the scripts we had in PHP. I'm not blaming PHP for this, I'm just trying to point out that problems related to version mismatches are usually related to the administrators understanding of that particular package. For me that means Perl caused me more issues than PHP because I know PHP better. have to be root to do anything with PHP, or indeed Apache except to I was referring to building PHP/Apache in general * You do not need to be root to build PHP or Apache, or in fact anything else, so I'm not sure where you're getting that requirement from. listen on a port lower than 1024, which is true for all tools since it's a platform limitation. * I'm speaking in generalitites of working with PHP not specifics components of the technology. In that case I would point out that your personal experiences with PHP are not necessarily a reflection on PHP. I hope you don't take offense at that but I know a huge number of developers and sysadmins who are more than happy with working with PHP, and nearly all of them have been through the process of trying the alternatives before landing on PHP as the right solution for them. And that module is not a MIME tool in itself, it uses perl's MIME tools and SMTP tools but it abstracts all of that for you so all you have to do is make a hash that represents your mail. No knowlege of SMTP or MIME necessary. And you can install it as a regular user and use it yourself if need be, what could be easier :) Yeah, you're definitely smoking somethin'. The PEAR package Mail_Mime is another example of a pure-php class. It certainly does not use anything perl related at all. I'd really like to know what makes you think it does. I never said PEAR or any specific package used Perl, I'd simply offered a better solution that happend to be done in Perl. Quoting your original post... "it uses perl's MIME tools and SMTP tools". How is that not saying "PEAR or any specific package used Perl"? Your solution was not "better" given the context of the question. Specifically that the question was asking about doing something in PHP and was asked on the PHP list meaning it's not a great leap to assume the guy need a solution in PHP. Oh, and there's nothing stopping you installing any of the PEAR classes as a regular user and using it yourself. What could be easier? Not having to read your ignorant emails. I was outlining some of PHP faults, not getting personal which truly *is* ignorant. I hope you understand that I wasn't getting personal, but you must accept that your answers so far have suggested that you don't actually know much about what you are talking about. Good day to all, sorry if I was to ambiguouse or I've offended. Feel free to ignore the rest of this post, which I hope you'll take in the spirit it is meant, but please answer me this. What has PHP done to you? Why are you so anti-PHP? And specifically why are you on a PHP list suggesting people use a different technology? -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: Sending filing attachments using PHP
JupiterHost.Net wrote: Alister Bulman wrote: On 12/05/06, JupiterHost.Net <[EMAIL PROTECTED]> wrote: You're piping a hand crafted mime message to sendmial via mail()? You are a glutton for pain :) (and oh yeah theres about a zillion MIME issues you've overlooked that will come back and bite you later, gauranteed) use a tool thats made for it: http://search.cpan.org/perldoc?Mail::Sender::Easy I agree - don't get bitten on the ass, but OTOH, there's already a PHP Mime encoder - no need to point him to a Perl library http://pear.php.net/package/Mail_Mime Yes there's a huge need, PHP is way to problematic and many folks don't even realize thats its one of a hundred possible tools. Most of which are better suited for most things. Plus, what if you don't have Pear compiled into PHP? Now theres more hoops, oops need zend optimizer, more hoops, oops that version doesn;t work on that verison, more hoops. Oh yeah and you have to be root to do all this, nice. What planet are you on? Seriously? Because PEAR does not need to be compiled into PHP. Zend Optimizer is no different to the optimizers available for other scripting languages. Version mismatches are a fact of life with all tools, deal with it. And last but not least, you do not have to be root to do anything with PHP, or indeed Apache except to listen on a port lower than 1024, which is true for all tools since it's a platform limitation. And that module is not a MIME tool in itself, it uses perl's MIME tools and SMTP tools but it abstracts all of that for you so all you have to do is make a hash that represents your mail. No knowlege of SMTP or MIME necessary. And you can install it as a regular user and use it yourself if need be, what could be easier :) Yeah, you're definitely smoking somethin'. The PEAR package Mail_Mime is another example of a pure-php class. It certainly does not use anything perl related at all. I'd really like to know what makes you think it does. Oh, and there's nothing stopping you installing any of the PEAR classes as a regular user and using it yourself. What could be easier? Not having to read your ignorant emails. -Stut -- If ignorance is bliss, you must be in heaven! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Sending filing attachments using PHP
JupiterHost.Net wrote: Chris wrote: JupiterHost.Net wrote: Ing. Edwin Cruz wrote: Have a look on this: http://framework.zend.com/manual/en/zend.mail.attachments.html It seems to be easy with zend framework How about a way to do it without having to install a huge system wide binary and configruation that might potentially break apache and all PHP sites? http://search.cpan.org/perldoc?Mail::Sender::Easy The OP is asking for a PHP solution and you point to cpan.. Hmm. Yep, because PHP is not usually (some say *never*) the best solution *and* this *is* a PHP + DB list so the OP actually has nothing to do with thei slist anyway. Agreed, but the subject does say "using PHP". phpmailer (phpmailer.sourceforge.net) handles everything for you.. even if you want to roll your own, that code will give you a good starting point. Right after rebuilding php and apache and breaking PHP funtionality for everyone, just so you can send a semi complex MIME message? That is the epitome of PHP's lameness and why I can't sit quietly by and not recommend an easy to install and use and maintain solution. Why are you rebuilding PHP and Apache? In what way does phpmailer (a completely PHP-based solution with no external dependancies) force you to do this and "break[ing] PHP functionality for everyone"? And besides its in a non strutcutered way to maek it even more impossible to maintain. I assume that's a generic dig at PHP. For me, the lack of an enforced structure makes it easier to maintain since it gives you the freedom to put in your own structure. I don't know you from Adam, but for whatever reason you seem to hate PHP. I'm sure whatever it did it wasn't personal. Please do us all a favour and unsubscribe from this list, or at the very least please stop posting pointless and time-wasting answers. -Stut -- If ignorance is bliss, you must be in heaven! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] access db
tuna3000 wrote: im new to php, i would like to see a simple php script for manipulating an access database (or mysql) for me to learn on. thanks. Have you tried the manual? Lots of useful and interesting stuff in there. Especially for people new to PHP. Try http://php.net/odbc and http://php.net/mysql. Google tends to be very good too: http://www.google.co.uk/search?q=php+access+database -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Newly inserted record ID
Skip Evans wrote: I am very new to the list, but I get the impression that Jonathan below is rather new to programming in PHP/MySQL and lists like these are great resources for people without the many years of experience some of us have. And while mysql_insert_id() is old hat to most of us, to people with less experience it is not so obvious. While I agree that we should be here to help people who are new to this topic I find people who ask very basic questions (which this was, a quick look at the mysql docs on php.net would have answered this) without making any effort at all to find the right answer really annoy me. In my experience putting in that bit of effort pays greater dividends than having all the answers served up piecemeal on a silver platter by people on mailing lists. That way you'll never learn. So I'm always dissapointed to see more experienced programmers say things like Stut has said below because they tend to intimiate inexperienced coders, make them shy away from asking questions out of fear that gurus like Stut will say the kinds of things he has said below. For this reason I'm going to unsubscribe from the list, lest I ask a question and get similar treatment. I find that to be a very strange way of looking at the situation. If you don't agree with me and feel that people that don't make any kind of effort should get the answers handed to them, the logical thing to do is to stay on the list and do the handing out. These resources are what the participants make of them - nobody is paid to help out here. Jonathan, if you have any other questions you feel might get you jumped on again for asking please feel free to email me directly. Which defeats the object of these lists since the answers will not be available to others who search the archives. And before you say an RTFM answer is no better, at least if someone looking lands on a pointer to the manual they will know where to look next, and by searching for the answer they have put some effort into finding the answer. And Stut, please please please please please consider other peoples' feelings before you go shooting off your "freaking" mouth. If what I said hurt someones feelings then I apologise, but I hope my above explanation gives acceptable reasons for my attitude to questions like this. Jonathan probably is reading the manual, but may missed the small section on mysql_insert_id(). And for that he doesn't deserve your scron. I saw no mention of this manual reading in the original post, which does not necessarily mean it's not happening, but this particular problem would easily be found by also searching the archives of this list. Flame away. -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Newly inserted record ID
JONATHAN GRAVOIS wrote: Thanks to the help of this list, I am making great progress. Now this -- I have a multi-part submission form for a support application for us, the manufacturer - the reseller's information is submitted, the customer's information is submitted, then the warranty support information needs to be submitted. How can I retrieve the CustomerID after I insert a record into the customer table in mySQL and pass it to the CSQdetails.php page? http://php.net/mysql_insert_id And please please please please please read the freaking manual before asking questions here! -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Session Variable from Recordset
JONATHAN GRAVOIS wrote: What is the syntax for pulling a field out of a query and setting it as a session variable? RTFM: http://php.net/mysqli (assuming you mean a MySQL query) and http://php.net/session Quote: "Failure is not the only punishment for laziness; there is also the success of others." -- Jules Renard Say no more! -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Single quotes in INSERT statements?
Skip Evans wrote: I was under the impression that addslashes() would handle single quote marks in INSERT statements, but when I execute the following: $sql="UPDATE images SET orderno=$orderno, url='".addslashes($url)."', banner=$banner,caption='".addslashes($caption)."' WHERE imageID=$imageID"; ...and $caption contains something like: "Don't look" ...the data is chopped off at the single quote mark. How, if not addslashes(), does one handle this? Change the contents of $sql to use double quotes around the strings instead of single - that's what real_escape_string was designed to escape. Alternatively use str_replace to escape single quotes. -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] apostrophes everywhere
[EMAIL PROTECTED] wrote: I looked at serveral of the function suggestions and indeed stumbled accross htmlspecialchars when doing research on another suggestion: mysqli_real_escape_string which I couldn't use since I'm not on PHP5. While htmlspecialchars may not offer as much security as the later it should would for my purposes. Just to clarify, my suggestion was mysql_real_escape_string, not mysqli_real_escape_string. The former is available on PHP4 >= 4.3.0 and PHP5. That's the function the link I posted goes to (http://php.net/mysql_real_escape_string). -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] apostrophes everywhere
Andrew Darrow wrote: Everything get's run except for the INSERT INTO if there is an apostrophe in the value $blog. If I replace the apostrophe with ' it works fine. On my server I'm running PHP 4.4 and mySQL 4.1.16. I design there and publish elsewere. On my server everything works fine all the time, but on the production server I'm running PHP 4.3.11 and MySQL 4.1.12 that's where i'm having problems with the apostrophe. RTFM: http://php.net/mysql_real_escape_string and http://php.net/magic_quotes -Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] PHP working but now Disobedient
On Wed, 1 Sep 2004 10:24:07 -0700 (PDT), Judy Picard <[EMAIL PROTECTED]> wrote: > > Prob 1: I am getting the following error: "Parse > > error: parse error, unexpected ';' in > > c:\inetpub\wwwroot\PTMemorandum6.php on line 89" > > > > 1 Trying Should be... 1 Trying > > Prob 2: Before the above error started, The > > following > > section was not creating 10 rows. > > > > > > > for ($i=0; $i <$count; $i++): ?> The should be inside the for loop. -- Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Read a PDF file via PHP
On Fri, 25 Jun 2004 19:36:11 +, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Is there any way to get PHP to simply read the PDF file for text only--just the > surface of it, just the words, as if it were a human reading the PDF itself--and not > for the internal code of the file? I do this on one of my sites using a utility called pstotext. Find it at http://research.compaq.com/SRC/virtualpaper/pstotext.html -- Stut -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php