[PHP] Re: Help needed with calculation
Chris Payne wrote: Hi everyone, I'm not sure of the correct formula for this, if I have a file - just for example, that is 10245458756 bytes long and the download speed is 60KB a second, what formula would I use to calculate how many seconds/minutes/hours it would take to download the file? Maths really isn't my strong point and formulas go over my head otherwise I wouldn't ask :-( Thanks everyone Chris $size = 1024548756; // in bytes $kb_per_sec = 60; // I assume you'll fill these in from elsewhere? $b_per_sec = $kb_per_sec * 1024; $seconds = $size / $b_per_sec; $minutes = 0; $hours = 0; if($seconds > 60) { // 60 seconds to a minute $minutes = (int)($seconds / 60); $seconds -= $minutes * 60; if($minutes > 60) { // 60 minutes to an hour $hours = (int)($minutes / 60); $minutes -= $hours * 60; // if you want to go further and calculate days, have at :) } } You could also approach this using modulus, but if you're not confident with math, this might be a more intuitive approach. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help needed / failed to open stream: Permission denied
> > > This is line 57 $file_handle = fopen("./" . $file_name, "r"); > > It seems that the user your web server runs as may not have permission to > open that file. Also, you might want to double check that ./$ile_name is a > valid path. And if you're planning to write to the file, you need to specify that. "r" means "open for reading only". Read up on the possibilities here: http://uk2.php.net/fopen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help needed / failed to open stream: Permission denied
Ndagi Mutiri wrote: > Hello, > > Trying to read a binary file in MySQL database, i have the following error > : > > Warning: fopen(./) [function.fopen]: failed to open stream: Permission > denied in d:\...\download.php on line 57 > > This is line 57 $file_handle = fopen("./" . $file_name, "r"); It seems that the user your web server runs as may not have permission to open that file. Also, you might want to double check that ./$ile_name is a valid path. > and my function > > function db_download_file($dbname, $file, $idreunion) { > //Sélectionne la base de données > mysql_select_db($dbname); > > //Requête SQL > $select = "SELECT " . $file . " FROM inter_vertaaldienst WHERE id_reunion > = '" . $idreunion . "'"; > > //Exécution de la requête > $file_records = @mysql_query($select); > > //En cas d'erreur, on affiche un message > if (!$file_records){echo('Erreur :' . mysql_error().'');} > //Autrement, on affiche le fichier > else{ > if($file_record = mysql_fetch_array($file_records)){ > $file_handle = fopen("./" . $file_name, "r"); > $file_bytes = $file_record[0]; > fwrite($file_handle, $file_bytes, strlen($file_bytes)); > $return_value = "./" . $file_name; > } > } > return($return_value); > } > > Thank for your help. > Ndagi Cheers -- David Robley A cat will go "quack" - if you squeeze it hard enough. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help Needed
http://uk2.php.net/manual/en/function.mssql-query.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help needed
Completely new? Well, there are a lot of articles on the web that will get you started... just try googling for "MySQL PHP tutorial". If you're willing to put in the time you can do it yourself... but there are a lot of PHPers out there that can do it for you right now. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help needed
Where does thejavascript fit ? Nirmala P wrote: Hi Pete Morganic , Thanks for reply. But the code is not solving my problem. May be I did not epress my problem clearly. Actually I wanted to store the returned value so that I can write it on page like { test = '); document.write(test); } and moreover the value I am passing is "material" and "E" is not getting parsed to PHP function. PHP function input for $field and $lang will be FieldName and LangName only. looking for help regards Nirmala P. On Mon, 30 Jun 2003 Pete Morganic wrote : Nirmala P wrote: Hi list, This time i am pasting my code could any body tell where wrong I am ? if(!$db) echo("Connect to localhost mysql database failed"); if(!mysql_select_db("eshop",$db)) echo ("Selection of eshop failed on MySQL database"); $Sql = "SELECT " . $field ." FROM language where LangCode = "."'".$lang."'"; $result = mysql_query($Sql,$db); if($result) { $myrow = mysql_fetch_array($result); $value = $myrow[$field]; // return valus return($value); } else echo (" No Record Found"); } ?> FieldName = "Material"; LangName = "E";
// included in quotes and php tag
alert('');
Loking for help.. Nirmala ___ Click below to experience Sooraj Barjatya's latest offering 'Main Prem Ki Diwani Hoon' starring Hrithik Roshan, Abhishek Bachchan & Kareena Kapoor http://www.mpkdh.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ___ Click below to experience Sooraj Barjatya's latest offering 'Main Prem Ki Diwani Hoon' starring Hrithik Roshan, Abhishek Bachchan & Kareena Kapoor http://www.mpkdh.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help needed
// included in quotes and php tagHi Pete Morganic , Thanks for reply. But the code is not solving my problem. May be I did not epress my problem clearly. Actually I wanted to store the returned value so that I can write it on page like { test = '); document.write(test); } and moreover the value I am passing is "material" and "E" is not getting parsed to PHP function. PHP function input for $field and $lang will be FieldName and LangName only. looking for help regards Nirmala P. On Mon, 30 Jun 2003 Pete Morganic wrote : Nirmala P wrote: Hi list, This time i am pasting my code could any body tell where wrong I am ? if(!$db) echo("Connect to localhost mysql database failed"); if(!mysql_select_db("eshop",$db)) echo ("Selection of eshop failed on MySQL database"); $Sql = "SELECT " . $field ." FROM language where LangCode = "."'".$lang."'"; $result = mysql_query($Sql,$db); if($result) { $myrow = mysql_fetch_array($result); $value = $myrow[$field]; // return valus return($value); } else echo (" No Record Found"); } ?> FieldName = "Material"; LangName = "E";
alert('');
Loking for help.. Nirmala ___ Click below to experience Sooraj Barjatya's latest offering 'Main Prem Ki Diwani Hoon' starring Hrithik Roshan, Abhishek Bachchan & Kareena Kapoor http://www.mpkdh.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ___ Click below to experience Sooraj Barjatya's latest offering 'Main Prem Ki Diwani Hoon' starring Hrithik Roshan, Abhishek Bachchan & Kareena Kapoor http://www.mpkdh.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help needed
// included in quotes and php tagNirmala P wrote: Hi list, This time i am pasting my code could any body tell where wrong I am ? if(!$db) echo("Connect to localhost mysql database failed"); if(!mysql_select_db("eshop",$db)) echo ("Selection of eshop failed on MySQL database"); $Sql = "SELECT " . $field ." FROM language where LangCode = "."'".$lang."'"; $result = mysql_query($Sql,$db); if($result) { $myrow = mysql_fetch_array($result); $value = $myrow[$field]; // return valus return($value); } else echo (" No Record Found"); } ?> FieldName = "Material"; LangName = "E";
alert('');
Loking for help.. Nirmala ___ Click below to experience Sooraj Barjatya's latest offering 'Main Prem Ki Diwani Hoon' starring Hrithik Roshan, Abhishek Bachchan & Kareena Kapoor http://www.mpkdh.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help needed
Thank you to all who helped, I have it working, well sort of. I now get the form but when I fill it in I get URL cannot be found on this server. The pages are there but it looks like i am not communicating with the database and the email is not being sent. I am now getting cross-eyed looking at all this code. Maybe I should get someone to do my website and I should stick to solving windows problems instead. "Andy" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi all > > Can someone help? > I am new to PHP and need some help, i have tried to build a members only > section to my website but i am finding it very hard. > > I get this error when i go to the login page: > > Parse error: parse error in /home/.sites/112/site***/web/Members/Login.php > on line 201 > > But the only thing on line 201 is: > default: > > I don't understand? > I get the feeling i will need more help even if someone solves this for me > :o) > > Thank you > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help needed
make sure you have a semicolon on line 200 or it could cause an error on line 201. am i right in assuming that this is a switch? can you provide us with a small block of code before and after this line? maybe 5 lines on either side... -Ryan >>> Andy<[EMAIL PROTECTED]> 04/01/03 08:17AM >>> Hi all Can someone help? I am new to PHP and need some help, i have tried to build a members only section to my website but i am finding it very hard. I get this error when i go to the login page: Parse error: parse error in /home/.sites/112/site***/web/Members/Login.php on line 201 But the only thing on line 201 is: default: I don't understand? I get the feeling i will need more help even if someone solves this for me :o) Thank you -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help needed
Missing ; ? Jochem Andy wrote: Hi all Can someone help? I am new to PHP and need some help, i have tried to build a members only section to my website but i am finding it very hard. I get this error when i go to the login page: Parse error: parse error in /home/.sites/112/site***/web/Members/Login.php on line 201 But the only thing on line 201 is: default: I don't understand? I get the feeling i will need more help even if someone solves this for me :o) Thank you -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: help needed with code!!
On Tue, 11 Mar 2003 01:14:09 -0500, Karl James <[EMAIL PROTECTED]> wrote: Can anyone give me some pointers on why im note seeing Any output to the browser. Thanks Karl my link http://66.12.3.67/webdb/webdb13/assignment_1.php my code http://nopaste.php-q.net/7560 ultimatefootballleague.com/index.php [EMAIL PROTECTED] You might have some sort of error message disabled in php.ini. If you just copy and paste from that html file, it's riddled with invalid characters. You'll have to manually go through the copied source and replace all of the spaces and newlines. -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help Needed
Hello All: Thanks again... I tried to use this and it is working fine for me. Please comment: Many Thanks -Pushpinder On Tuesday, February 4, 2003, at 12:32 PM, Goetz Lohmann wrote: Pushpinder Singh Garcha schrieb: Hello All: My question is related to authentication. I have made a login system using PHP Sessions and MySQL. Once the user gets authenticated on the website I want to be able to allow him to see some html pages on the website. Only users who have logged in are able to see such a files. I have asked this question before , but still I have some doubts. My code will check for: if (session_is_registered($valid_user)) { /// display the reqd page } else { DISPLAY ERROR MESSAGE and ASK USER TO LOGIN } How should I display the page ... the page has a lot of html code and trying to write echo " blah blah blah . "; will not be a an option. Please suggest a way out . you could include every page into a php script using this mean, that this page is like being copyed in the php file also instead of you always can do bla bla bla -- @ Goetz Lohmann, Germany | Web-Developer & Sys-Admin \/ -- () He's the fellow that people wonder what he does and || why the company needs him, until he goes on vacation. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Pushpinder Singh Garcha _ Web Architect
[PHP] Re: Help Needed
Pushpinder Singh Garcha schrieb: > Hello All: > > My question is related to authentication. I have made a login system > using PHP Sessions and MySQL. Once the user gets authenticated on the > website I want to be able to allow him to see some html pages on the > website. Only users who have logged in are able to see such a files. I > have asked this question before , but still I have some doubts. > > My code will check for: > > > if (session_is_registered($valid_user)) > { > /// display the reqd page > } > > > else { > > DISPLAY ERROR MESSAGE and ASK USER TO LOGIN > } > > > How should I display the page ... the page has a lot of html code and > trying to write echo " blah blah blah . "; > will not be a an option. Please suggest a way out . you could include every page into a php script using this mean, that this page is like being copyed in the php file also instead of you always can do bla bla bla -- @ Goetz Lohmann, Germany | Web-Developer & Sys-Admin \/ -- () He's the fellow that people wonder what he does and || why the company needs him, until he goes on vacation. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: help needed building query string based on which form fieldsthat are filled.
Don't get your question right, but you get all your vars in the querystring after submitting the form. There, you should check on whether or not the var is filled (i.e. $var <> "" or so). There's no other way :-( so your guess is pretty ok. BTW: use Javascript to modify the submitted values. Edwin Anders Thoresson wrote: Hi, I've got a html form where not all fields need to be filled by the users. How can I build a MySQL query based on which fields the user have filled? My guess is that I can do something like this: if(!empty($f_name)) { some_commands_to_add_$f_name_to_querystring } if(!empty($l_name)) { some_commands_to_add_$f_name_to_querystring } some_commands_to_build_querystring_based_on_if's $result = mysql_query($query) But what commands/functions should I use to build the query? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: help needed with forms
Hello, On 11/21/2002 07:28 PM, Pushpinder Singh Garcha wrote: I am using php based forms, which collect information from the client and send it in the form a email message to the admin. I need to start using validation i.e. check whether some field/s has been correctly entered in the from. My application consists of 2 php pages 1). info.php(this page consists of the plain form and the has its action parameter set to "send_info.php") 2). send_info.php (this forms collects the information that the client entered and composes a message and mails it to admin) So I use headers in the following manner: The send_info.php code starts like this if($email =='') { header("Location: http://www.mysite.com/info.php";); } ?> This takes the user back to the info.php page with all the fields reset. What I need is that 1). An alert box must be displayed which tells the user where he went wrong 2). Also the data that the user had entered on the form must not be reset to blank. This very popular class does exactlty what you need: http://www.phpclasses.org/formsgeneration -- Regards, Manuel Lemos -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help needed with attachments
Hello, On 11/13/2002 02:35 PM, Pushpinder Sngh Garcha wrote: I am using MIME to send mail (http://www.phpclasses.org/mimemessage) I need to be able to send attachments that are present on the local machine. Is there a way to send attachements without uploading then to the server ?? The file needs to be accessible from the server because that is where PHP is running. Either you upload it or specify a URL of a public accessible file like the example of the class. -- Regards, Manuel Lemos -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help needed about queries with MySQL, thanks.
Same here... Even though allot of people say it's not necessary... - Original Message - From: "Carsten Mohr" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, August 18, 2002 5:22 PM Subject: [PHP] Re: Help needed about queries with MySQL, thanks. > Hallo, > > I don't know if it helps you, but normally you have to quote the > variable in the SQL-Statement like: > SELECT * FROM sessions WHERE sessionID = '$sessionID' > Otherwise I always get an SQL-Error > > Jean-Marc Godart wrote: > > Hello everyone, > > > > I am a new PHP user, from Belgium. I am trying to manage a MySQL database with PHP, and I kindly request your help to solve a little (probably very stupid) problem I have been dealing with for a while already ... > > > > I have a MySQL database (called "sessions") with a auto-increment INT field called "sessionID". I try to check if there is already a record in this database with a given sessionID, which is called $sessionID in PHP. I use this query, which must be wrong (but I cannot find out why !!!) : > > > >SELECT * FROM sessions WHERE sessionID = $sessionID > > > > Even though there is already a record with the right sessionID, my program does not find it (I always get 0 when using mysql_num_rows() after the query). Though, if I replace "$sessionID" by, for example 4, then that works and it says there is already a record with that ID. > > > > I guess the problem comes from comparing two different kinds of variables, but I can't fix it ... Could anyone please help ? By advance, thank you !!! > > > > Best regards from Belgium, > > > > > > Jean-marc > > > > > > > > > > > -- > 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] Re: Help needed about queries with MySQL, thanks.
Hallo, I don't know if it helps you, but normally you have to quote the variable in the SQL-Statement like: SELECT * FROM sessions WHERE sessionID = '$sessionID' Otherwise I always get an SQL-Error Jean-Marc Godart wrote: > Hello everyone, > > I am a new PHP user, from Belgium. I am trying to manage a MySQL database with PHP, >and I kindly request your help to solve a little (probably very stupid) problem I >have been dealing with for a while already ... > > I have a MySQL database (called "sessions") with a auto-increment INT field called >"sessionID". I try to check if there is already a record in this database with a >given sessionID, which is called $sessionID in PHP. I use this query, which must be >wrong (but I cannot find out why !!!) : > >SELECT * FROM sessions WHERE sessionID = $sessionID > > Even though there is already a record with the right sessionID, my program does not >find it (I always get 0 when using mysql_num_rows() after the query). Though, if I >replace "$sessionID" by, for example 4, then that works and it says there is already >a record with that ID. > > I guess the problem comes from comparing two different kinds of variables, but I >can't fix it ... Could anyone please help ? By advance, thank you !!! > > Best regards from Belgium, > > > Jean-marc > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help needed with hexdec();
>I wrote a less-limited hex2dec function years ago, and threw it up on >Sklar, >or, uhhh, the *other* PHP code repository. There were really only two, >back >then... :-) Another option would be the BC Math package which will let you compute arbitrarily large numbers, albeit a bit slower. Just how big do the numbers get?... -- 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] Re: Help needed with hexdec();
Thank you for your answer Richard, unfortunately the port from perl to PHP didn't work out the way I wanted it to - probably mainly because of the lack of perl knowledge here. And yes you are right, the numbers I use are a lot bigger than 2147483647. If anyone has an idea on how to treat the numbers or hex number for that matter please don't hesitate. Anyway, I'm dropping the project for now. Thanks again. -Oorspronkelijk bericht- Van: Richard Lynch [mailto:[EMAIL PROTECTED]] Verzonden: zondag 7 juli 2002 0:12 Aan: [EMAIL PROTECTED] Onderwerp: [PHP] Re: Help needed with hexdec(); >I have to convert a perl script to PHP trying to do so I get negative >values from hexdec(), If I use (int)hexdec() the numbers aren't negative >anymore, but they do not add up to what they should. >From the manual: http://php.net/hexdec "The largest number that can be converted is 7fff or 2147483647 in decimal." I'm betting your numbers are bigger than that. I wrote a less-limited hex2dec function years ago, and threw it up on Sklar, or, uhhh, the *other* PHP code repository. There were really only two, back then... :-) -- 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help needed with hexdec();
>I have to convert a perl script to PHP trying to do so I get negative >values from hexdec(), If I use (int)hexdec() the numbers aren't negative >anymore, but they do not add up to what they should. >From the manual: http://php.net/hexdec "The largest number that can be converted is 7fff or 2147483647 in decimal." I'm betting your numbers are bigger than that. I wrote a less-limited hex2dec function years ago, and threw it up on Sklar, or, uhhh, the *other* PHP code repository. There were really only two, back then... :-) -- 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] Re: help needed with headers
Hi, I spent ages figuring this one out so it work work on Windoze, Linux, Mac, ... and this *always* works: Create a hyperlink for user to click on: echo ' Download TXT'; On click, we come back in to this: if ( $action == '*' ) { if ( isset( $download ) ) { downloadFile( $download ); we have a fn to do the biz: function downloadFile( $type ) { global $PHPSESSID; // is it a .txt file or an .rtf file if ( $type == 'txt' ) { // write the stuff to a text file: /downloads/$PHPSESSID.txt include( '../include/mkcribsheet_txt.inc' ); // download the file if ( file_exists( $txtfile ) ) { $size = filesize( $txtfile ); // this goes all on one line header( "Content-Type: text/x-c; charset=\"iso-8859-1\"; name=\"$txtfile\"" ); header( "Content-Length: $size" ); header( "Content-Transfer-Encoding: base64" ); header( "Accept-Ranges: none" ); // You could have filename="$txtfile\"" here. I don't becos the user // gets his "save as" box with $PHPSESSID.txt which is ugly header( "Content-Disposition: attachment; filename=\"cribsheet.txt\"" ); header( "Content-Description: PHP Generated Cribsheet" ); $fp = fopen( "$txtfile", "r" ); fpassthru( $fp ); // delete the PHPSESSID.txt file unlink( "$txtfile" ); // delete the PHPSESSID from the cribsheet so user can go again $query = "update cribsheet set sess_id='' where sess_id='$PHPSESSID'"; dbCribsheetUpdate( $query ); } exit; } good luck Donna -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: help needed with headers
Try this: header ("Content-type: text/plain"); header ("Content-disposition: attachment; filename=file.txt"); -- Kind regards, Yuri. www.AceHoster.com Quality web hosting "Vins" <[EMAIL PROTECTED]> > I would like to create a text file that doesn't save to disk but askes me to > save the file. > like when i click on a zip file from a website, ie asks me to save the file > to somewhere. > > how do i create the file and then tell my browser to ask the user to save > the file somewhere > > ??? > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help needed with speading up a function.
On Friday, March 8, 2002, at 04:27 PM, George Whiffen wrote: > Hope you are/are not trying to crack ciphers! George, you know way more about math than I do, but I do know that trying to crack them is a good way to make sure they work, or make them stronger! Erik (who thinks his pay rate should be a more rational number) Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help needed with speading up a function.
William, You need a mathematician not a computer programmer. This is classic number theory which must have been very well explored. I have a very vague recollection that there may be partial proofs that there are no primes between x and y or no more than n primes between w and z for low ranges of numbers. My instinct would be that you cannot, in general, know you are near a prime. But that's based on a wishy-washy assumption that primes are the only significant rational numbers and that all other rationals are just short hand for prime relationships. Or rather, only the primes and irrationals are necessary. Or, if you want a database metaphor, only primes are 5th normal form. Hope you are/are not trying to crack ciphers! George William Bailey wrote: > Hello again. > > I have the following function that generates a prime number of x > bits. It seems to work but i am just trying to see if i can make it any > faster as generateing 1024 bit prime can take a while. so i thoought i > would ask here to see if anybody has any ideas or suggestions. > > The function is as follows: > > mt_srand((double)microtime()*1); > > function generate_prime ($bits) { > $number=gmp_init('0'); > for($i=$bits; $i>=0; $i--){ > $rand=mt_rand()%2; > gmp_setbit($number, $i, $rand); > } > while(gmp_prob_prime($number)<1){ > $number=gmp_add($number, 1); > } > if(strlen(gmp_strval($number, 2))!=$bits){ > $number=generate_prime($bits); > }else{ > return (string)gmp_strval($number); > } > } > > At the moment im generating a random number of the required length and > then +1ing it untill it is a prime. I suppose i really want to know if > their is some way of knowing how close you are to a possiable prime so > that if the random number is too far away then it could call itself again > and try a different random start location. > > I look forward to any ideas that you might have. > > Regards, > William. > > -- > William Bailey. > http://wb.pro-net.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help needed - need to access a value from DB into all pages
Hi there :) One of the most common methods of achieving this is by using session variables. First the user logins in through a form with a username and a password, you check these against the database to make sure they are who they say they are, once that is established you could create a session variable called "$USERID" (or something a little less intutive:) once retrieving the $USERID, and do a check within every page to see what $USERID they are and perform the appropriate actions. Check out sessions at : http://www.php.net/manual-lookup.php?pattern=sessions Cheers, Joe :) Wg4- Cook <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi there, > > I am struggling with a concept and can't seem to find a way to do it so > hoping you all can help. > > We want to use PHP with MySql Db. > For security reasons on the DB, it is to be accessed only through this front > end i.e. via the internal web > Each user will have a number of levels of access to various parts of the > system, so the obvious design is one where there is only 1 real login to the > MySQL db (i.e. the system will auto log everyone in as this without them > knowing it), and then the user is validated against a table in my DB which > holds the access rights. I can get through the login OK, and get my table to > return "USERID" for this person. Now I need that "USERID" available to ALL > other pages so I can use it to determine what parts of screens to show, and > what to allow them to do. > > My question is how do I make this variable available to all pages?? Do I > have to include it with the variables passed to each page or is there a > simpler way of doing it. Can I put the variable in an include file and > include it in every page - will that work?. > > Surely someone must have had a similar situation before and can tell me how > they solved it. > > Many thanks > > Janet > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help needed - need to access a value from DB into all pages
Janet, I think you probably need to investigate the concept of sessions. You were a bit sketchy on details, but it sounds like this is what you want. If you'd like more help, post to the list, or contact me directly at [EMAIL PROTECTED] (aim:mgkimsal) Wg4- Cook wrote: > Hi there, > > I am struggling with a concept and can't seem to find a way to do it so > hoping you all can help. > My question is how do I make this variable available to all pages?? Do I > have to include it with the variables passed to each page or is there a > simpler way of doing it. Can I put the variable in an include file and > include it in every page - will that work?. > > Surely someone must have had a similar situation before and can tell me how > they solved it. > > Many thanks > > Janet > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php