Re: [PHP] Date Question
on the fly: use date_format function in select statement, format should be a string like %d%m%y not sure about it check on manual. hth adriano 2006/3/17, Tom Chubb [EMAIL PROTECTED]: Please can you help me. I've created a page where problems are posted into a database and I am using the datetime format in MySQL and trying to find the best way to display it in the 17/03/06 format. I've found a way of doing it (so you don't think I haven't googled, RTFM) but don't think it's the best way. Any help would be appreciated. (Current Code:) ?php $datestr = $row_rsSnags['date']; $arr1 = str_split($datestr, 2); echo $arr1 [2]; echo /; echo $arr1 [1]; echo /; echo $arr1 [0]; // echo $row_rsSnags['date']; ?
Re: [PHP] Str to Int
well I don't well understand the problem hope these two snippets can solve your problem: i tested them seems fine file 1 form.php html head meta http-equiv=Content-Language content=it meta http-equiv=Content-Type content=text/html; charset=windows-1252 titleenter tour code/title /head body pnbsp;/p penter tour code/p form method=POST action=get_card.php table border=1 width=47% id=table1 tr td width=186user/td tdinput type=text name=txt_user size=20/td /tr tr td width=186code/td tdinput type=text name=txt_id size=20/td /tr tr td colspan=2 p align=centerinput type=submit value=Invia name=B1 input type=reset value=Reimposta name=B2/td /tr /table p dir=ltrnbsp;/p /form pnbsp;/p /body /html file 2 -- get_card.php html head meta http-equiv=Content-Type content=text/html; charset=windows-1252 titleNuova pagina 1/title /head body ?php print string value:::.$_POST['txt_id'].br; $int_id=intval(trim($_POST['txt_id'])); print integer value:::$int_id.br; print type returned:.gettype($int_id).br; ? /body /html 2006/1/20, Ron Eggler (Paykiosks) [EMAIL PROTECTED]: Hi, I need to do a type cast from string to int in folllowing code: [php] getPIN cardID='.intval(trim($cardID)).' quantity=1 / [/php] I need $cardID have converted to int. I thought it should work that way but it does not! But it's working if I'm putting [php] getPIN cardID=180 quantity=1 / [/php] in there. I got card ID as a var that is passed as get like: [php] $cardID = $HTTP_GET_VARS[cardID]; [/php] Can anyone help me in that issue? Thank you! __ Ron Eggler Intern 866-999-4179 www.paykiosks.net
Re: [PHP] insert to DB
pls could you point out which instruction should insert record in db thanks... 2005/12/18, Anasta [EMAIL PROTECTED]: It just wont insert new data into DB--any ideas as i have gone over and over. ? mysql_connect(localhost,anasta,silteren); mysql_select_db(mytipperv1); if(!isset($cmd)) { $result = mysql_query(select * from leaderboard order by ID); while($r=mysql_fetch_array($result)) { //grab the title and the rating of the entry $id=$r[ID];//take out the id $Name=$r[Name];//take out the Name $Rating=$r[Rating];//take out the Rating echo $Name a href='edit.php?cmd=editID=$id' Edit/abr; } } ? ? if($_GET[cmd]==edit || $_POST[cmd]==edit) { if (!isset($_POST[submit])) { $id = $_GET[ID]; $sql = SELECT * FROM leaderboard WHERE ID=$id; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); ? form action=../craigs_DB/edit.php method=post input type=hidden name=ID value=?php echo $myrow[ID] ? Name: INPUT TYPE=TEXT NAME=Name VALUE=?php echo $myrow[Name] ? SIZE=15 maxlength=15brbr Rating: INPUT TYPE=TEXT NAME=Rating VALUE=?php echo $myrow[Rating] ? SIZE=3 maxlength=3brbr input type=hidden name=cmd value=edit input type=submit name=submit value=submit /form ? } ? ? if ($_POST[$submit]) { $Name = $_POST[Name]; $Rating = $_POST[Rating]; $sql = UPDATE leaderboard SET Name='$Name', Rating='$Rating' WHERE ID=$id; //replace news with your table name above $result = mysql_query($sql); echo Thank you! Information updated.; } } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with the copy command...
just put the wrong lines in a file and run it from the shell with php -f you should get more info about what's going wrong hyh ciao! 2005/12/16, Tim Meader [EMAIL PROTECTED]: What difference are you seeing in the files I give in the example? Are they not identical paths? Thanks. Hristo Yankov wrote: The two examples you give are not the same? I see different files. Please, doublecheck. --- Tim Meader [EMAIL PROTECTED] wrote: Okay, this seems like a ridiculously easy question which shouldn't even need asking, but I'm having trouble getting the builtin copy command to work properly. It seems to work fine as long as I feed it a full constant string path for each argument (ie - in the form /the/path/to/the/file). However, if I try to feed it two variables as the arguments, it craps out somewhere along the line. Here are the two different sets of calls I'm making: These two work perfectly: copy(/usr/local/apache/htdocs/ipreg2/crons/regservice_rep/snapshot.baseline, /usr/local/apache/htdocs/ipreg2/crons/regservice_rep/snapshot.baseline.bak) ; copy(/usr/local/apache/htdocs/ipreg2/crons/regservice_rep/lastrun.timestamp, /usr/local/apache/htdocs/ipreg2/crons/regservice_rep/lastrun.timestamp.bak); These two fail: $l_stLastRun = /usr/local/apache/htdocs/ipreg2/crons/regservice_rep/lastrun.timestamp; $l_stSnapshotBase = /usr/local/apache/htdocs/ipreg2/crons/regservice_rep/snapshot.baseline; copy($l_stSnapshotBase, $l_stSnapshotBase..bak); copy($l_stLastRun, $l_stLastRun..bak); Can anyone offer any insight on what the problem might be with this? The unlink function seems to accept the variable inputs with absolutely no problem, so I can't understand the discrepancy between the two. Thanks in advance. Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php === Hristo Yankov, Developer at Portellus, Inc. ICQ - 191445567 Yahoo! - yankov_hristo __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- Tim [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Declaring arrays? Good practice?
imho I agree always declare all kinds of variables before using in the specific situation you have to consider that you are using two different variables rthe $foo inside the function and the $foo outside the function I think its' correct to declar both, imho you should use different names if you want to check all variables are properly declared you can turn on error reporting for all during development and wwitch it off again in production 2005/12/14, Michael Hulse [EMAIL PROTECTED]: Sorry if this question sounds noobish: $foo = array(); // Declare first, good practice. $foo = array('one', 'two', 'three'); Using above as example, is it good to always declare the array first? I usually/always declare my arrays first, but sometimes I get a bit confused... for example: function give_foo() { $the_foo = array(); // Declare first, good practice. $the_foo = array('one', 'two', 'three'); // Do some stuff here... return $the_foo; } $foo = give_foo(); // Declare $foo also? So, should I declare $foo as array and then give it the value of the function? Example: $foo = array(); // Declare first, good practice. $foo = give_foo(); That seems kinda redundant. Thoughts? Sorry if this is a stupid question... I am self-taught, and I am trying to shake all my bad coding habits. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] question
server and client are logical definitions, in the environment here normally discussed these are meanings server : a pc (cpu) where a web server is running (usually apache) and php is parsing pages served to the client client: is a pc (cpu), normally remote, who is asking for a page to the server is it enough, do I well understand the question ? cheers. 2005/11/27, Stephen Leaf [EMAIL PROTECTED]: On Sunday 27 November 2005 12:34, cheeto borje wrote: Hello, I wanna ask you about : 1. When you say server, does it mean my CPU? By CPU I assume you mean your computer and not the Central Processing Unit. being a CPU is the small chip inside your computer attached into the motherboard which every instruction gets sent to for processing. And yes a server is a computer. Technically what makes a server a server is the fact that it serves something. Take any computer out there say a 133MHz install a web server on it (apache) and boom you now have a server that serves webpages. 2. Do i have to buy a seperate server besides my computer CPU? No but generally it's recommended if your wanting good server performance and a unshakable uptime. By using the computer for every day you work you expose the server/computer to performance hits and possible program crashes that may also affect the underlaying OS. 3. Can i use the software to multiple web-domain that i will create and launch online? I assume you mean you want to be able to host websites from multiple domains and the answer is yes. Apache has that functionality and is well documented all over the place. 4. How will i be able store those data coming from the threads? You store them using those threads however you feel like it? I guess I don't really understand this question. 5. Can you provide a remote server to serve as a database? Php has support to connect to remote database servers yes. you may also run the database server locally to the server. I personally recommend PostgreSQL. Others I'm sure will recommend MySQL. Hoping for your kind response. Thank you. LOUIE - Yahoo! Music Unlimited - Access over 1 million songs. Try it free. -- 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] Re: $_GET and $_POST arrays not working
could you give us all source lines, just cut and paste ? hy ag. 2005/11/26, Matt Monaco [EMAIL PROTECTED]: Somewhat, but its what you need to do for the post and get arrays to work. What you need to do is make sure check the values in the global variables before you use them. For example if on one page you have a form for a user signup and input type=text name='userName' on the next page $_POST['userName'] should be checked for things like quotes and other characters that will alter your SQL statement before you actually INSERT that value into your table. Unknown Unknown [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Doesn't that cause security problems? On 11/25/05, Matt Monaco [EMAIL PROTECTED] wrote: In php.ini (most likely located in your windows directory) look for the globals section and turn register_globals = on Matt Unknown Unknown [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello everyone, i am running PHP 5 on Windows XP Pro SP2, my $_GET and $_POST arrays do not seem to be working, I am Sure I am spelling them right, but i keep getting the errors: ** *Notice*: Undefined index: Username in * D:\Apache\Apache(re)\Apache2\htdocs\RegisterP.php* on line *3* *Notice*: Undefined index: Password in * D:\Apache\Apache(re)\Apache2\htdocs\RegisterP.php* on line *4* *Notice*: Undefined index: EMail in * D:\Apache\Apache(re)\Apache2\htdocs\RegisterP.php* on line *5* Is this a problem with configuration or is there a bug in PHP, thanks in advance -- 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ignore: this is a test
bye -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php session in ie
to be redirected to login must have at least one of ( if(!isset($_SESSION['student_username']) !isset($_SESSION['student_password'])) ) not set, which one (or both) fail under i.e. ??? hth ag. 2005/11/11, sunaram patir [EMAIL PROTECTED]: Hi, i am having problem with internet explorer. i am working on a project on building a website where i need to keep track of the users i.e. i use a login system in there in short. with the following code i check whether the user is logged in or not. ?php session_start(); $_SESSION['myurl']=$_SERVER['PHP_SELF']; if(!isset($_SESSION['student_username']) !isset($_SESSION['student_password'])) header(Location: login.php); ? if the user is not logged in, it redirects to the login page login.php as is shown in the above code. now the user is allowed to log in through the following code: ?php session_cache_limiter('private_no_expire'); session_set_cookie_params(0,/,schools.zenrays.com); session_start(); if(isset($_POST['submit'])){ include(../database.inc); $login=trim($_POST['login']); $pass=trim($_POST['pass']); $Effectivelogin=strtoupper($login); $auth=false; $connection=mysql_connect($host,$user,$password); mysql_select_db($database,$connection); $query=SELECT password FROM students WHERE userID='$Effectivelogin'; $result=mysql_query($query); if(mysql_num_rows($result)){ while($row=mysql_fetch_array($result)) { if($row[0]!=$pass) echo (Wrong Username/Password!); else $auth=true; } } if($auth){ $_SESSION[student_username]=$Effectivelogin; $_SESSION[student_password]=$pass; if(isset($_SESSION['myurl'])) header(Location: http://schools.zenrays.com.$_SESSION['myurl']); else header(Location: http://schools.zenrays.com/students;); } } ? html head titleUser Authentication/title /head body form method=post LoginID: input type=text name=loginbr Password: input type=password name=passbr input type=submit name=submit value=Login /form /body /html then the user is redirected back to the page he visited. it workd fine in firefox and msn explorer. in internet explorer, when i visit to a link in any page it asks for the login details again. could anyone please help me out?! -- 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] convert array to HTML GET request
if i understand well you need to get an array from html post if you use the same name for your html fields you automatically have an array in $_POST eg input type=text name=myfield value=field_1 input type=text name=myfield value=field_2 you'll get the array ar_myfield = $_POS['myfield'] you should achieve the same result using myfield[key] in the name of html hyh by ag. 2005/10/2, Martin van den Berg [EMAIL PROTECTED]: Newbe question: How does one convert an array into a HTML GET request easely? Are there any standard functions? Same for HTML POST requests. Thanks, Martin. -- 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] creating a shopping cart.
you need a db based approach, just setup a couple of tables in mysql items table one record per item current cart table one record per each item added to cart with unique session id order table one record per each item ordered with unique order id you'll transfer records here from current cart when user checkout hope help adriano 2005/10/1, Emil Novak [EMAIL PROTECTED]: Hi! The best way is already presented in PHP manual: http://www.php.net/oop . In this example you create an object, which you can - naturaly pass over Session, etc. If you'll use OOP (Object-Oriented Programming), it is preffered in PHP5 to use OOP5 (OOP for PHP5). You can find details on http://www.php.net/oop5 . Emil NOVAK, Slovenia, EU -- 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] creating a shopping cart.
depends imho there are a lot of reasons to use a db approach, unless you are working on a really poor system, first is persistent in any case you'll never lost an item is the only way to make your software scalable to hundreds of users, using array you have everything in memory, you must set up your persistent system unless you trust a lot sessions that basically is a file on disk but as everything it's up to you I really suggest you to go on db I can't see any disadvantage bye 2005/10/1, Robert Cummings [EMAIL PROTECTED]: On Sat, 2005-10-01 at 11:41, adriano ghezzi wrote: you need a db based approach, just setup a couple of tables in mysql items table one record per item current cart table one record per each item added to cart with unique session id order table one record per each item ordered with unique order id you'll transfer records here from current cart when user checkout A DB approach is nice, but not necessary. Serialization of a shopping cart array that contains the contents of the cart is sufficient. While a DB is a natural solution, I've heard of systems that use the file system or even email the request to a fulfillment address. 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] exec command fails in php, works in the command line
did you tried to run the script from the shell as www-data user ? (if not su www-data) an then run the script may be something regarding permission hth 2005/9/21, John Nichel [EMAIL PROTECTED]: [EMAIL PROTECTED] wrote: I have two programs on two servers, and they both have similar problems. In each one, I use 'exec' to call a helper program. In one case, it is ecasound, which I use to resample an mp3. In the other, it is convert, which creates a thumbnail of a very large image the user has uploaded. In both cases, the exec command fails. Not all the time, but some times. In both cases, the command that is being called by exec will work fine at the command line. I assume that there is some memory / resource limit that is being breached when this happens, but I don't know what it is, or how to tell php to allow my programs to run. Any ideas? Or is save mode on? -- 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
Re: [PHP] Chat module
should be not too difficult to setup using a couple of web pages running on localhost e socket hope help 2005/9/20, Vinicius Mapelli Schmaedek [EMAIL PROTECTED]: Somebody knows a chat module to be used for conversation between only two people? PS: sorry, my english is not very good :P -- 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] BOOKING SYSTEM
well I did it in the past, at the end after a lot of tests and simulation i decided for warehouse table id_hotel, date, num_total_rooms, num_booked_rooms this is day by day handling it is really flexible you can satisfy each kind of request with very simple queries you also gain more flexibility in period definition you canalso easily handling dsingle day workout and so on 2005/9/20, php @ net mines [EMAIL PROTECTED]: Hi all I have a hotel booking system where for sppecific periods we have specific availability e.g. hotel_id, hotel_name, hotel_fromperiod, hotel_toperiod, hotel_availablesinglerooms 1, Hilton, 20/06/05, 20/08/05, 20 We have a second table for recording the bookings e.g.hotel1_id, hotel1_name, hotel1_fromperiod, hotel1_toperiod, hotel1_availablesinglerooms 1, Hilton, 01/07/05, 20/07/05, 1 2, Hilton, 20/06/05, 25/07/05, 1 3, Hilton, 25/06/05, 27/06/05, 19 4, Hilton, 05/07/05, 05/08/05, 2 Let's say that someone wants to book from the 25/06/05 - 29/06/05 what kind of function-SQL do I have to run to check whether there is availability? (in this example there should be availability between 27 and 29 but not between 25 and 27). Is this way of structuring the easiest and more efficient? Thank you Mario -- 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] professional code quick tip
hy guys this night I'm quite tired I need a little tip ok var n could be from 0 to 12 var f must be set f=1 if0n=4 f=2 if 5n=7 f=3 if 8n=12 f=4 if n12 due to my fatigue I coded four if-if else statement, in other languages it is possible use conditional epression in switch case like switch $n case (0n=4): but no in php any suggestion for more professional coding then 4 if/else statement tia a.g. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] professional code quick tip ---last---
thx to all -- final release good nigh! $f=0; if ( $ar[0]0 and $ar[0]=12) $f=1; elseif ( $ar[0]12 and $ar[0]=14) $f=2; elseif ( $ar[0]14 and $ar[0]=18) $f=3; if ( $ar[0]18) $f=4; 2005/9/21, Robert Cummings [EMAIL PROTECTED]: On Tue, 2005-09-20 at 19:20, adriano ghezzi wrote: hy guys this night I'm quite tired I need a little tip ok var n could be from 0 to 12 var f must be set f=1 if0n=4 f=2 if 5n=7 f=3 if 8n=12 f=4 if n12 due to my fatigue I coded four if-if else statement, in other languages it is possible use conditional epression in switch case like switch $n case (0n=4): but no in php any suggestion for more professional coding then 4 if/else statement For such a small set I'd say that's as good as it gets. However if there were 100 intervals you could try the following: function f( $n ) { $map = array ( // min, max,f array( 0, 4,1 ), array( 5, 7,2 ), array( 8,12,3 ), array( 17, null,4 ), ); foreach( $map as $criteria ) { if( $criteria[0] === null || $n $criteria[0] $criteria[1] === null || $n = $criteria[1] ) { return $criteria[2]; } } return null; } I think your code is flawed by the way, the lower endpoints are only compared for greater than value and not equal to value meaning $n with value 4 would not match any f value. 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
[PHP] linux embedded no db which way
guys hi all, quite new in this list I'm involved in a project with php in a linux embedded environment, it's impossibile to use a db server, any suggestion on how to handle few hundreds of simple records ? tia - happy work with php! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Fwd: [PHP] linux embedded no db which way(2)
-- Forwarded message -- From: Jasper Bryant-Greene [EMAIL PROTECTED] Date: 14-set-2005 9.01 Subject: Re: [PHP] linux embedded no db which way To: php-general@lists.php.net adriano ghezzi wrote: guys hi all, quite new in this list I'm involved in a project with php in a linux embedded environment, it's impossibile to use a db server, any suggestion on how to handle few hundreds of simple records ? A text file, comma-separated or similar? http://php.net/fputcsv -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ -- - hy bryant -no space for db and no cpu power it is a really poor environment looking for a template or framework csv may be ok but need to handle all records management eg.: insert,delete,search every time rewriting text file -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php