Re: [PHP] whats wrong
On Sat, Mar 31, 2012 at 6:36 AM, Maciek Sokolewicz maciek.sokolew...@gmail.com wrote: On 31-03-2012 10:29, tamouse mailing lists wrote: On Sat, Mar 31, 2012 at 1:45 AM, saeed ahmedmycomputerbo...@gmail.com wrote: i have made a php script with a tutorial helpi dont know where is a error.please have a look Before you actually run code in a browser, check your syntax with php -l (for lint, the old command to check C syntax on unixy systems) on a command line. This will improve your life immeasurably since you won't have to chase down where the server logs errors just to see if your code was syntactically correct. miishka:Sites tamara$ php -l test.saeed.php PHP Parse error: syntax error, unexpected T_STRING in test.saeed.php on line 6 Errors parsing test.saeed.php miishka:Sites tamara$ Which points out the syntax error on line 6 where you have: $result=mysql_query(select(SELECT*FROM COLLEAGUE); Which as an improperly formed select sql, and an unclosed string (thus sucking up part of your php code and html document. To fix this, it should be: $result=mysql_query($db, SELECT * FROM COLLEAGUE); Wrong, it should be the other way around. First the query, and then an OPTIONAL link-identifier (which I assume $db to be in this case). i.e., the sql statement is in a single string. Also, spacing around the column list * may or may not be necessary, but it's a lot easier to read if it's there. Also, you need to tell the query procedure what data base you're using the $db variable (see below for this). Ok, that fixed, run php -l on the file again, and we get: PHP Parse error: syntax error, unexpected '' in test.saeed.php on line 31 Errors parsing test.saeed.php Looking at line 31: echo td . $row['firstName'] ./td; it looks fine, you might be wondering why it's complaining about that line. The key is to look up from there for possible syntax problems, and on line 30, there is a problem in that you didn't close the last string: echotd.$row['id'] ./td; should be: echotd.$row['id'] ./td; Ok, fix that, run php -l again: PHP Parse error: syntax error, unexpected '[', expecting ',' or ';' in test.saeed.php on line 34 Errors parsing test.saeed.php So, look at line 34 now: echo td . Srow['email'] ./td; The problem is that you typoed the dollar sign in front of row. It should be: echo td . $row['email'] ./td; Also, on this line, although php -l won't catch it, is an html error. The last /td is not closed, so: echo td . $row['email'] ./td; Run php -l again, and this time, voila: No syntax errors detected in test.saeed.php That solves your syntax errors. Now you can test it from a server. Before you do that though, a few other points: When developing code, it's a really good idea to turn on run time error checking so you can see things in the browser when a problem crops up: ?php error_reporting(-1); // turns on EVERYTHING ini_set('display_errors',true); ini_set('display_startup_errors',true); // follow with your code... This won't help if your code doesn't parse correctly, but that's what the php -l is for above, but it will reveal run-time processing errors in your browser. And you have several. As another responder said, checking the return values of functions is important. Sometimes tutorials omit this for the sake of brevity, but it is something that still should be done. Line 3: mysql_connect(localhost,root, ); is incorrect on at least two levels. First, you haven't saved the data base resource that is returned from mysql_connect, and second, you haven't checked that the call was successful. Third, possibly is that you have specified the root mysql password a string of one space. This is unlikely to be the password. It should be rewritten as: $db = mysql_connect(localhost, root, ) or die(Could not connect to mysql server on local host: . mysql_error() . PHP_EOL); The next line: mysql_select_db(addressbook); is also incorrect as it does not specify the data base resource which you omitted in the previous call, and you aren't (again) checking the result to see if it works. It should be rewritten as: mysql_select_db($db, addressbook) or die (Could not connect to data base 'addressbook'. Error: . mysql_error($db) . PHP_EOL); Back to that line 6, after you've repaired it, you *again* need to check that the query actually worked. After that query, include the following line: if (FALSE === $result) die (Query failed. Error: . mysql_error($db) . PHP_EOL); Note that if the table is empty, that is not an error; your result set will simply be empty. Returning FALSE indicates that there was an actual error in the query. I find it better to put the sql statement into a string, and then use the string variable in the actual query function. This lets you also print out the query as it was sent to mysql: $sql =
Re: [PHP] whats wrong
On Fri, Mar 30, 2012 at 11:45 PM, saeed ahmed mycomputerbo...@gmail.com wrote: i have made a php script with a tutorial helpi dont know where is a error.please have a look Your code below assumes that everything is perfect in your world. IE: no network connectivity issue, all firewall related are properly configured, the user account actually exists and have the right permissions, the database exists and so are the table(s), etc I suggest you revisit the official PHP manual and read about each function you're using. ?php //connect and select a database mysql_connect(localhost,root, ); for starters, http://php.net/function.mysql-connect Noticed the result returned. You didn't bother to check whether if it's successful or not. If not why not? Since the DB is on the same box, is the firewall, if any, configured properly? If there's no firewall or if it's configured properly, is the account valid and have the right permissions? Is the MySQL server running on the default port 3306? If you don't know how to configure each of the above mentioned, allow me to introduce you a new friend, Google ;) Both of those topics are beyond the scope of this list. HTH, Tommy mysql_select_db(addressbook); //Run a query $result=mysql_query(select(SELECT*FROM COLLEAGUE); ? !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 titleAddress Book/title meta http-equiv=content-type content=text/html;charset=utf-8 /head body h1Address Bookh1 table Border=1 cellpadding=2cellspacing=3 summary=table holda colleague contacts information tr th ID/th thFirst Name/th thLast Name/th thTelephone/th thEmail Address/th /tr ?php //LOOP through all table rows while ($row=mysql_fetch_array($result)) { echotr; echotd.$row['id'] . /td; echo td . $row['firstName'] . /td; echo td . $row['lastName'] . /td; echo td . $row['telephone'] . /td; echo td . Srow['email'] . /td; echo/tr; } //free result memory and close database connection mysql_free_result($result); mysql_close(); ? /table /body /html thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] whats wrong
Please check this line: $result=mysql_query(select(SELECT*FROM COLLEAGUE); I think it should be: $result=mysql_query(SELECT * FROM COLLEAGUE); On Sat, Mar 31, 2012 at 1:45 PM, saeed ahmed mycomputerbo...@gmail.comwrote: i have made a php script with a tutorial helpi dont know where is a error.please have a look ?php //connect and select a database mysql_connect(localhost,root, ); mysql_select_db(addressbook); //Run a query $result=mysql_query(select(SELECT*FROM COLLEAGUE); ? !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 titleAddress Book/title meta http-equiv=content-type content=text/html;charset=utf-8 /head body h1Address Bookh1 table Border=1 cellpadding=2cellspacing=3 summary=table holda colleague contacts information tr th ID/th thFirst Name/th thLast Name/th thTelephone/th thEmail Address/th /tr ?php //LOOP through all table rows while ($row=mysql_fetch_array($result)) { echotr; echotd.$row['id'] . /td; echo td . $row['firstName'] . /td; echo td . $row['lastName'] . /td; echo td . $row['telephone'] . /td; echo td . Srow['email'] . /td; echo/tr; } //free result memory and close database connection mysql_free_result($result); mysql_close(); ? /table /body /html thanks -- Duken Marga
Re: [PHP] whats wrong
On Sat, Mar 31, 2012 at 1:45 AM, saeed ahmed mycomputerbo...@gmail.com wrote: i have made a php script with a tutorial helpi dont know where is a error.please have a look Before you actually run code in a browser, check your syntax with php -l (for lint, the old command to check C syntax on unixy systems) on a command line. This will improve your life immeasurably since you won't have to chase down where the server logs errors just to see if your code was syntactically correct. miishka:Sites tamara$ php -l test.saeed.php PHP Parse error: syntax error, unexpected T_STRING in test.saeed.php on line 6 Errors parsing test.saeed.php miishka:Sites tamara$ Which points out the syntax error on line 6 where you have: $result=mysql_query(select(SELECT*FROM COLLEAGUE); Which as an improperly formed select sql, and an unclosed string (thus sucking up part of your php code and html document. To fix this, it should be: $result=mysql_query($db, SELECT * FROM COLLEAGUE); i.e., the sql statement is in a single string. Also, spacing around the column list * may or may not be necessary, but it's a lot easier to read if it's there. Also, you need to tell the query procedure what data base you're using the $db variable (see below for this). Ok, that fixed, run php -l on the file again, and we get: PHP Parse error: syntax error, unexpected '' in test.saeed.php on line 31 Errors parsing test.saeed.php Looking at line 31: echo td . $row['firstName'] . /td; it looks fine, you might be wondering why it's complaining about that line. The key is to look up from there for possible syntax problems, and on line 30, there is a problem in that you didn't close the last string: echotd.$row['id'] . /td; should be: echotd.$row['id'] . /td; Ok, fix that, run php -l again: PHP Parse error: syntax error, unexpected '[', expecting ',' or ';' in test.saeed.php on line 34 Errors parsing test.saeed.php So, look at line 34 now: echo td . Srow['email'] . /td; The problem is that you typoed the dollar sign in front of row. It should be: echo td . $row['email'] . /td; Also, on this line, although php -l won't catch it, is an html error. The last /td is not closed, so: echo td . $row['email'] . /td; Run php -l again, and this time, voila: No syntax errors detected in test.saeed.php That solves your syntax errors. Now you can test it from a server. Before you do that though, a few other points: When developing code, it's a really good idea to turn on run time error checking so you can see things in the browser when a problem crops up: ?php error_reporting(-1); // turns on EVERYTHING ini_set('display_errors',true); ini_set('display_startup_errors',true); // follow with your code... This won't help if your code doesn't parse correctly, but that's what the php -l is for above, but it will reveal run-time processing errors in your browser. And you have several. As another responder said, checking the return values of functions is important. Sometimes tutorials omit this for the sake of brevity, but it is something that still should be done. Line 3: mysql_connect(localhost,root, ); is incorrect on at least two levels. First, you haven't saved the data base resource that is returned from mysql_connect, and second, you haven't checked that the call was successful. Third, possibly is that you have specified the root mysql password a string of one space. This is unlikely to be the password. It should be rewritten as: $db = mysql_connect(localhost, root, ) or die(Could not connect to mysql server on local host: . mysql_error() . PHP_EOL); The next line: mysql_select_db(addressbook); is also incorrect as it does not specify the data base resource which you omitted in the previous call, and you aren't (again) checking the result to see if it works. It should be rewritten as: mysql_select_db($db, addressbook) or die (Could not connect to data base 'addressbook'. Error: . mysql_error($db) . PHP_EOL); Back to that line 6, after you've repaired it, you *again* need to check that the query actually worked. After that query, include the following line: if (FALSE === $result) die (Query failed. Error: . mysql_error($db) . PHP_EOL); Note that if the table is empty, that is not an error; your result set will simply be empty. Returning FALSE indicates that there was an actual error in the query. I find it better to put the sql statement into a string, and then use the string variable in the actual query function. This lets you also print out the query as it was sent to mysql: $sql = select * from colleague; $result = mysql_query($db, $sql); if (FALSE === $result) die (Query failed. \$sql=$sql. Error: . mysql_error($db) . PHP_EOL); A little further on, there is a problem in the html meta statement: there is no closer on that line: meta http-equiv=content-type content=text/html;charset=utf-8 It needs to be closed with / since you're using
Re: [PHP] whats wrong
On 31-03-2012 10:29, tamouse mailing lists wrote: On Sat, Mar 31, 2012 at 1:45 AM, saeed ahmedmycomputerbo...@gmail.com wrote: i have made a php script with a tutorial helpi dont know where is a error.please have a look Before you actually run code in a browser, check your syntax with php -l (for lint, the old command to check C syntax on unixy systems) on a command line. This will improve your life immeasurably since you won't have to chase down where the server logs errors just to see if your code was syntactically correct. miishka:Sites tamara$ php -l test.saeed.php PHP Parse error: syntax error, unexpected T_STRING in test.saeed.php on line 6 Errors parsing test.saeed.php miishka:Sites tamara$ Which points out the syntax error on line 6 where you have: $result=mysql_query(select(SELECT*FROM COLLEAGUE); Which as an improperly formed select sql, and an unclosed string (thus sucking up part of your php code and html document. To fix this, it should be: $result=mysql_query($db, SELECT * FROM COLLEAGUE); Wrong, it should be the other way around. First the query, and then an OPTIONAL link-identifier (which I assume $db to be in this case). i.e., the sql statement is in a single string. Also, spacing around the column list * may or may not be necessary, but it's a lot easier to read if it's there. Also, you need to tell the query procedure what data base you're using the $db variable (see below for this). Ok, that fixed, run php -l on the file again, and we get: PHP Parse error: syntax error, unexpected '' in test.saeed.php on line 31 Errors parsing test.saeed.php Looking at line 31: echo td . $row['firstName'] ./td; it looks fine, you might be wondering why it's complaining about that line. The key is to look up from there for possible syntax problems, and on line 30, there is a problem in that you didn't close the last string: echotd.$row['id'] ./td; should be: echotd.$row['id'] ./td; Ok, fix that, run php -l again: PHP Parse error: syntax error, unexpected '[', expecting ',' or ';' in test.saeed.php on line 34 Errors parsing test.saeed.php So, look at line 34 now: echo td . Srow['email'] ./td; The problem is that you typoed the dollar sign in front of row. It should be: echo td . $row['email'] ./td; Also, on this line, although php -l won't catch it, is an html error. The last /td is not closed, so: echo td . $row['email'] ./td; Run php -l again, and this time, voila: No syntax errors detected in test.saeed.php That solves your syntax errors. Now you can test it from a server. Before you do that though, a few other points: When developing code, it's a really good idea to turn on run time error checking so you can see things in the browser when a problem crops up: ?php error_reporting(-1); // turns on EVERYTHING ini_set('display_errors',true); ini_set('display_startup_errors',true); // follow with your code... This won't help if your code doesn't parse correctly, but that's what the php -l is for above, but it will reveal run-time processing errors in your browser. And you have several. As another responder said, checking the return values of functions is important. Sometimes tutorials omit this for the sake of brevity, but it is something that still should be done. Line 3: mysql_connect(localhost,root, ); is incorrect on at least two levels. First, you haven't saved the data base resource that is returned from mysql_connect, and second, you haven't checked that the call was successful. Third, possibly is that you have specified the root mysql password a string of one space. This is unlikely to be the password. It should be rewritten as: $db = mysql_connect(localhost, root, ) or die(Could not connect to mysql server on local host: . mysql_error() . PHP_EOL); The next line: mysql_select_db(addressbook); is also incorrect as it does not specify the data base resource which you omitted in the previous call, and you aren't (again) checking the result to see if it works. It should be rewritten as: mysql_select_db($db, addressbook) or die (Could not connect to data base 'addressbook'. Error: . mysql_error($db) . PHP_EOL); Back to that line 6, after you've repaired it, you *again* need to check that the query actually worked. After that query, include the following line: if (FALSE === $result) die (Query failed. Error: . mysql_error($db) . PHP_EOL); Note that if the table is empty, that is not an error; your result set will simply be empty. Returning FALSE indicates that there was an actual error in the query. I find it better to put the sql statement into a string, and then use the string variable in the actual query function. This lets you also print out the query as it was sent to mysql: $sql = select * from colleague; $result = mysql_query($db, $sql); Again, query first, linkidentifier after that. This way you'll always get an error. if
[PHP] Whats the correct syntax for using query results in a new query
I'm trying to use the AdminID that returns from query #1 in the WHERE AdminID = AdminID from Query 1 $sql= SELECT WorkOrderID, CreatedDate, Location, WorkOrderName, AdminID, FormName, Status, Notes, pod FROM `workorders` WHERE AdminID = '.$row['AdminID'].' ; that isn't working and the query 1 does return in this case 3 AdminID's so I'm thinking it's just the .$row['AdminID'] part that is wrong and I have tried some different things but am not sure the correct term for what I'm trying to do so I can' t seem to google answers Here is my query #1 $query = SELECT `UserName`, `AdminID` FROM admin WHERE Retail1 = 'YES' ; $result = mysql_query ($query) ; //$row = mysql_fetch_array($result); while ($row = mysql_fetch_row($result)){ for ($i=0; $imysql_num_fields($result); $i++) echo $row[$i] . ; } Above returns 3 AdminID ... I also tried using the While statement in my second query to return the sets but nothing... yet the code isn't breaking, just returning 0 Thanks Terion Happy Freecycling Free the List !! www.freecycle.org Over Moderation of Freecycle List Prevents Post Timeliness. Twitter? http://twitter.com/terionmiller Facebook: a href=http://www.facebook.com/people/Terion-Miller/1542024891; title=Terion Miller's Facebook profile target=_TOPimg src= http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0 alt=Terion Miller's Facebook profile/a Joe DiMaggio - Pair up in threes.
Re: [PHP] Whats the correct syntax for using query results in a new query
On Tue, 2009-03-03 at 14:09 -0600, Terion Miller wrote: I'm trying to use the AdminID that returns from query #1 in the WHERE AdminID = AdminID from Query 1 $sql= SELECT WorkOrderID, CreatedDate, Location, WorkOrderName, AdminID, FormName, Status, Notes, pod FROM `workorders` WHERE AdminID = '.$row['AdminID'].' ; that isn't working and the query 1 does return in this case 3 AdminID's so I'm thinking it's just the .$row['AdminID'] part that is wrong and I have tried some different things but am not sure the correct term for what I'm trying to do so I can' t seem to google answers Here is my query #1 $query = SELECT `UserName`, `AdminID` FROM admin WHERE Retail1 = 'YES' ; $result = mysql_query ($query) ; //$row = mysql_fetch_array($result); while ($row = mysql_fetch_row($result)){ for ($i=0; $imysql_num_fields($result); $i++) echo $row[$i] . ; } Above returns 3 AdminID ... I also tried using the While statement in my second query to return the sets but nothing... yet the code isn't breaking, just returning 0 Thanks Terion Happy Freecycling Free the List !! www.freecycle.org Over Moderation of Freecycle List Prevents Post Timeliness. Twitter? http://twitter.com/terionmiller Facebook: a href=http://www.facebook.com/people/Terion-Miller/1542024891; title=Terion Miller's Facebook profile target=_TOPimg src= http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0 alt=Terion Miller's Facebook profile/a Joe DiMaggio - Pair up in threes. $query = SELECT `UserName`, `AdminID` FROM admin WHERE Retail1 = 'YES' ; When you run this in phpMyAdmin, what is returned? Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats the correct syntax for using query results in a new query
On Tue, Mar 3, 2009 at 2:20 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Tue, 2009-03-03 at 14:09 -0600, Terion Miller wrote: I'm trying to use the AdminID that returns from query #1 in the WHERE AdminID = AdminID from Query 1 $sql= SELECT WorkOrderID, CreatedDate, Location, WorkOrderName, AdminID, FormName, Status, Notes, pod FROM `workorders` WHERE AdminID = '.$row['AdminID'].' ; that isn't working and the query 1 does return in this case 3 AdminID's so I'm thinking it's just the .$row['AdminID'] part that is wrong and I have tried some different things but am not sure the correct term for what I'm trying to do so I can' t seem to google answers Here is my query #1 $query = SELECT `UserName`, `AdminID` FROM admin WHERE Retail1 = 'YES' ; $result = mysql_query ($query) ; //$row = mysql_fetch_array($result); while ($row = mysql_fetch_row($result)){ for ($i=0; $imysql_num_fields($result); $i++) echo $row[$i] . ; } Above returns 3 AdminID ... I also tried using the While statement in my second query to return the sets but nothing... yet the code isn't breaking, just returning 0 $query = SELECT `UserName`, `AdminID` FROM admin WHERE Retail1 = 'YES' ; When you run this in phpMyAdmin, what is returned? Ash www.ashleysheridan.co.uk When I run the second query the one where the WHERE syntax is wrong if I put it like this I still get one record: SQL query: SELECT WorkOrderID, CreatedDate, Location, WorkOrderName, AdminID , FormName, STATUS , Notes, pod FROM `workorders` WHERE AdminID = '20' AND '61' AND '24' LIMIT 0 , 30 this part keeps getting put in by phpMyAdmin the first query works and returns the records it should... which are 3 usernames and 3 adminID
Re: [PHP] Whats the correct syntax for using query results in a new query
I'm trying to use the AdminID that returns from query #1 in the WHERE AdminID = AdminID from Query 1 Okay, I think I understand what you are trying to do. //query 1 $query1 = SELECT UserName, AdminID FROM admin WHERE Retail1 = 'YES'; $result1 = mysql_query ($query1) ; while ($row1 = mysql_fetch_row($result1)){ $admin_id = $row1['AdminID']; //query 2 $query2= SELECT WorkOrderID, CreatedDate, Location, WorkOrderName, AdminID, FormName, Status, Notes, pod FROM workorders WHERE AdminID = $admin_id; $result2 = mysql_query ($query2) ; $end_result = mysql_fetch_row($result2); echo $end_result['WorkOrderID']; echo $end_result['CreatedDate']; }
Re: [PHP] Whats the correct syntax for using query results in a new query
On Tue, 2009-03-03 at 14:36 -0600, Terion Miller wrote: On Tue, Mar 3, 2009 at 2:20 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Tue, 2009-03-03 at 14:09 -0600, Terion Miller wrote: I'm trying to use the AdminID that returns from query #1 in the WHERE AdminID = AdminID from Query 1 $sql= SELECT WorkOrderID, CreatedDate, Location, WorkOrderName, AdminID, FormName, Status, Notes, pod FROM `workorders` WHERE AdminID = '.$row['AdminID'].' ; that isn't working and the query 1 does return in this case 3 AdminID's so I'm thinking it's just the .$row['AdminID'] part that is wrong and I have tried some different things but am not sure the correct term for what I'm trying to do so I can' t seem to google answers Here is my query #1 $query = SELECT `UserName`, `AdminID` FROM admin WHERE Retail1 = 'YES' ; $result = mysql_query ($query) ; //$row = mysql_fetch_array($result); while ($row = mysql_fetch_row($result)){ for ($i=0; $imysql_num_fields($result); $i++) echo $row[$i] . ; } Above returns 3 AdminID ... I also tried using the While statement in my second query to return the sets but nothing... yet the code isn't breaking, just returning 0 $query = SELECT `UserName`, `AdminID` FROM admin WHERE Retail1 = 'YES' ; When you run this in phpMyAdmin, what is returned? Ash www.ashleysheridan.co.uk When I run the second query the one where the WHERE syntax is wrong if I put it like this I still get one record: SQL query: SELECT WorkOrderID, CreatedDate, Location, WorkOrderName, AdminID , FormName, STATUS , Notes, pod FROM `workorders` WHERE AdminID = '20' AND '61' AND '24' LIMIT 0 , 30 this part keeps getting put in by phpMyAdmin the first query works and returns the records it should... which are 3 usernames and 3 adminID What about joining the queries? SELECT admin.UserName, admin.AdminID, workorders.WorkOrderID, workorders.CreateDate, workorders.Location, workorders.WorkOrderName, workorders.FormName, workorders.STATUS, workorders.Notes, workorders.pod FROM admin LEFT JOIN workorders ON (admin.AdminID = workorders.AdminID) WHERE admin.Retail1 = 'yes' I know it looks like a mess, but it should do the trick Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats the correct syntax for using query results in a new query
On Tue, Mar 3, 2009 at 3:51 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Tue, 2009-03-03 at 14:36 -0600, Terion Miller wrote: On Tue, Mar 3, 2009 at 2:20 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Tue, 2009-03-03 at 14:09 -0600, Terion Miller wrote: I'm trying to use the AdminID that returns from query #1 in the WHERE AdminID = AdminID from Query 1 $sql= SELECT WorkOrderID, CreatedDate, Location, WorkOrderName, AdminID, FormName, Status, Notes, pod FROM `workorders` WHERE AdminID = '.$row['AdminID'].' ; that isn't working and the query 1 does return in this case 3 AdminID's so I'm thinking it's just the .$row['AdminID'] part that is wrong and I have tried some different things but am not sure the correct term for what I'm trying to do so I can' t seem to google answers Here is my query #1 $query = SELECT `UserName`, `AdminID` FROM admin WHERE Retail1 = 'YES' ; $result = mysql_query ($query) ; //$row = mysql_fetch_array($result); while ($row = mysql_fetch_row($result)){ for ($i=0; $imysql_num_fields($result); $i++) echo $row[$i] . ; } Above returns 3 AdminID ... I also tried using the While statement in my second query to return the sets but nothing... yet the code isn't breaking, just returning 0 $query = SELECT `UserName`, `AdminID` FROM admin WHERE Retail1 = 'YES' ; When you run this in phpMyAdmin, what is returned? Ash www.ashleysheridan.co.uk When I run the second query the one where the WHERE syntax is wrong if I put it like this I still get one record: SQL query: SELECT WorkOrderID, CreatedDate, Location, WorkOrderName, AdminID , FormName, STATUS , Notes, pod FROM `workorders` WHERE AdminID = '20' AND '61' AND '24' LIMIT 0 , 30 this part keeps getting put in by phpMyAdmin the first query works and returns the records it should... which are 3 usernames and 3 adminID What about joining the queries? SELECT admin.UserName, admin.AdminID, workorders.WorkOrderID, workorders.CreateDate, workorders.Location, workorders.WorkOrderName, workorders.FormName, workorders.STATUS, workorders.Notes, workorders.pod FROM admin LEFT JOIN workorders ON (admin.AdminID = workorders.AdminID) WHERE admin.Retail1 = 'yes' I know it looks like a mess, but it should do the trick Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php incorrect syntax on your query try SQL query: SELECT WorkOrderID, CreatedDate, Location, WorkOrderName, AdminID , FormName, STATUS , Notes, pod FROM `workorders` WHERE AdminID in ( '20','61','24') -- Bastien Cat, the other other white meat
Re: [PHP] Whats the correct syntax for using query results in a new query
On Tue, 2009-03-03 at 15:54 -0500, Bastien Koert wrote: On Tue, Mar 3, 2009 at 3:51 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Tue, 2009-03-03 at 14:36 -0600, Terion Miller wrote: On Tue, Mar 3, 2009 at 2:20 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Tue, 2009-03-03 at 14:09 -0600, Terion Miller wrote: I'm trying to use the AdminID that returns from query #1 in the WHERE AdminID = AdminID from Query 1 $sql= SELECT WorkOrderID, CreatedDate, Location, WorkOrderName, AdminID, FormName, Status, Notes, pod FROM `workorders` WHERE AdminID = '.$row['AdminID'].' ; that isn't working and the query 1 does return in this case 3 AdminID's so I'm thinking it's just the .$row['AdminID'] part that is wrong and I have tried some different things but am not sure the correct term for what I'm trying to do so I can' t seem to google answers Here is my query #1 $query = SELECT `UserName`, `AdminID` FROM admin WHERE Retail1 = 'YES' ; $result = mysql_query ($query) ; //$row = mysql_fetch_array($result); while ($row = mysql_fetch_row($result)){ for ($i=0; $imysql_num_fields($result); $i++) echo $row[$i] . ; } Above returns 3 AdminID ... I also tried using the While statement in my second query to return the sets but nothing... yet the code isn't breaking, just returning 0 $query = SELECT `UserName`, `AdminID` FROM admin WHERE Retail1 = 'YES' ; When you run this in phpMyAdmin, what is returned? Ash www.ashleysheridan.co.uk When I run the second query the one where the WHERE syntax is wrong if I put it like this I still get one record: SQL query: SELECT WorkOrderID, CreatedDate, Location, WorkOrderName, AdminID , FormName, STATUS , Notes, pod FROM `workorders` WHERE AdminID = '20' AND '61' AND '24' LIMIT 0 , 30 this part keeps getting put in by phpMyAdmin the first query works and returns the records it should... which are 3 usernames and 3 adminID What about joining the queries? SELECT admin.UserName, admin.AdminID, workorders.WorkOrderID, workorders.CreateDate, workorders.Location, workorders.WorkOrderName, workorders.FormName, workorders.STATUS, workorders.Notes, workorders.pod FROM admin LEFT JOIN workorders ON (admin.AdminID = workorders.AdminID) WHERE admin.Retail1 = 'yes' I know it looks like a mess, but it should do the trick Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php incorrect syntax on your query try SQL query: SELECT WorkOrderID, CreatedDate, Location, WorkOrderName, AdminID , FormName, STATUS , Notes, pod FROM `workorders` WHERE AdminID in ( '20','61','24') Where and what is the syntax error? Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats the correct syntax for using query results in a new query
On Tue, Mar 3, 2009 at 2:51 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Tue, 2009-03-03 at 14:36 -0600, Terion Miller wrote: On Tue, Mar 3, 2009 at 2:20 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Tue, 2009-03-03 at 14:09 -0600, Terion Miller wrote: I'm trying to use the AdminID that returns from query #1 in the WHERE AdminID = AdminID from Query 1 $sql= SELECT WorkOrderID, CreatedDate, Location, WorkOrderName, AdminID, FormName, Status, Notes, pod FROM `workorders` WHERE AdminID = '.$row['AdminID'].' ; that isn't working and the query 1 does return in this case 3 AdminID's so I'm thinking it's just the .$row['AdminID'] part that is wrong and I have tried some different things but am not sure the correct term for what I'm trying to do so I can' t seem to google answers Here is my query #1 $query = SELECT `UserName`, `AdminID` FROM admin WHERE Retail1 = 'YES' ; $result = mysql_query ($query) ; //$row = mysql_fetch_array($result); while ($row = mysql_fetch_row($result)){ for ($i=0; $imysql_num_fields($result); $i++) echo $row[$i] . ; } Above returns 3 AdminID ... I also tried using the While statement in my second query to return the sets but nothing... yet the code isn't breaking, just returning 0 $query = SELECT `UserName`, `AdminID` FROM admin WHERE Retail1 = 'YES' ; When you run this in phpMyAdmin, what is returned? Ash www.ashleysheridan.co.uk When I run the second query the one where the WHERE syntax is wrong if I put it like this I still get one record: SQL query: SELECT WorkOrderID, CreatedDate, Location, WorkOrderName, AdminID , FormName, STATUS , Notes, pod FROM `workorders` WHERE AdminID = '20' AND '61' AND '24' LIMIT 0 , 30 this part keeps getting put in by phpMyAdmin the first query works and returns the records it should... which are 3 usernames and 3 adminID What about joining the queries? SELECT admin.UserName, admin.AdminID, workorders.WorkOrderID, workorders.CreateDate, workorders.Location, workorders.WorkOrderName, workorders.FormName, workorders.STATUS, workorders.Notes, workorders.pod FROM admin LEFT JOIN workorders ON (admin.AdminID = workorders.AdminID) WHERE admin.Retail1 = 'yes' I know it looks like a mess, but it should do the trick Ash www.ashleysheridan.co.uk The joined query works as far as returning the records now I just have to get them to display and I'm good to go, thanks guys!
Re: [PHP] Whats faster? simplexml_load_string or simplexml_load_file?
On Sat, Mar 8, 2008 at 11:18 PM, Lamonte [EMAIL PROTECTED] wrote: I was wondering this because at the moment using simplexml_load_file makes my script go at about 2 seconds per page load, in a loop. Then I created a cache system so it doesn't keep loading the xml file, but I'm wondering if theres a faster way to load xml QUICKER, is it possible with file_get_contents and simplexml_load_string ? Yes, and you may notice performance enhancements because you're now going to parse the XML data line-by-line as opposed to parsing the entire file at once. -- /Dan Daniel P. Brown Senior Unix Geek ? while(1) { $me = $mind--; sleep(86400); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Whats faster? simplexml_load_string or simplexml_load_file?
I was wondering this because at the moment using simplexml_load_file makes my script go at about 2 seconds per page load, in a loop. Then I created a cache system so it doesn't keep loading the xml file, but I'm wondering if theres a faster way to load xml QUICKER, is it possible with file_get_contents and simplexml_load_string ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] whats wrong in this program.
Hi, I tried to use the final array values in a insert statement, but the values are not inserted. the code is foreach ($final as $subnum){ $res = $db-query(INSERT INTO substrate_protocoll(substrate_type,substrate_num,operator,location,solvent,ultrasonic,duration,cdate,ctime,comment) VALUES('$substrate_type1',$subnum,'$operator','$location','$solvent',$uv,$duration,'$cdate','$sctime','$comment')); if(!$res){ echo insert failed; } } the values of array ($subnum)are not inserted , can you tell me where the problem is. Jordan Miller [EMAIL PROTECTED] wrote: I think I finally understand what you are trying to do. I don't see any reason why you need to use the token functions, and I would recommend using array functions instead (also, it is exceedingly easy to sort the elements of an array... see the end). I believe this will do what you are trying to do: //Tokenizer for Babu $str = '10,12,14-18'; $commas = explode(',', $str); // $commas will be an array of three items in this case // Final Values will go into the $final array $final = array(); foreach ($commas as $value) { // If one of the $commas elements contains a dash, we need to get the range between them! if (strstr($value, '-')) { // Explode based on the dash. This code assumes there will only be a single dash $rangeValues = explode('-', $value); foreach (range($rangeValues[0], $rangeValues[1]) as $number) { $final[] = $number; } } else { // If $value does not contain a dash, add it directly to the $final array $final[] = $value; } } echo All your values in the range $str are .implode(' ', $final); // Prints All your values in the range 10,12,14-18 are 10 12 14 15 16 17 18 In your last email, you had some of the values given out of order: 1. 20,21-24 2. 21-24,20 3. 10,20,21-24,25,26,30 To make sure the $final values are always ascending, just do this at the end: sort($final); Done!! Jordan On Sep 13, 2005, at 7:16 PM, babu wrote: $str=10,12,14-18; $tok = strtok($str, ','); while ($tok !== false) { $toks[] = $tok; $tok = strtok(','); } foreach ($toks as $token){ if (strpos($token,'-')){ stringtokenize($token); }else{ $finaltokens[]= $token; } } function stringtokenize($nstr){ $ntok1= strtok($nstr,'-'); $ntok2=strtok('-'); for($i=$ntok1;$i=$ntok2;$i++){ $finaltokens[]= $i; } } foreach ($finaltokens as $ftoken){ echo $ftoken; echo ; } the ouput prints only 10,12 but not 14,15,16,17,18. where is the problem. - To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php - How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos. Get Yahoo! Photos
Re: [PHP] whats wrong in this program.
I tried to use the final array values in a insert statement, but the values are not inserted. the code is foreach ($final as $subnum){ $res = $db-query(INSERT INTO substrate_protocoll(substrate_type,substrate_num,operator,location,solvent,u ltrasonic,duration,cdate,ctime,comment) VALUES('$substrate_type1',$subnum,'$operator','$location','$solvent',$uv,$du ration,'$cdate','$sctime','$comment')); if(!$res){ echo insert failed; } } the values of array ($subnum)are not inserted , can you tell me where the problem is. the problem is probably in this line: echo (INSERT INTO substrate_protocoll(substrate_type,substrate_num,operator,location,solvent,u ltrasonic,duration,cdate,ctime,comment) VALUES('$substrate_type1',$subnum,'$operator','$location','$solvent',$uv,$du ration,'$cdate','$sctime','$comment')); and the problem is that you haven't done this to see what is wrong with the SQL. The next problem is that this line is also missing: echo mysql_error(); Jordan Miller [EMAIL PROTECTED] wrote: I think I finally understand what you are trying to do. I don't see any reason why you need to use the token functions, and I would recommend using array functions instead (also, it is exceedingly easy to sort the elements of an array... see the end). I believe this will do what you are trying to do: //Tokenizer for Babu $str = '10,12,14-18'; $commas = explode(',', $str); // $commas will be an array of three items in this case // Final Values will go into the $final array $final = array(); foreach ($commas as $value) { // If one of the $commas elements contains a dash, we need to get the range between them! if (strstr($value, '-')) { // Explode based on the dash. This code assumes there will only be a single dash $rangeValues = explode('-', $value); foreach (range($rangeValues[0], $rangeValues[1]) as $number) { $final[] = $number; } } else { // If $value does not contain a dash, add it directly to the $final array $final[] = $value; } } echo All your values in the range $str are .implode(' ', $final); // Prints All your values in the range 10,12,14-18 are 10 12 14 15 16 17 18 In your last email, you had some of the values given out of order: 1. 20,21-24 2. 21-24,20 3. 10,20,21-24,25,26,30 To make sure the $final values are always ascending, just do this at the end: sort($final); Done!! Jordan On Sep 13, 2005, at 7:16 PM, babu wrote: $str=10,12,14-18; $tok = strtok($str, ','); while ($tok !== false) { $toks[] = $tok; $tok = strtok(','); } foreach ($toks as $token){ if (strpos($token,'-')){ stringtokenize($token); }else{ $finaltokens[]= $token; } } function stringtokenize($nstr){ $ntok1= strtok($nstr,'-'); $ntok2=strtok('-'); for($i=$ntok1;$i=$ntok2;$i++){ $finaltokens[]= $i; } } foreach ($finaltokens as $ftoken){ echo $ftoken; echo ; } the ouput prints only 10,12 but not 14,15,16,17,18. where is the problem. - To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php - How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos. Get Yahoo! Photos -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] whats wrong in this program.
you need single quotes around $subnum in the sql statement. don't know why you seem to be arbitrarily leaving them off (put them around $uv and $duration, too!). also, you should never insert stuff directly from a user into a database. first escape every variable with: http://www.php.net/mysql_real_escape_string Jordan On Sep 14, 2005, at 6:36 AM, babu wrote: Hi, I tried to use the final array values in a insert statement, but the values are not inserted. the code is foreach ($final as $subnum){ $res = $db-query(INSERT INTO substrate_protocoll (substrate_type,substrate_num,operator,location,solvent,ultrasonic,dur ation,cdate,ctime,comment) VALUES('$substrate_type1', $subnum,'$operator','$location','$solvent',$uv, $duration,'$cdate','$sctime','$comment')); if(!$res){ echo insert failed; } } the values of array ($subnum)are not inserted , can you tell me where the problem is. Jordan Miller [EMAIL PROTECTED] wrote: I think I finally understand what you are trying to do. I don't see any reason why you need to use the token functions, and I would recommend using array functions instead (also, it is exceedingly easy to sort the elements of an array... see the end). I believe this will do what you are trying to do: //Tokenizer for Babu $str = '10,12,14-18'; $commas = explode(',', $str); // $commas will be an array of three items in this case // Final Values will go into the $final array $final = array(); foreach ($commas as $value) { // If one of the $commas elements contains a dash, we need to get the range between them! if (strstr($value, '-')) { // Explode based on the dash. This code assumes there will only be a single dash $rangeValues = explode('-', $value); foreach (range($rangeValues[0], $rangeValues[1]) as $number) { $final[] = $number; } } else { // If $value does not contain a dash, add it directly to the $final array $final[] = $value; } } echo All your values in the range $str are .implode(' ', $final); // Prints All your values in the range 10,12,14-18 are 10 12 14 15 16 17 18 In your last email, you had some of the values given out of order: 1. 20,21-24 2. 21-24,20 3. 10,20,21-24,25,26,30 To make sure the $final values are always ascending, just do this at the end: sort($final); Done!! Jordan On Sep 13, 2005, at 7:16 PM, babu wrote: $str=10,12,14-18; $tok = strtok($str, ','); while ($tok !== false) { $toks[] = $tok; $tok = strtok(','); } foreach ($toks as $token){ if (strpos($token,'-')){ stringtokenize($token); }else{ $finaltokens[]= $token; } } function stringtokenize($nstr){ $ntok1= strtok($nstr,'-'); $ntok2=strtok('-'); for($i=$ntok1;$i=$ntok2;$i++){ $finaltokens[]= $i; } } foreach ($finaltokens as $ftoken){ echo $ftoken; echo ; } the ouput prints only 10,12 but not 14,15,16,17,18. where is the problem. - To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php - How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos. Get Yahoo! Photos -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] whats wrong in this program.
Jordan Miller wrote: you need single quotes around $subnum in the sql statement. don't know why you seem to be arbitrarily leaving them off (put them around $uv and $duration, too!). snip It's not needed if those fields are integers. *damnit, that's twice today I've replied to the poster and not the list. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] whats wrong in this program.
heh, i did it too. John, oh, good to know, thanks. $final should be composed of strings, not integers, so i guess that is his problem. i just read that it is best to quote every variable, now I know why... so you can change implementations later and not have to worry about types (and php's autotyping is so great anyway). Jordan On Sep 14, 2005, at 10:54 AM, John Nichel wrote: Jordan Miller wrote: you need single quotes around $subnum in the sql statement. don't know why you seem to be arbitrarily leaving them off (put them around $uv and $duration, too!). snip It's not needed if those fields are integers. *damnit, that's twice today I've replied to the poster and not the list. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] whats wrong in this program.
$str=10,12,14-18; $tok = strtok($str, ','); while ($tok !== false) { $toks[] = $tok; $tok = strtok(','); } foreach ($toks as $token){ if (strpos($token,'-')){ stringtokenize($token); }else{ $finaltokens[]= $token; } } function stringtokenize($nstr){ $ntok1= strtok($nstr,'-'); $ntok2=strtok('-'); for($i=$ntok1;$i=$ntok2;$i++){ $finaltokens[]= $i; } } foreach ($finaltokens as $ftoken){ echo $ftoken; echo br /; } the ouput prints only 10,12 but not 14,15,16,17,18. where is the problem. - To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre.
Re: [PHP] whats wrong in this program.
I think I finally understand what you are trying to do. I don't see any reason why you need to use the token functions, and I would recommend using array functions instead (also, it is exceedingly easy to sort the elements of an array... see the end). I believe this will do what you are trying to do: //Tokenizer for Babu $str = '10,12,14-18'; $commas = explode(',', $str); // $commas will be an array of three items in this case // Final Values will go into the $final array $final = array(); foreach ($commas as $value) { // If one of the $commas elements contains a dash, we need to get the range between them! if (strstr($value, '-')) { // Explode based on the dash. This code assumes there will only be a single dash $rangeValues = explode('-', $value); foreach (range($rangeValues[0], $rangeValues[1]) as $number) { $final[] = $number; } } else { // If $value does not contain a dash, add it directly to the $final array $final[] = $value; } } echo All your values in the range $str are .implode(' ', $final); // Prints All your values in the range 10,12,14-18 are 10 12 14 15 16 17 18 In your last email, you had some of the values given out of order: 1. 20,21-24 2. 21-24,20 3. 10,20,21-24,25,26,30 To make sure the $final values are always ascending, just do this at the end: sort($final); Done!! Jordan On Sep 13, 2005, at 7:16 PM, babu wrote: $str=10,12,14-18; $tok = strtok($str, ','); while ($tok !== false) { $toks[] = $tok; $tok = strtok(','); } foreach ($toks as $token){ if (strpos($token,'-')){ stringtokenize($token); }else{ $finaltokens[]= $token; } } function stringtokenize($nstr){ $ntok1= strtok($nstr,'-'); $ntok2=strtok('-'); for($i=$ntok1;$i=$ntok2;$i++){ $finaltokens[]= $i; } } foreach ($finaltokens as $ftoken){ echo $ftoken; echo br /; } the ouput prints only 10,12 but not 14,15,16,17,18. where is the problem. - To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] whats happen fsockopen function?
You're STILL seeing the same WARNING message? Or now it's just not working? QT wrote: hi, I clean all signs, but still no result. This code was working perfect last two years. I don't know what happen? Richard Lynch [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] QT wrote: Dear Sirs, my fsockopen function is not working, for last 1 day. And I get following error on log. Any idea why? PHP Warning: Call-time pass-by-reference has been deprecated - argument passed Get rid of the signs in your code inside the fsockopen( ) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] whats happen fsockopen function?
Dear Sirs, my fsockopen function is not working, for last 1 day. And I get following error on log. Any idea why? PHP Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of fsockopen(). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. Best Regards -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] whats happen fsockopen function?
QT wrote: Dear Sirs, my fsockopen function is not working, for last 1 day. And I get following error on log. Any idea why? PHP Warning: Call-time pass-by-reference has been deprecated - argument passed Get rid of the signs in your code inside the fsockopen( ) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] whats happen fsockopen function?
hi, I clean all signs, but still no result. This code was working perfect last two years. I don't know what happen? Richard Lynch [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] QT wrote: Dear Sirs, my fsockopen function is not working, for last 1 day. And I get following error on log. Any idea why? PHP Warning: Call-time pass-by-reference has been deprecated - argument passed Get rid of the signs in your code inside the fsockopen( ) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats faster? text files or mysql?
Andrew -- ...and then Andrew Fenn said... % % I have two text files with two rows of data on each line sperated by a tab for about 20 lines in each file. Would it be faster accessing this data by putting it in a mysql table? For something so small I'd go with a text file unless you happen to already really know and love your database server -- and it's not doing much anyway. The real time savings will come in your programming and maintenance rather than in file access, so do whatever is easiest for you. My guess is that a straight file, even under something as bad as Windows on an ATA disk, will be faster because of the overhead of talking to the database; DBs shine when they have tons of data, not ounces. HTH HAND :-D -- David T-G [EMAIL PROTECTED] http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg! pgp0.pgp Description: PGP signature
RE: [PHP] Whats faster? text files or mysql?
Hi Jay, El mar, 20-04-2004 a las 07:52, Jay Blanchard escribió: [snip] I have two text files with two rows of data on each line sperated by a tab for about 20 lines in each file. Would it be faster accessing this data by putting it in a mysql table? [/snip] Sounds like the perfect opportunity to set up a test! File I/O is always slower. I/O is always slow, but it is even slower when it is done through a network. It is always faster accessing a file on the hard disk than accessing it through the network. If you don't need to index the information and make complex queries, a text file on the web server hard disk is just fine. -William -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats faster? text files or mysql?
El mar, 20-04-2004 a las 08:24, John Nichel escribió: Jay Blanchard wrote: There is always awk! Aw, no votes for cat | grep? ;) No, that would be worse since the system needs to spawn a new process and this is slow too. Specially on a high loaded system. If you are concerned about speed always use native functions. -William -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats faster? text files or mysql?
William Lovaton wrote: El mar, 20-04-2004 a las 08:24, John Nichel escribió: Jay Blanchard wrote: There is always awk! Aw, no votes for cat | grep? ;) No, that would be worse since the system needs to spawn a new process and this is slow too. Specially on a high loaded system. If you are concerned about speed always use native functions. -William It was a joke. :) -- *** * _ __ __ __ _ * John Nichel * * | |/ /___ __ \ \/ /__ _ _| |__ ___ __ ___ _ __ * 716.856.9675 * * | ' / -_) _` \ \/\/ / _ \ '_| / /(_-_/ _/ _ \ ' \ * 737 Main St. * * |_|\_\___\__, |\_/\_/\___/_| |_\_\/__(_)__\___/_|_|_|* Suite #150 * * |___/ * Buffalo, NY * * http://www.KegWorks.com[EMAIL PROTECTED] * 14203 - 1321 * *** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Whats faster? text files or mysql?
I have two text files with two rows of data on each line sperated by a tab for about 20 lines in each file. Would it be faster accessing this data by putting it in a mysql table? - Yahoo! Messenger - Communicate instantly...Ping your friends today! Download Messenger Now
RE: [PHP] Whats faster? text files or mysql?
[snip] I have two text files with two rows of data on each line sperated by a tab for about 20 lines in each file. Would it be faster accessing this data by putting it in a mysql table? [/snip] Sounds like the perfect opportunity to set up a test! File I/O is always slower. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats faster? text files or mysql?
Isn't the database kept in a file? Why would that file be faster than a plain text file? cheers, Travis Jay Blanchard wrote: [snip] I have two text files with two rows of data on each line sperated by a tab for about 20 lines in each file. Would it be faster accessing this data by putting it in a mysql table? [/snip] Sounds like the perfect opportunity to set up a test! File I/O is always slower. -- Travis Low mailto:[EMAIL PROTECTED] http://www.dawnstar.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Whats faster? text files or mysql?
[snip] Isn't the database kept in a file? Why would that file be faster than a plain text file? [/snip] Of course it is, but the file is kept accessible by the database server deamon so you are not reading from a file in the tradional sense. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Whats faster? text files or mysql?
I'm not sure but I think it would depend on the programming language and with php File I/O is slower then database (mySql anyway). Where as Perl would probably be quicker with the text file. I could be wrong though Regards Mark Cubitt -Original Message- From: Travis Low [mailto:[EMAIL PROTECTED] Sent: 20 April 2004 14:12 To: [EMAIL PROTECTED] Subject: Re: [PHP] Whats faster? text files or mysql? Isn't the database kept in a file? Why would that file be faster than a plain text file? cheers, Travis Jay Blanchard wrote: [snip] I have two text files with two rows of data on each line sperated by a tab for about 20 lines in each file. Would it be faster accessing this data by putting it in a mysql table? [/snip] Sounds like the perfect opportunity to set up a test! File I/O is always slower. -- Travis Low mailto:[EMAIL PROTECTED] http://www.dawnstar.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Whats faster? text files or mysql?
[snip] I'm not sure but I think it would depend on the programming language and with php File I/O is slower then database (mySql anyway). Where as Perl would probably be quicker with the text file. [/snip] There is always awk! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats faster? text files or mysql?
From: Andrew Fenn [EMAIL PROTECTED] I have two text files with two rows of data on each line sperated by a tab for about 20 lines in each file. Would it be faster accessing this data by putting it in a mysql table? Depends what you want to do with the data. If you're searching through for specific values, summing values, grouping, etc, then you'd probably be better off putting it in a database as they are designed for those sort of functions. If you're just opening and displaying the file, or looking for one simple match, then just leave it in a file. Don't forget about SQLite if you choose the database route, also. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats faster? text files or mysql?
Mark Cubitt wrote: I'm not sure but I think it would depend on the programming language and with php File I/O is slower then database (mySql anyway). Where as Perl would probably be quicker with the text file. I could be wrong though It would really depend on the size of the file, and how the db table is set up. No matter the size of the file, or if you're using php / Perl, you still have to open the file, and parse it line for line until you find the value you're looking for. If the db table is indexed, it's going to be faster than most text files (unless you only have like 10 records). -- *** * _ __ __ __ _ * John Nichel * * | |/ /___ __ \ \/ /__ _ _| |__ ___ __ ___ _ __ * 716.856.9675 * * | ' / -_) _` \ \/\/ / _ \ '_| / /(_-_/ _/ _ \ ' \ * 737 Main St. * * |_|\_\___\__, |\_/\_/\___/_| |_\_\/__(_)__\___/_|_|_|* Suite #150 * * |___/ * Buffalo, NY * * http://www.KegWorks.com[EMAIL PROTECTED] * 14203 - 1321 * *** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats faster? text files or mysql?
Jay Blanchard wrote: [snip] I'm not sure but I think it would depend on the programming language and with php File I/O is slower then database (mySql anyway). Where as Perl would probably be quicker with the text file. [/snip] There is always awk! Aw, no votes for cat | grep? ;) -- *** * _ __ __ __ _ * John Nichel * * | |/ /___ __ \ \/ /__ _ _| |__ ___ __ ___ _ __ * 716.856.9675 * * | ' / -_) _` \ \/\/ / _ \ '_| / /(_-_/ _/ _ \ ' \ * 737 Main St. * * |_|\_\___\__, |\_/\_/\___/_| |_\_\/__(_)__\___/_|_|_|* Suite #150 * * |___/ * Buffalo, NY * * http://www.KegWorks.com[EMAIL PROTECTED] * 14203 - 1321 * *** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Whats wrong with this statement.
?php ## ASSUME DATABASE IS CONNECTED AND THESE 2 ITEMS ARE NOT IN THE DATABASE ## THIS RETURNS 1,0 all the time. $websiteUrl=http://www.philipnz.com/;; $websiteEmail=[EMAIL PROTECTED]; // CHECK TO SEE IF DATA MATCHS WHATS IN THE DATABASE. $sql = SELECT hUrl,hContactEmail FROM hyperlinks_data; $sql_result = mysql_query($sql, $connection) or die (Could not get Query); $exists_hUrl = 0; $exists_hContactEmail = 0; while ($row = mysql_fetch_array($sql_result)) { if ($websiteUrl==$row[hUrl]) { $exists_hUrl = 1; break; } if ($websiteEmail==$row[hContactEmail]) { $exists_hContactEmail = 1; break; } } Echo $exists_hUrl, $exists_hContactEmail; ? --- Philip J. Newman Master Developer PhilipNZ.com [NZ] Ltd. [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Whats wrong with this query?
$addamysqluser = mysql_query(grant select,insert,drop,update,delete,create,index,alter on $_POST[f2] to [EMAIL PROTECTED] IDENTIFIED by $_POST[f3]); What is wrong with the above php based mysql_query ? I am trying to add a user to mysql granting just the specified rights to table defined by the $_POST[f2] which is both the table and username and the password is defined by $_POST[f3]. This has been baffleing me for a couple of days now and any help given is very much appreciated. Thank you in advance. Yours Dave C --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.535 / Virus Database: 330 - Release Date: 01/11/2003 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats wrong with this query?
Hi Dave, I could be wrong cause i am answering without running your code : 1) your mysql user account probably does not have grant privileges. good thing too. It's very dangerous to just run a grant query like this because it can so easily be abused by a malicious user. (of course you might have security measures in place which are not obvious to us because you have not posted that part of the code). 2) your variables should in the strictest sense be $_POST['f2'] etc. all the best Dave Carrera wrote: $addamysqluser = mysql_query(grant select,insert,drop,update,delete,create,index,alter on $_POST[f2] to [EMAIL PROTECTED] IDENTIFIED by $_POST[f3]); What is wrong with the above php based mysql_query ? I am trying to add a user to mysql granting just the specified rights to table defined by the $_POST[f2] which is both the table and username and the password is defined by $_POST[f3]. This has been baffleing me for a couple of days now and any help given is very much appreciated. Thank you in advance. Yours Dave C -- Raditha Dissanayake. http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader Graphical User Inteface. Just 150 KB | with progress bar. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Whats wrong with this query?
Dave Carrera mailto:[EMAIL PROTECTED] on Monday, November 10, 2003 8:45 AM said: $addamysqluser = mysql_query(grant select,insert,drop,update,delete,create,index,alter on $_POST[f2] to [EMAIL PROTECTED] IDENTIFIED by $_POST[f3]); What is wrong with the above php based mysql_query ? 1. What error are you getting? (This information should always be included in a why isn't this working? post.) 2. How do you know it's not working? 3. Assign your sql statement to a variable and then pass that variable to the mysql_query() function. Then echo the variable used to store the query and see if everything looks right to you. 4. Have you tried putting single quotes around the $_POST indexes? i.e. $_POST['f2'] 5. (I believe) You need to put { and } around your $_POST variables. i.e. {$_POST['f2']} HTH, Chris. -- Don't like reformatting your Outlook replies? Now there's relief! http://home.in.tum.de/~jain/software/outlook-quotefix/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats wrong with this query?
--- Dave Carrera [EMAIL PROTECTED] wrote: $addamysqluser = mysql_query(grant select,insert,drop,update,delete,create,index,alter on $_POST[f2] to [EMAIL PROTECTED] IDENTIFIED by $_POST[f3]); What is wrong with the above php based mysql_query? I'm not sure about the query itself, but it seems to me your problem is more about using strings with PHP. $foo = grant select,insert,drop,update,delete,create,index,alter on $_POST[f2] to [EMAIL PROTECTED] IDENTIFIED by $_POST[f3]; echo $foo; Try that, and I think the output will show you the problem. The solution is to use curly braces around $_POST['f2'], in addition to properly quoting the key as I just did. In order to more easily identify problems like this, you can: 1. Store the query in a variable, and use that variable in mysql_query(). This will allow you to echo it to the screen or something during debugging, so that you can identify anything obvious, such as this. 2. Output mysql_error() if mysql_query() does not return true. This will show you what MySQL thinks the error is, which is very helpful. Hope that helps. Chris = My Blog http://shiflett.org/ HTTP Developer's Handbook http://httphandbook.org/ RAMP Training Courses http://www.nyphp.org/ramp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Whats wrong with this query?
-Original Message- From: Dave Carrera [mailto:[EMAIL PROTECTED] Sent: maandag 10 november 2003 17:45 To: [EMAIL PROTECTED] Subject: [PHP] Whats wrong with this query? $addamysqluser = mysql_query(grant select,insert,drop,update,delete,create,index,alter on $_POST[f2] to [EMAIL PROTECTED] IDENTIFIED by $_POST[f3]); What is wrong with the above php based mysql_query ? The value you use for the IDENTIFIED BY clause (which is, of course, the password) should be quoted in mysql because it is a value. Both table and username are sortoff 'objects'. Try this: $Query = 'GRANT select, insert, drop, update, delete, create, index, alter ON '.$_POST['f2'].' TO '.$_POST['f2'].' IDENTIFIED BY '.mysql_escape_string($_POST['f3']).''; mysql_query($Query); if (mysql_error()) print mysql_error(); What I also just noted was that you use $_POST[f2] twice, if you are not also creating a table with the same name as the user this is probably not what you meant. It might just, but it looks odd to me. Wouter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats more efficient? ( echo ; or ?php echo ? )
I believe I read someplace once that it is more efficient to have your php embedded in your HTML where required. Something to do with the amount of parsing that the engine has to do. However, to reiterate what Captain John W. Holmes said, using a templating engine does allow you to better manage the project especially in dealing with maintenance down the road. I personally prefer to let the business logic create XML and employ XSLT to do my Html rendering. It may not be the quickest or most memory efficient, but, in my humble opinion, it is one of the easiest to maintain. Jordan S. Jones Ryan A wrote: Hi everyone, Just a simple doubt and basically your opinion needed. I have an option box on a webpage and have around 10 options on it and have run into a doubt, which is more efficient to do: 1. option value=1?php if($th_order==1){echo SELECTED; } ?Something1/option option value=2?php if($th_order==2){echo SELECTED; } ?Something2/option (or) 2. instead of having the ?php and ? mixed in the HTML is it better to echo/print the whole lines? Thanks, -Ryan -- I am nothing but a poor boy. Please Donate.. https://www.paypal.com/xclick/business=list%40racistnames.comitem_name=Jordan+S.+Jonesno_note=1tax=0currency_code=USD -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats more efficient? (Conclusion)
On Wed, 22 Oct 2003, Ryan A wrote: what do you suggest? and any urls for reading up on caching? Some benchmarks on content and bytecode caching: http://www.appelsiini.net/~tuupola/articles/benchmarking-phpa/ -- Mika Tuupola http://www.appelsiini.net/~tuupola/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Whats more efficient? ( echo ; or ?php echo ? )
Hi everyone, Just a simple doubt and basically your opinion needed. I have an option box on a webpage and have around 10 options on it and have run into a doubt, which is more efficient to do: 1. option value=1?php if($th_order==1){echo SELECTED; } ?Something1/option option value=2?php if($th_order==2){echo SELECTED; } ?Something2/option (or) 2. instead of having the ?php and ? mixed in the HTML is it better to echo/print the whole lines? Thanks, -Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats more efficient? ( echo ; or ?php echo ? )
Ryan A wrote: I have an option box on a webpage and have around 10 options on it and have run into a doubt, which is more efficient to do: 1. option value=1?php if($th_order==1){echo SELECTED; } ?Something1/option option value=2?php if($th_order==2){echo SELECTED; } ?Something2/option (or) 2. instead of having the ?php and ? mixed in the HTML is it better to echo/print the whole lines? Use a template engine to separate your presentation from your logic. :) -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats more efficient? ( echo ; or ?php echo ? )
which is more efficient to do: 1. option value=1?php if($th_order==1){echo SELECTED; } ?Something1/option option value=2?php if($th_order==2){echo SELECTED; } ?Something2/option (or) 2. instead of having the ?php and ? mixed in the HTML is it better to echo/print the whole lines? Really just a matter of personal preference. If I have a mostly PHP page, I would use echo to print out chunks of HTML. If I have a mostly HTML page (or section of a page), I would use separate ?php ? sections within it. I doubt you'd notice any performance difference between the two so use whichever is easier for you to code. Larry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats more efficient? ( echo ; or ?php echo ? )
--- John W. Holmes [EMAIL PROTECTED] wrote: Use a template engine to separate your presentation from your logic. :) Isn't PHP a templating engine? :-) Chris = My Blog http://shiflett.org/ HTTP Developer's Handbook http://httphandbook.org/ RAMP Training Courses http://www.nyphp.org/ramp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats more efficient? ( echo ; or ?php echo ? )
Chris Shiflett wrote: --- John W. Holmes [EMAIL PROTECTED] wrote: Use a template engine to separate your presentation from your logic. :) Isn't PHP a templating engine? :-) Of course it is, but what's that got to do with separating presentation from logic (business logic)? Each one can be PHP code... :) Bad answer, I know, because his code could be a PHP template. I'm sure it's not, though. I just wanted to give a different answer from the many it doesn't matter answers. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats more efficient? (Conclusion)
Hey all, Thanks for clearing up my little doubt, I wanted to know if there was a major differience. John, thanks for the reply and I know it makes sense (like all your replies) but I just kind of got my feet wet with php and getting to the interesting stuff, learning while i go along of course. I dont think I can take trying to learn a who new templating language/package while doing this because I hear some of them (eg smarty) can be quite tricky sometimes for the beginner...and I get enough PHP errors so dont want to add templating errors to that :-) Just one last question, you guys can reply to this off list or on: does using a templating engine slow down pages a lot (as i have heard) or increase speed (as i have heard again) ? :-D Cheers, -Ryan Chris Shiflett wrote: --- John W. Holmes [EMAIL PROTECTED] wrote: Use a template engine to separate your presentation from your logic. :) Isn't PHP a templating engine? :-) Of course it is, but what's that got to do with separating presentation from logic (business logic)? Each one can be PHP code... :) Bad answer, I know, because his code could be a PHP template. I'm sure it's not, though. I just wanted to give a different answer from the many it doesn't matter answers. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals - www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats more efficient? (Conclusion)
Ryan A wrote: Just one last question, you guys can reply to this off list or on: does using a templating engine slow down pages a lot (as i have heard) or increase speed (as i have heard again) ? :-D Depends upon your application and the templating engine. Many options either way. In my cases, the benefit is easier code to maintain with no noticable slowdown. Good trade off for me. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats more efficient? (Conclusion)
--- Ryan A [EMAIL PROTECTED] wrote: Just one last question, you guys can reply to this off list or on: does using a templating engine slow down pages a lot (as i have heard) or increase speed (as i have heard again) ? :-D Things like Smarty are slow in terms of performance alone, yes. The tradeoff is that the design these solutions allow might make life easier for the developers. If your applications are serving ten million requests a day, Smarty is going to be problematic, but you can still overcome this with some good server-side caching (for example, is it necessary to dynamically generate a response for every request if the data isn't very volatile?). Chris = My Blog http://shiflett.org/ HTTP Developer's Handbook http://httphandbook.org/ RAMP Training Courses http://www.nyphp.org/ramp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats more efficient? (Conclusion)
* Thus wrote Ryan A ([EMAIL PROTECTED]): Hey all, Just one last question, you guys can reply to this off list or on: does using a templating engine slow down pages a lot (as i have heard) or increase speed (as i have heard again) ? :-D One thing I always try to avoid is having the template engine buffer everything while processing all the data from start to finish. In most cases a document has a top, left, content and bottom. And in standard conditions the top and left should be sent before the content is processed (which tends to take the longest to process). That way the page appears to load much quicker, than sitting there waiting for the website to respond with content while php is gathering all the html to send. Curt -- My PHP key is worn out PHP List stats since 1997: http://zirzow.dyndns.org/html/mlists/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats more efficient? (Conclusion)
Hey, thanks for replying. /* ...but you can still overcome this with some good server-side caching (for example, is it necessary to dynamically generate a response for every request if the data isn't very volatile?). */ My main pages are basically querying the databases for hosting plans depending on what the client chooses what do you suggest? and any urls for reading up on caching? Thanks, -Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats more efficient? (Conclusion)
On Tue, 2003-10-21 at 23:12, Ryan A wrote: Hey all, Thanks for clearing up my little doubt, I wanted to know if there was a major differience. John, thanks for the reply and I know it makes sense (like all your replies) but I just kind of got my feet wet with php and getting to the interesting stuff, learning while i go along of course. I dont think I can take trying to learn a who new templating language/package while doing this because I hear some of them (eg smarty) can be quite tricky sometimes for the beginner...and I get enough PHP errors so dont want to add templating errors to that :-) Just one last question, you guys can reply to this off list or on: does using a templating engine slow down pages a lot (as i have heard) or increase speed (as i have heard again) ? :-D TemplateJinn (part of InterJinn :) is a compiling template engine. You can run it from the command line (or via a compile page) to generate your site, in which case there is no overhead whatsoever since the output is embedded PHP in content. The other style is to have it automatically compile missing files that have yet to be compiled, or compile updates -- this has a small overhead while it checks dependencies at page load time. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats more efficient? ( echo ; or ?php echo ? )
I'll just on the template bandwagon, I use smarty. (http://smarty.php.net) Rolf Brusletto phpExamples.net John W. Holmes wrote: Ryan A wrote: I have an option box on a webpage and have around 10 options on it and have run into a doubt, which is more efficient to do: 1. option value=1?php if($th_order==1){echo SELECTED; } ?Something1/option option value=2?php if($th_order==2){echo SELECTED; } ?Something2/option (or) 2. instead of having the ?php and ? mixed in the HTML is it better to echo/print the whole lines? Use a template engine to separate your presentation from your logic. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Whats more efficient? (Conclusion)
What I find easy to do, Is have the top, left in a file, say we call it header.php And have the bottom html in a page called footer.php Both pages mainly contain html exept if php is required. Many sites / database the top, left is html code and never changes, There is no need to place this inside php, there is no need to slow down the engine Advantages of this is that it is kind of like a template, where you could change the header, and it take effect site wide, as well as been able to change the view by having multiple headers for people to choose their own. Hope that made sense -- Chris Kay (CK) Eleet Internet Services M: 0415 451 372 P: 02 4620 5076 F: 02 4620 7008 E: [EMAIL PROTECTED] -Original Message- From: Ryan A [mailto:[EMAIL PROTECTED] Sent: Wednesday, 22 October 2003 1:28 PM To: Chris Shiflett Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Whats more efficient? (Conclusion) Hey, thanks for replying. /* ...but you can still overcome this with some good server-side caching (for example, is it necessary to dynamically generate a response for every request if the data isn't very volatile?). */ My main pages are basically querying the databases for hosting plans depending on what the client chooses what do you suggest? and any urls for reading up on caching? Thanks, -Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats more efficient? (Conclusion)
* Thus wrote Chris Shiflett ([EMAIL PROTECTED]): --- Ryan A [EMAIL PROTECTED] wrote: Just one last question, you guys can reply to this off list or on: does using a templating engine slow down pages a lot (as i have heard) or increase speed (as i have heard again) ? :-D Things like Smarty are slow in terms of performance alone, yes. The tradeoff is that the design these solutions allow might make life easier for the developers. If your applications are serving ten million requests a day, Smarty is going to be problematic, but you can still overcome this with some good server-side caching (for example, is it necessary to dynamically generate a response for every request if the data isn't very volatile?). (more i do things like...) I usually set up a minimum of 3-4 levels of caching: . regular document, only regenerate when last modified. (much easier if apache handles this) . Session lifetime. Things that change specifically to a session. Like last-login: . Per visit. although harder to detect, things like page counters. . per request. Usually this level means no caching but in certain cases this can fine tune performance under heavy loads. So when I set up a page I'll assign it a different cache level for it and generate a fresh copy depending on the level and all the rules I set up for the level. Curt -- My PHP key is worn out PHP List stats since 1997: http://zirzow.dyndns.org/html/mlists/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats more efficient? (Conclusion)
--- Ryan A [EMAIL PROTECTED] wrote: My main pages are basically querying the databases for hosting plans depending on what the client chooses what do you suggest? and any urls for reading up on caching? Caching is a generic term, so it's tough to search for documentation about a specific type of caching. The type I am referring to is a lot like how Slashdot works. Imagine if they queried the database and generated every single page (with mod_perl) for every single request. That would take a lot of resources to sustain, right? But, they only have a handful of servers. Most of their popular content (like the front page) are generated on the server at regular intervals, not at request time. So, when you request the front page, you get a static document, even though the content is dynamic. This is why you will notice a slight delay in refreshes (number of posts, etc.). This is a good way to take control of the load on your server. If you generate a page once per minute, that page will only be generated 525,600 times (I enjoyed Rent, if you're wondering if I calculated that). Compare this to millions of generations a day, and you can see how you can significantly reduce the amount of resources you need. The site I currently operate gets 10 million hits a day, which works out to about 3.5 billion hits a year. So, I could generate content once a second, and it would still be better than doing it once per request. That wasn't the greatest explanation, but hopefully you get the idea. Chris = My Blog http://shiflett.org/ HTTP Developer's Handbook http://httphandbook.org/ RAMP Training Courses http://www.nyphp.org/ramp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats more efficient? (Conclusion)
* Thus wrote Ryan A ([EMAIL PROTECTED]): Hey Curt, Hey ryan! I put this back on the list in case people were ever so curious of the system I use. /* In most cases a document has a top, left, content and bottom. And in standard conditions the top and left should be sent before the content is processed (which tends to take the longest to process). That way the page appears to load much quicker, than sitting there waiting for the website to respond with content while php is gathering all the html to send. */ How do you do that and what engine are you using? Smarty or something differient? Actually i'm not using a template engine per se. I'm looking right now for a template engine that can do that. I havn't yet looked at smarty but I am hoping that it has those capabilities. What I DO do though, with my site that I have in my sig below . Is Basically I have one controlling file called 'html' (I set apache to run html as a php file in apache) and its logic goes something like this: I split the parts in the uri after the html into an array of items so the uri: /html/php/code/xtpl/ turns into: $parts = array ('php', 'code', 'xtpl'); So then what 'html' does is look at the first item in the list which happens to by 'php' in this case. It then includes a file from a file defined file structure called php.conf. php.conf decides a certain couple things. Like are we going to send out html, text, authentication or just redirect someplace. It Also sets variables like the page title and the like. if php.conf returns successfully 'html' now goes through and includes some common files like 'doctype.php, header.php, top.php leftside.php' And sends those to the browser. And when that is done, 'html' now includes the file 'php.php' (the first php in the filename is based off of $parts[0]). This is the muscle of the content area (in this case the php area) and does everything inside that area. using the $parts and query_string to determain what it needs to do. And finally 'html' sends out the bottom.php and footer.php /html/php aka php.php.. uses and old method of outputing stuff. It echo's all the content to the browser ..while.. /html/mlists aka mlists.php.. uses a templating system to generate the html. Which can be found in 'code' section under xtpl Nothing on this site is really production level, It is mainly a place I toy around with my ideas and stuff. HTH even the slightest bit :) Curt -- My PHP key is worn out PHP List stats since 1997: http://zirzow.dyndns.org/html/mlists/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats wrong with my code?
Stevie D Peele wrote: Can someone spot what Is wrong with my code? [ trim ] It says Line 195 which is the ? Would it matter I don't have all of these files (i.e. /includes/world.html) were uploaded yet? Yes it would matter. You need to use an editor that supports syntax highlighting. Whenever the error is on the last line, check the line before it. Like others have suggested, narrow your post down to a test case, never send attachments. -- Burhan Khalid phplist[at]meidomus[dot]com http://www.meidomus.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats wrong with my code?
Sounds like you might have an open { somewhere, PHP can't tell that you have a problem until it reaches the end of the file. Jason Burhan Khalid wrote: Stevie D Peele wrote: Can someone spot what Is wrong with my code? [ trim ] It says Line 195 which is the ? Would it matter I don't have all of these files (i.e. /includes/world.html) were uploaded yet? Yes it would matter. You need to use an editor that supports syntax highlighting. Whenever the error is on the last line, check the line before it. Like others have suggested, narrow your post down to a test case, never send attachments. -- Burhan Khalid phplist[at]meidomus[dot]com http://www.meidomus.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats wrong with my code?
Stevie -- You've already been beaten up about posting tons of code, so I won't add to that (much, anyway; DON'T, and ABSOLUTELY DON'T 'TOFU' POST!). And you've heard that you needed the ; on the last line and to correct your occasional $includes problems, so that's done. Yes, you should work on reducing the problem to its minimum cause. While a default case is not required for a switch statement, you could have the same problem by replacing all of those cases with a default -- and then you not only might find the answer yourself but you also wouldn't take so much heat for posting so much junk :-) You should also read the manual to see how to use include(). I'll bet a twinkie that /includes doesn't exist on your server (who would give a web site access to files right off of the system root directory??) but am not going to tell you any more because you should go and look it up yourself. No, this reply is more about style and tricks. Your code is long and difficult to debug because of its sheer bulk, and it needn't be. I would write your entire 200 (or 151) lines of code as ?php $page = $_GET['id'] ; if ( is_file(/includes/$page.html) ) { include(/includes/$page.html) ; } ? if you didn't need to exclude any possibilities or, much more sanely, ?php $includes = array ( home, arts, ... world) ; $page = $_GET['id'] ; if ( in_array($page,$includes) is_file(/includes/$page.html) ) { include(/includes/$page.html) ; } ? (just from the top of my head, though, without real thought for security) and in reality I'd probably not bother with the $page temp variable. Good luck, and enjoy :-) HTH HAND :-D -- David T-G * There is too much animal courage in (play) [EMAIL PROTECTED] * society and not sufficient moral courage. (work) [EMAIL PROTECTED] -- Mary Baker Eddy, Science and Health http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg! pgp0.pgp Description: PGP signature
[PHP] Whats wrong with my code?
Can someone spot what Is wrong with my code? ?php $page = $_GET['id']; switch ($page) { case home: $include = /includes/index.html; break; case arts: $include = /includes/arts.html; break; case aaexpert: $include = /includes/aaexpert.html; break; case career: $include = /includes/career.html; break; case comics: $include = /includes/comics.html; break; case graphics: $include = /includes/graphics.html; break; case computers: $include = includes/computers.html; break; case consumers: $include = /includes/consumer.html; break; case dailies: $include = /includes/dailies.html; break; case forums: $include = /includes/forums.html; break; case downloads: $include = /includes/downloads.html; break; case editors: $include = /includes/editors.html; break; case educational: $include = /includes/educational.html; break; case electronics: $include = /includes/electronics.html; break; case entertainment: $include = /includes/entertainment.html; break; case shopping: $include = /includes/shopping.html; break; case free: $include = /includes/freetime.html; break; case government: $include = /includes/government.html; break; case governments: $includes = /includes/governments.html; break; case healthnews: $includes = /includes/healthnews.html; break; case homegarden: $includes = /includes/homegarden.html; break; case homework: $includes = /includes/homework.html; break; case stuffworks: $includes = /includes/hsworks.html; break; case inthenews: $includes = /includes/inthenews.html; break; case infokiosk: $includes = /includes/kiosk.html; break; case knowledge: $includes = /includes/builder.html; break; case money: $includes = /includes/money.html; break; case yahoo: $includes = /includes/yahoo.html; break; case museums: $includes = /includes/museums.html; break; case othernews: $includes = /includes/othernews.html; break; case pictures: $includes = /includes/pictures.html; break; case politics: $includes = includes/politics.html; break; case quotations: $includes = /includes/quotes.html; break; case recreation: $includes = /includes/recreation.html; break; case reference: $includes = /includes/reference.html; break; case reviews: $includes = /includes/reviews.html; break; case search: $includes = /includes/search.html; break; case society: $include = /includes/society.html; break; case sports: $include = /includes/sportsnews.html; break; case studyhelp: $include = /includes/study.html; break; case travel: $include = /includes/travel.html; break; case USA: $includes = /includes/usa.html; break; case USNews: $includes = includes/usnews.html; break; case weather: $includes = /includes/weather.html; break; case webmaster: $includes = /includes/webmaster.html; break; case goodbad: $includes = /includes/goodbad.html; break; case world: $includes = /includes/world.html; break; } include ($include) ? It says Line 195 which is the ? Would it matter I don't have all of these files (i.e. /includes/world.html) were uploaded yet? Thanks, Stevie
Re: [PHP] Whats wrong with my code?
Stevie D Peele wrote: [snip] case world: $includes = /includes/world.html; break; } include ($include) ? It says Line 195 which is the ? Would it matter I don't have all of these files (i.e. /includes/world.html) were uploaded yet? Yeah. You need a ; at the end of the line before that. Like: include ($include); You also use $includes in a couple of the cases, like the last one. - Brad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Whats wrong with my code?
no semicolon after include ($include) hope that helps, Craig -Original Message- From: Stevie D Peele [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 16, 2003 3:11 PM To: [EMAIL PROTECTED] Subject: [PHP] Whats wrong with my code? Can someone spot what Is wrong with my code? ?php $page = $_GET['id']; switch ($page) { case home: $include = /includes/index.html; break; case arts: $include = /includes/arts.html; break; case aaexpert: $include = /includes/aaexpert.html; break; case career: $include = /includes/career.html; break; case comics: $include = /includes/comics.html; break; case graphics: $include = /includes/graphics.html; break; case computers: $include = includes/computers.html; break; case consumers: $include = /includes/consumer.html; break; case dailies: $include = /includes/dailies.html; break; case forums: $include = /includes/forums.html; break; case downloads: $include = /includes/downloads.html; break; case editors: $include = /includes/editors.html; break; case educational: $include = /includes/educational.html; break; case electronics: $include = /includes/electronics.html; break; case entertainment: $include = /includes/entertainment.html; break; case shopping: $include = /includes/shopping.html; break; case free: $include = /includes/freetime.html; break; case government: $include = /includes/government.html; break; case governments: $includes = /includes/governments.html; break; case healthnews: $includes = /includes/healthnews.html; break; case homegarden: $includes = /includes/homegarden.html; break; case homework: $includes = /includes/homework.html; break; case stuffworks: $includes = /includes/hsworks.html; break; case inthenews: $includes = /includes/inthenews.html; break; case infokiosk: $includes = /includes/kiosk.html; break; case knowledge: $includes = /includes/builder.html; break; case money: $includes = /includes/money.html; break; case yahoo: $includes = /includes/yahoo.html; break; case museums: $includes = /includes/museums.html; break; case othernews: $includes = /includes/othernews.html; break; case pictures: $includes = /includes/pictures.html; break; case politics: $includes = includes/politics.html; break; case quotations: $includes = /includes/quotes.html; break; case recreation: $includes = /includes/recreation.html; break; case reference: $includes = /includes/reference.html; break; case reviews: $includes = /includes/reviews.html; break; case search: $includes = /includes/search.html; break; case society: $include = /includes/society.html; break; case sports: $include = /includes/sportsnews.html; break; case studyhelp: $include = /includes/study.html; break; case travel: $include = /includes/travel.html; break; case USA: $includes = /includes/usa.html; break; case USNews: $includes = includes/usnews.html; break; case weather: $includes = /includes/weather.html; break; case webmaster: $includes = /includes/webmaster.html; break; case goodbad: $includes = /includes/goodbad.html; break; case world: $includes = /includes/world.html; break; } include ($include) ? It says Line 195 which is the ? Would it matter I don't have all of these files (i.e. /includes/world.html) were uploaded yet? Thanks, Stevie -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats wrong with my code?
--- Stevie D Peele [EMAIL PROTECTED] wrote: Can someone spot what Is wrong with my code? It is about 200 lines of redundant crap and posted to a mailing list? Please be considerate and try to narrow your code down to the smallest case that demonstrates the problem. We are not here to debug your code. Your code can be summarized as: ? switch ($_GET['id']) { default: $include = '/includes/index.html'; break; } include ($include); ? Does this code have the same problem in your environment? Are you saving files with \n\r line termination and trying to execute the code from a Unix environment? Chris = Become a better Web developer with the HTTP Developer's Handbook http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats wrong with my code?
Hi Stevie D Peele, you wrote: Can someone spot what Is wrong with my code? Please read your code carefully and check the writing of your variable $include! Sometimes you write $includes instead... It has to have the same name everywhere, PHP can't guess what you want ;-) What is the certain error message? And yes: if the file doesn't exists that should be included PHP will not be happy about it. PHP can't also guess what code is in the file you wanna include ;-) Regards, Matthias ?php $page = $_GET['id']; switch ($page) { case home: $include = /includes/index.html; break; case arts: $include = /includes/arts.html; break; case aaexpert: $include = /includes/aaexpert.html; break; case career: $include = /includes/career.html; break; case comics: $include = /includes/comics.html; break; case graphics: $include = /includes/graphics.html; break; case computers: $include = includes/computers.html; break; case consumers: $include = /includes/consumer.html; break; case dailies: $include = /includes/dailies.html; break; case forums: $include = /includes/forums.html; break; case downloads: $include = /includes/downloads.html; break; case editors: $include = /includes/editors.html; break; case educational: $include = /includes/educational.html; break; case electronics: $include = /includes/electronics.html; break; case entertainment: $include = /includes/entertainment.html; break; case shopping: $include = /includes/shopping.html; break; case free: $include = /includes/freetime.html; break; case government: $include = /includes/government.html; break; case governments: $includes = /includes/governments.html; break; case healthnews: $includes = /includes/healthnews.html; break; case homegarden: $includes = /includes/homegarden.html; break; case homework: $includes = /includes/homework.html; break; case stuffworks: $includes = /includes/hsworks.html; break; case inthenews: $includes = /includes/inthenews.html; break; case infokiosk: $includes = /includes/kiosk.html; break; case knowledge: $includes = /includes/builder.html; break; case money: $includes = /includes/money.html; break; case yahoo: $includes = /includes/yahoo.html; break; case museums: $includes = /includes/museums.html; break; case othernews: $includes = /includes/othernews.html; break; case pictures: $includes = /includes/pictures.html; break; case politics: $includes = includes/politics.html; break; case quotations: $includes = /includes/quotes.html; break; case recreation: $includes = /includes/recreation.html; break; case reference: $includes = /includes/reference.html; break; case reviews: $includes = /includes/reviews.html; break; case search: $includes = /includes/search.html; break; case society: $include = /includes/society.html; break; case sports: $include = /includes/sportsnews.html; break; case studyhelp: $include = /includes/study.html; break; case travel: $include = /includes/travel.html; break; case USA: $includes = /includes/usa.html; break; case USNews: $includes = includes/usnews.html; break; case weather: $includes = /includes/weather.html; break; case webmaster: $includes = /includes/webmaster.html; break; case goodbad: $includes = /includes/goodbad.html; break; case world: $includes = /includes/world.html; break; } include ($include) ? It says Line 195 which is the ? Would it matter I don't have all of these files (i.e. /includes/world.html) were uploaded yet? Thanks, Stevie -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats wrong with my code?
Your missing your default for your case switch statement And you ; at the end of line on your last include statement.. -Dan - Original Message - From: Stevie D Peele [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, September 16, 2003 4:10 PM Subject: [PHP] Whats wrong with my code? Can someone spot what Is wrong with my code? ?php $page = $_GET['id']; switch ($page) { case home: $include = /includes/index.html; break; case arts: $include = /includes/arts.html; break; case aaexpert: $include = /includes/aaexpert.html; break; case career: $include = /includes/career.html; break; case comics: $include = /includes/comics.html; break; case graphics: $include = /includes/graphics.html; break; case computers: $include = includes/computers.html; break; case consumers: $include = /includes/consumer.html; break; case dailies: $include = /includes/dailies.html; break; case forums: $include = /includes/forums.html; break; case downloads: $include = /includes/downloads.html; break; case editors: $include = /includes/editors.html; break; case educational: $include = /includes/educational.html; break; case electronics: $include = /includes/electronics.html; break; case entertainment: $include = /includes/entertainment.html; break; case shopping: $include = /includes/shopping.html; break; case free: $include = /includes/freetime.html; break; case government: $include = /includes/government.html; break; case governments: $includes = /includes/governments.html; break; case healthnews: $includes = /includes/healthnews.html; break; case homegarden: $includes = /includes/homegarden.html; break; case homework: $includes = /includes/homework.html; break; case stuffworks: $includes = /includes/hsworks.html; break; case inthenews: $includes = /includes/inthenews.html; break; case infokiosk: $includes = /includes/kiosk.html; break; case knowledge: $includes = /includes/builder.html; break; case money: $includes = /includes/money.html; break; case yahoo: $includes = /includes/yahoo.html; break; case museums: $includes = /includes/museums.html; break; case othernews: $includes = /includes/othernews.html; break; case pictures: $includes = /includes/pictures.html; break; case politics: $includes = includes/politics.html; break; case quotations: $includes = /includes/quotes.html; break; case recreation: $includes = /includes/recreation.html; break; case reference: $includes = /includes/reference.html; break; case reviews: $includes = /includes/reviews.html; break; case search: $includes = /includes/search.html; break; case society: $include = /includes/society.html; break; case sports: $include = /includes/sportsnews.html; break; case studyhelp: $include = /includes/study.html; break; case travel: $include = /includes/travel.html; break; case USA: $includes = /includes/usa.html; break; case USNews: $includes = includes/usnews.html; break; case weather: $includes = /includes/weather.html; break; case webmaster: $includes = /includes/webmaster.html; break; case goodbad: $includes = /includes/goodbad.html; break; case world: $includes = /includes/world.html; break; } include ($include) ? It says Line 195 which is the ? Would it matter I don't have all of these files (i.e. /includes/world.html) were uploaded yet? Thanks, Stevie -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats wrong with my code?
Okay, I took all the extra spaces out of my code, So it is now 151 lines. I have attached that code, instead of posting it in my mail. It says Warning: Unable to access /includes/home.html in /usr/local/psa/home/vhosts/net-riches.com/httpdocs/includes/category.php on line 150Warning: Failed opening '/includes/home.html' for inclusion (include_path='.:/usr/local/psa/apache/lib/php') in /usr/local/psa/home/vhosts/net-riches.com/httpdocs/includes/category.php on line 150 In the code, line 150 is the line where 'include ($include);' is (without the quotes)... Thanks for all your help Stevie On Tue, 16 Sep 2003 16:44:25 -0500 "Dan J. Rychlik" [EMAIL PROTECTED] writes: Your missing your default for your case switch statement And you ; at the end of line on your last include statement.. -Dan- Original Message - From: "Stevie D Peele" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, September 16, 2003 4:10 PM Subject: [PHP] Whats wrong with my code?Can someone spot what Is wrong with my code??php $page = $_GET['id']; switch ($page) { case "home": $include = "/includes/index.html"; break; case "arts": $include = "/includes/arts.html"; break; case "aaexpert": $include = "/includes/aaexpert.html"; break;case "career": $include = "/includes/career.html"; break; case "comics": $include = "/includes/comics.html"; break; case "graphics": $include = "/includes/graphics.html"; break;case "computers": $include = "includes/computers.html"; break; case "consumers": $include = "/includes/consumer.html"; break; case "dailies": $include = "/includes/dailies.html"; break;case "forums": $include = "/includes/forums.html"; break; case "downloads": $include = "/includes/downloads.html"; break; case "editors": $include = "/includes/editors.html"; break;case "educational": $include = "/includes/educational.html"; break;case "electronics": $include = "/includes/electronics.html"; break;case "entertainment": $include = "/includes/entertainment.html"; break;case "shopping": $include = "/includes/shopping.html"; break; case "free": $include = "/includes/freetime.html"; break; case "government": $include = "/includes/government.html"; break;case "governments": $includes = "/includes/governments.html"; break;case "healthnews": $includes = "/includes/healthnews.html"; break; case "homegarden": $includes = "/includes/homegarden.html"; break;case "homework": $includes = "/includes/homework.html"; break; case "stuffworks": $includes = "/includes/hsworks.html"; break; case "inthenews": $includes = "/includes/inthenews.html"; break;case "infokiosk": $includes = "/includes/kiosk.html"; break; case "knowledge": $includes = "/includes/builder.html"; break; case "money": $includes = "/includes/money.html"; break;case "yahoo": $includes = "/includes/yahoo.html"; break; case "museums": $includes = "/includes/museums.html"; break; case "othernews": $includes = "/includes/othernews.html"; break;case "pictures": $includes = "/includes/pictures.html"; break; case "politics": $includes = "includes/politics.html"; break; case "quotations": $includes = "/includes/quotes.html"; break; case "recreation": $includes = "/includes/recreation.html"; break;case "reference": $includes = "/includes/reference.html"; break; case "reviews": $includes = "/includes/reviews.html"; break; case "search": $includes = "/includes/search.html"; break;case "society": $include = "/includes/society.html"; break; case "sports": $include = "/includes/sportsnews.html"; break; case "studyhelp": $include = "/includes/study.html"; break;case "travel": $include = "/includes/travel.html"; break; case "USA": $includes = "/includes/usa.html"; break; case "USNews": $includes = "includes/usnews.html"; break;case "weather": $includes = "/includes/weather.html"; break; case "webmaster": $includes = "/includes/webmaster.html"; break; case "goodbad": $includes = "/includes/goodbad.html"; break;case "world": $includes = "/includes/world.html"; break; } include ($include) ? It says Line 195 which is the ? Would it matter I don't have all of these files (i.e. /includes/world.html) were uploaded yet? Thanks,Stevie -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Whats wrong with my code?
Stevie D Peele mailto:[EMAIL PROTECTED] on Tuesday, September 16, 2003 4:08 PM said: Okay, I took all the extra spaces out of my code, So it is now 151 lines. I have attached that code, instead of posting it in my mail. It says Attachments are even worse. I'll never open an attachment I receive on a list. 1. Don't post tons of code 2. Don't send attachments. 3. Trim your posts! Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats wrong with my code?
--- Stevie D Peele [EMAIL PROTECTED] wrote: Okay, I took all the extra spaces out of my code, So it is now 151 lines. I appreciate you trying to trim down your code. However, it isn't the whitespace that is superfluous. You now have 151 lines that are mostly repeating the same basic assignment; it's the same problem. It makes it look as if you have not put forth any effort to try and solve this problem. Remember that the people who answer questions on this list do so voluntarily and can't afford to waste a lot of time searching through all of your code to find a missing semicolon or something of the like. As I mentioned earlier, this list is not the place to have someone debug your code. So, when you have a problem with your code, you will find people much more willing to help if you can reproduce the problem in a very small sample. In many cases, you may also discover your own problem and not even need to ask. I have attached that code, instead of posting it in my mail. I generally delete anything posted to this list with an attachment. I'm sure many people do. Also, because you quoted the entire message from before, you have all of your 200 lines of code in the email, and then you attach the whole thing again. That's even worse. Warning: Unable to access /includes/home.html in /usr/local/psa/home/vhosts/net-riches.com/httpdocs/includes/category.php on line 150 Warning: Failed opening '/includes/home.html' for inclusion (include_path='.:/usr/local/psa/apache/lib/php') in /usr/local/psa/home/vhosts/net-riches.com/httpdocs/includes/category.php on line 150 I bet you could reproduce this problem with the following code: include('/includes/home.html'); That 1 line demonstrates the same problem that your 151 lines do. Have you looked to see if /includes/home.html exists? Hope that helps. Chris = Become a better Web developer with the HTTP Developer's Handbook http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Whats wrong?
Whats wrong with this title?php echo Thank You, $senderemail; ?/title where $senderemail = $_POST['from']; It doesnt It only echos thank you. Why?
Re: [PHP] Whats wrong?
Hey, Just touched it up a bit but its working: title ?php $senderemail = $_POST['from']; print Thank You, $senderemail; ? /title This should come before: $senderemail = $_POST['from']; not after this: print Thank You, $senderemail; plus I'm guessing that either your form is sending $senderemail or that you are getting via a $_GET you have to post $from not $senderemail. If you change the above to a $_GET this will work YourFileName.php?from=Ryan Cheers, -Ryan We will slaughter you all! - The Iraqi (Dis)information ministers site http://MrSahaf.com - Original Message - From: Stevie D Peele [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, September 13, 2003 2:45 PM Subject: [PHP] Whats wrong? Whats wrong with this title?php echo Thank You, $senderemail; ?/title where $senderemail = $_POST['from']; It doesnt It only echos thank you. Why? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats wrong?
Try this title?echo Thank You, .$_POST['from']; ?/title - Sid On Sat, 13 Sep 2003 08:45:16 -0400, Stevie D Peele wrote: Whats wrong with this title?php echo Thank You, $senderemail; ?/title where $senderemail = $_POST['from']; It doesnt It only echos thank you. Why? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Whats wrong?
or even: title?=(Thank you, $_POST[from])?/title :P - -Oorspronkelijk bericht- - Van: Sid [mailto:[EMAIL PROTECTED] - Verzonden: zondag 14 september 2003 3:43 - Aan: Stevie D Peele; [EMAIL PROTECTED] - Onderwerp: Re: [PHP] Whats wrong? - - - Try this - - title?echo Thank You, .$_POST['from']; ?/title - - - Sid - - On Sat, 13 Sep 2003 08:45:16 -0400, Stevie D Peele wrote: - Whats wrong with this - - - title?php echo Thank You, $senderemail; ?/title - - - where - - - $senderemail = $_POST['from']; - - - It doesnt It only echos thank you. - - - Why? - - -- - PHP General Mailing List (http://www.php.net/) - To unsubscribe, visit: http://www.php.net/unsub.php - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] whats this!!!!
read: http://php.weblogs.com/ -- Chris Edwards Web Application Developer Outer Banks Internet, Inc. 252-441-6698 [EMAIL PROTECTED] http://www.OuterBanksInternet.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] whats this!!!!
This has to be an April Fools joke.. -Original Message- From: Chris Edwards [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 01, 2003 2:36 PM To: [EMAIL PROTECTED] Subject: [PHP] whats this read: http://php.weblogs.com/ -- Chris Edwards Web Application Developer Outer Banks Internet, Inc. 252-441-6698 [EMAIL PROTECTED] http://www.OuterBanksInternet.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] whats this!!!!
the world has come to an end :-P - Original Message - From: Chris Edwards [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, April 01, 2003 3:35 PM Subject: [PHP] whats this read: http://php.weblogs.com/ -- Chris Edwards Web Application Developer Outer Banks Internet, Inc. 252-441-6698 [EMAIL PROTECTED] http://www.OuterBanksInternet.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] whats this!!!!
It's an April Fools joke ... nicely done too. Chris Edwards wrote: read: http://php.weblogs.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Whats the deal with HotScripts.com?
How many of you have listed premium (not free) scripts on HotScripts? Have you ever had ranking problems? Everything was going great for me, I had 12 scripts listed, all on the tops of the categories, and then poof! Now all my scripts are on the last page, I get zero traffic from that site now, and I can't figure out what the hell happened! I've even submitted two more scripts to them that never showed up. Do any of you know how it works?! Or have experienced this problem and know why it happened? It's really killin me traffic-wise. I've even gone so far as saying screw ya guys and set up my own! If you'd like to check it out, the links are below. =) ~ Tim -- Submit your PHP or Perl Script to the newest Script Repository on the web. http://www.nukedweb.com/ The Webmaster's Board - http://www.nukedweb.com/board/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] whats wrong with this?
I just cant seem to work out why this doesn't work. My PHP book doesn't explain if statements very well so i have no idea if i am breaking a rule. $system_day = date(j); for($day = 1; $day 32; $day++){ if($day = $system_day){ echo match!; } else{ echo no match; } } the problem i am experiencing is that it seems the if statement is setting the $day value to equal $system_day instead of comparing their values if i add echo Day: . $day . System_day: . $system_day; before and after the if statement then the first result is something like Day: 1 System_day: 29 after the if statement has executed the result is Day: 29 System_day: 29 so you see, instead of if comparing $day to $system_day it is making $day equal to $system_day. any ideas why and how to fix this? help is most appreciated :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] whats wrong with this?
you need to use == instead of = == is used when comparing values (i.e. is this == to that) = is used to set something's value (i.e. this = that) -chip -Original Message- From: Chris Barnes [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 28, 2002 11:12 AM To: Php-General (E-mail) Subject: [PHP] whats wrong with this? I just cant seem to work out why this doesn't work. My PHP book doesn't explain if statements very well so i have no idea if i am breaking a rule. $system_day = date(j); for($day = 1; $day 32; $day++){ if($day = $system_day){ echo match!; } else{ echo no match; } } the problem i am experiencing is that it seems the if statement is setting the $day value to equal $system_day instead of comparing their values if i add echo Day: . $day . System_day: . $system_day; before and after the if statement then the first result is something like Day: 1 System_day: 29 after the if statement has executed the result is Day: 29 System_day: 29 so you see, instead of if comparing $day to $system_day it is making $day equal to $system_day. any ideas why and how to fix this? help is most appreciated :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] whats wrong with this?
A single = will assing a value, even inside an if statement A double = (ie ==) will perform a comparison between 2 values, returning true if they evaluate to the same value, false otherwise A triple = (===) will do the same as ==, but also check that the types of the 2 variables match. Check out the PHP manual - http://www.php.net/manual/ - for more info HTH, Richy == Richard Black Systems Programmer, DataVisibility Ltd - http://www.datavisibility.com Tel: 0141 435 3504 Email: [EMAIL PROTECTED] -Original Message- From: Chris Barnes [mailto:[EMAIL PROTECTED]] Sent: 28 August 2002 17:12 To: Php-General (E-mail) Subject: [PHP] whats wrong with this? I just cant seem to work out why this doesn't work. My PHP book doesn't explain if statements very well so i have no idea if i am breaking a rule. $system_day = date(j); for($day = 1; $day 32; $day++){ if($day = $system_day){ echo match!; } else{ echo no match; } } the problem i am experiencing is that it seems the if statement is setting the $day value to equal $system_day instead of comparing their values if i add echo Day: . $day . System_day: . $system_day; before and after the if statement then the first result is something like Day: 1 System_day: 29 after the if statement has executed the result is Day: 29 System_day: 29 so you see, instead of if comparing $day to $system_day it is making $day equal to $system_day. any ideas why and how to fix this? help is most appreciated :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] whats wrong with this?
(1) for($day = 1; $day 32; $day++){ (2) if($day = $system_day){ (3) echo match!; (4) } . . . Easy enough. One of those things the programmer may not spot, but a casual observer might. In line #2, you have a single =. A comparative = is a double equal (==). The line should read if($day == $system_day){. A single equal will assign the value; a double equal will compare the two. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] whats wrong with this function
whats wrong with this. it's getting stuck somewhere function urls_clickable($string) { for($n=0; $n strlen($string); $n++) { if(strtolower($string[$n]) == 'h') { if(!strcmp(http://;, strtolower($string[$n]) . strtolower($string[$n+1]) . strtolower($string[$n+2]) . strtolower($string[$n+3]) . $string[$n+4] . $string[$n+5] . $string[$n+6])) { $startpos = $n; while($n strlen($string) eregi([a-z0-9\.\:\?\/\~\-\_\\=\%\+\'\], $string[$n])) $n++; if(!eregi([a-z0-9], $string[$n-1])) $n--; $link = substr($string, $startpos, ($n-$startpos)); $link = $link; $string_tmp = $string; $string = substr($string_tmp, 0, $startpos); $string .= a href=\$link\ target=\_blank\$link/a; $string .= substr($string_tmp, $n, strlen($string_tmp)); $n = $n + 15; } } } return $string; } $text = http://www.somewhere.org brbr; echo urls_clickable($text);
Re: [PHP] whats wrong with this function
Yes, your problem is it doesn't work. HTH, ---John Holmes... PS: Think that's a worthless answer? Well...same for your question... - Original Message - From: Adrian Murphy [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, July 03, 2002 8:47 AM Subject: [PHP] whats wrong with this function whats wrong with this. it's getting stuck somewhere function urls_clickable($string) { for($n=0; $n strlen($string); $n++) { if(strtolower($string[$n]) == 'h') { if(!strcmp(http://;, strtolower($string[$n]) . strtolower($string[$n+1]) . strtolower($string[$n+2]) . strtolower($string[$n+3]) . $string[$n+4] . $string[$n+5] . $string[$n+6])) { $startpos = $n; while($n strlen($string) eregi([a-z0-9\.\:\?\/\~\-\_\\=\%\+\'\], $string[$n])) $n++; if(!eregi([a-z0-9], $string[$n-1])) $n--; $link = substr($string, $startpos, ($n-$startpos)); $link = $link; $string_tmp = $string; $string = substr($string_tmp, 0, $startpos); $string .= a href=\$link\ target=\_blank\$link/a; $string .= substr($string_tmp, $n, strlen($string_tmp)); $n = $n + 15; } } } return $string; } $text = http://www.somewhere.org brbr; echo urls_clickable($text); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] whats wrong with this function
On Wednesday 03 July 2002 20:47, Adrian Murphy wrote: whats wrong with this. it's getting stuck somewhere Stick in some echo statements at strategic points in the loops to find out _where_ it is getting stuck. function urls_clickable($string) { for($n=0; $n strlen($string); $n++) { if(strtolower($string[$n]) == 'h') { if(!strcmp(http://;, strtolower($string[$n]) . strtolower($string[$n+1]) . strtolower($string[$n+2]) . strtolower($string[$n+3]) . $string[$n+4] . $string[$n+5] . $string[$n+6])) { $startpos = $n; while($n strlen($string) eregi([a-z0-9\.\:\?\/\~\-\_\\=\%\+\'\], $string[$n])) $n++; if(!eregi([a-z0-9], $string[$n-1])) $n--; $link = substr($string, $startpos, ($n-$startpos)); $link = $link; $string_tmp = $string; $string = substr($string_tmp, 0, $startpos); $string .= a href=\$link\ target=\_blank\$link/a; $string .= substr($string_tmp, $n, strlen($string_tmp)); $n = $n + 15; } } } return $string; } $text = http://www.somewhere.org brbr; echo urls_clickable($text); -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* System going down at 1:45 this afternoon for disk crashing. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] whats wrong with this function
relax friend.i was just asking - Original Message - From: 1LT John W. Holmes [EMAIL PROTECTED] To: Adrian Murphy [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, July 03, 2002 2:08 PM Subject: Re: [PHP] whats wrong with this function Yes, your problem is it doesn't work. HTH, ---John Holmes... PS: Think that's a worthless answer? Well...same for your question... - Original Message - From: Adrian Murphy [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, July 03, 2002 8:47 AM Subject: [PHP] whats wrong with this function whats wrong with this. it's getting stuck somewhere function urls_clickable($string) { for($n=0; $n strlen($string); $n++) { if(strtolower($string[$n]) == 'h') { if(!strcmp(http://;, strtolower($string[$n]) . strtolower($string[$n+1]) . strtolower($string[$n+2]) . strtolower($string[$n+3]) . $string[$n+4] . $string[$n+5] . $string[$n+6])) { $startpos = $n; while($n strlen($string) eregi([a-z0-9\.\:\?\/\~\-\_\\=\%\+\'\], $string[$n])) $n++; if(!eregi([a-z0-9], $string[$n-1])) $n--; $link = substr($string, $startpos, ($n-$startpos)); $link = $link; $string_tmp = $string; $string = substr($string_tmp, 0, $startpos); $string .= a href=\$link\ target=\_blank\$link/a; $string .= substr($string_tmp, $n, strlen($string_tmp)); $n = $n + 15; } } } return $string; } $text = http://www.somewhere.org brbr; echo urls_clickable($text); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] whats wrong with this function
On Wednesday, July 3, 2002, 1:47:05 PM, Adrian Murphy wrote: whats wrong with this. it's getting stuck somewhere Somewhere isn't very helpful. When asking for help be sure to include as much information as possilble. Laying out your code so the structure can be seen... ?php function urls_clickable($string) { for($n=0; $n strlen($string); $n++) { if(strtolower($string[$n]) == 'h') { if(!strcmp(http://;, strtolower($string[$n]) . strtolower($string[$n+1]) . strtolower($string[$n+2]) . strtolower($string[$n+3]) . $string[$n+4] . $string[$n+5] . $string[$n+6])) { $startpos = $n; while($n strlen($string) eregi([a-z0-9\.\:\?\/\~\-\_\\=\%\+\'\], $string[$n])) $n++; if(!eregi([a-z0-9], $string[$n-1])) $n--; $link = substr($string, $startpos, ($n-$startpos)); $link = $link; $string_tmp = $string; $string = substr($string_tmp, 0, $startpos); $string .= a href=\$link\ target=\_blank\$link/a; $string .= substr($string_tmp, $n, strlen($string_tmp)); $n = $n + 15; } } } return $string; } $text = http://www.somewhere.org brbr; echo urls_clickable($text); ? It's getting stuck because you're moving the goalposts. It's a very bad idea to base a loop on a variable that is changed within the loop. I suggest you loop through one string while building a second string as the return value. On the other hand, I seem to remember seeing a regex posted on this list recently that did exactly this. I suggest you search the archives for it because it would save you a lot of hassle. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] whats wrong with this function
thnks, i didn't write the function so i've now replaced it with something better. - Original Message - From: Stuart Dallas [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, July 03, 2002 2:30 PM Subject: Re: [PHP] whats wrong with this function On Wednesday, July 3, 2002, 1:47:05 PM, Adrian Murphy wrote: whats wrong with this. it's getting stuck somewhere Somewhere isn't very helpful. When asking for help be sure to include as much information as possilble. Laying out your code so the structure can be seen... ?php function urls_clickable($string) { for($n=0; $n strlen($string); $n++) { if(strtolower($string[$n]) == 'h') { if(!strcmp(http://;, strtolower($string[$n]) . strtolower($string[$n+1]) . strtolower($string[$n+2]) . strtolower($string[$n+3]) . $string[$n+4] . $string[$n+5] . $string[$n+6])) { $startpos = $n; while($n strlen($string) eregi([a-z0-9\.\:\?\/\~\-\_\\=\%\+\'\], $string[$n])) $n++; if(!eregi([a-z0-9], $string[$n-1])) $n--; $link = substr($string, $startpos, ($n-$startpos)); $link = $link; $string_tmp = $string; $string = substr($string_tmp, 0, $startpos); $string .= a href=\$link\ target=\_blank\$link/a; $string .= substr($string_tmp, $n, strlen($string_tmp)); $n = $n + 15; } } } return $string; } $text = http://www.somewhere.org brbr; echo urls_clickable($text); ? It's getting stuck because you're moving the goalposts. It's a very bad idea to base a loop on a variable that is changed within the loop. I suggest you loop through one string while building a second string as the return value. On the other hand, I seem to remember seeing a regex posted on this list recently that did exactly this. I suggest you search the archives for it because it would save you a lot of hassle. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Whats Function like response.redirect
what function in PHP like response.redirect http://www.detik.com; in ASP ? Roy Daniel , ST IT Developer System - PT BERCA COMPUTEL My E-mail : [EMAIL PROTECTED] and : [EMAIL PROTECTED] / [EMAIL PROTECTED] My ICQNumber : # 103507581 My Phone Cell : 0816-1192832 My Web site: http://www22.brinkster.com/roydaniel/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats Function like response.redirect
header(Location: http://www.detik.com;); www.php.net/header Read the manual page... ---John Holmes... - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, May 21, 2002 5:12 AM Subject: [PHP] Whats Function like response.redirect what function in PHP like response.redirect http://www.detik.com; in ASP ? Roy Daniel , ST IT Developer System - PT BERCA COMPUTEL My E-mail : [EMAIL PROTECTED] and : [EMAIL PROTECTED] / [EMAIL PROTECTED] My ICQNumber : # 103507581 My Phone Cell : 0816-1192832 My Web site: http://www22.brinkster.com/roydaniel/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Whats Function like response.redirect
Hi Roy, what function in PHP like response.redirect http://www.detik.com; in ASP? header (Location: http://www.detik.com/;); HTH Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Whats the best way?
Gerard: On Sat, May 18, 2002 at 12:38:37PM -0400, Gerard Samuel wrote: HTTP_ACCEPT_LANGUAGE is 'en-us, en;q=0.75, nl;q=0.50, fr;q=0.25' $foo = split(',', $_SERVER['HTTP_ACCEPT_LANGUAGE'] ); foreach ($foo as $bar) { $string = preg_replace(/([a-z]{2})|(-[a-z]{2})|(;q=[0-9]\.[0-9]{2})/i, $1, trim($bar)); $array[] = $string; } The replacements supposed to be \\1 rather than $1. But, $1 might work anyway. Also, you can just assign the fuction to $array[], rather than assigning it to $string and then $string to $array[]. But, even better, use preg_match_all: http://www.php.net/manual/en/function.preg-match-all.php That'll eliminate the need to split() first. Just put the stuff you want to keep, ie the two lettered language codes, in subpatterns () and keep the rest of the stuff out of sub patterns. Enjoy, --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Whats the best way?
Well this is the first time actually creating a regex. It works, but was wondering if the regex was created properly. HTTP_ACCEPT_LANGUAGE is 'en-us, en;q=0.75, nl;q=0.50, fr;q=0.25' /* Explode the browser report to get each language */ $foo = split(',', $_SERVER['HTTP_ACCEPT_LANGUAGE'] ); /* Perform a regex to get the first 2 letters for each language reported */ foreach ($foo as $bar) { $string = preg_replace(/([a-z]{2})|(-[a-z]{2})|(;q=[0-9]\.[0-9]{2})/i, $1, trim($bar)); $array[] = $string; } Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Whats wrong with getimagesize ??
Hi guys, I am really stuck with this prob. Anyhow php can't read imagefiles after password protecting the site with htaccess. The file exists, the application works (after deleting the htaccess function), the path is ok. copy and pasting the url into the browserwindow returns the image. So whats wrong?? I am getting following erromsg: Warning: getimagesize: Unable to open 'http://testserver/subapp_gallery/app_data/ca/pictures/www.globosapiens.net- -canada--northwest-territories--id=239.jpg' for reading does anybody have any idea? I would really apreciate it, this gives me a real headache. Thanx for any help, Andy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php