Jump to content

joesaddigh

Members
  • Posts

    93
  • Joined

  • Last visited

Everything posted by joesaddigh

  1. Hi, I am currently running PHP 5.4.12 and cannot find a compatible php_win32service.dll to download. All the ones that I have seen seem to be for PHP 5.2/5.3? When trying to use the dll made for these versions, I get the following error message: PHP Warning: PHP Startup: Unable to load dynamic library 'ext\php_win32service.dll' - The specified module could not be found. It is worth pointing out that I have put the dll in the correct place along with the other extensions! Please can somebody give me any advice on where to go from here? Thanks in advance. Joe
  2. Hi, This is probably a really basic question but I really can't find the answer. Once I have configured and downloaded Nginx and PHP how do I actually run a PHP script, i.e. I create a simple index.php page and I want to open it in a browser and ensure the PHP code is run. My dir structure is as follows: C:\nginx C:\nginx\php My nginx.conf file is: #user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} location ~ .php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME c:/nginx/html/$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443; # server_name localhost; # ssl on; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_timeout 5m; # ssl_protocols SSLv2 SSLv3 TLSv1; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} } I have created a batch file for starting and stopping the php service and this seems to work (I run tasklist /svc) and I see the php-cgi.exe service appear and disappear. Although when I run the start service: @ECHO OFF c:\nginx\nginx.exe c:\nginx\php\php-cgi.exe -b 127.0.0.1:9000 -c c:\nginx\php\php.ini ping 127.0.0.1 -n 1>NUL echo Starting nginx echo . echo . echo . ping 127.0.0.1 >NUL EXIT It gives me an error "nginx: [alert] could not open error log file: CreateFile() "logs.error.log" failed (3: The system cannot find the path specified) even though I have added a file at this level: C:\nginx\logs\error.log Please any suggestions would be very much appreciated! Joe
  3. Hi, I have managed to debug my PHP application using XDebug and Eclipse - This is like a dream as I am used to the luxury of a debugger :-) However I have a few problems... 1) It will only stop at any of my breakpoints if I start the debug session from index.php - Used to work on other pages too but since I tried to uncheck the Break at first line this problem arose? I only want it to stop at my breakpoints which is why i fiddled with these settings in the first place.. 2) In the PHP debugger section it seems to think I am using the Zend Debugger - I don't even have this installed (why does it work?) I originally set it up with the Xdebug as this choice? 3) How do you simply import an existing php file into your project? I did it by using windows explorer view and dragging the files I wanted to use in to eclipse which seemed to add them to the library. However when I later did a create new file selection and then debugged it didn't find the file. I then created the new file manually and drag and dropped it in and it worked fine? my php.ini settings are as follows: [XDebug] zend_extension = "C:\xampp\php\ext\php_xdebug.dll" xdebug.remote_enable=1 xdebug.remote_host=localhost xdebug.remote_port=9001 xdebug.remote_handler=dbgp xdebug.profiler_enable=0 xdebug.remote_mode=req xdebug.remote_autostart=0 Image attached to show relevant settings in Eclipse: Please any advise would be greatly received. Thanks, Joe 17236_.doc 17237_.doc
  4. Yeah that's how I have got along so far. Going to give setting up zend another go as it makes itso much quicker being able to debug. Thanks for your help.
  5. That' excellent. Looking forward to creating some useful classes that I can re-use. One more thing if you don't mind. What do you use to debug PHP and is this easy to setup (know of any tutorials). I have tried setting up Zend studio before but not had a lot of luck so am using Dreamwever for now which means that I simply echo variable contents as and when I need to debug. Sorry that this is unrelated but would appreciate any help on this. Thanks again!
  6. Ah yess.. What an idiot I am. I want to try and put some of the common tasks that I perform regarding DB functions into a class which I can just create and use all over the place. The thing I am finding difficult to get used to is not having to specify data types and knowing what a function like: mysql_query mysql_fetch_array returns? Also when you declare a function within a class you dont say perhaps: ReturnType function NameOfFunction( param1, 2, 3 ) { return something; } You can simply do this: function NameOfFunction( param1, 2, 3 ) { return something; } So if I wanted to return the result of a mysql_fetch_array from a function that takes sql as a param and then use this in the caller of the func how woud I loop through the result that I would expect to be returned? Thanks for your help.
  7. Hi, I have decided to try and write some OO php. I have a simple class with one function. I am trying to instantiate an object of that class using the new operator but get an error. Parse error: syntax error, unexpected T_OBJECT_OPERATOR in C:\wamp\www\School\addcourse.php on line 38 <?php $CDBController = new CMasterDataController; //THIS IS LINE 38 CMasterDataController->PerformQuery("SOME SQL HERE"); ?> I am including the file that contains this class (CMasterDataController) in this file (addcourse.php). The version of PHP i am using is 5.3.8. Does anybody know what I am missing? Thanks, Joe
  8. Perfect thanks for your help. It was the DB that was messing it all up for me. The code posted now works perfectly.
  9. hi, It was the DB field being stored as a Date. Changed to a string so will have a play now. Getting better results. Thanks for your help
  10. I had the code like that at some point. the output of that was this: 2020-10-11 00:00:00?? What am I doing wrong? Thanks,
  11. Nothing its declared and assigned in the same statement $DateAndTime = date('d-m-y', strtotime($DateAndTime)); All I want is the current date in the format DD-MM-YYYY followed by the time. This must be a simple task?
  12. Hi, When I do this the result is a date of zeros? $DateAndTime = date('d-m-y', strtotime($DateAndTime)); All I want is a date in format of DD0MM-YYY and the Time in HH:MM::SS Any help would be great! I know it is basic, Thanks in advance
  13. That makes sense I can see the good reason for this. Cheers
  14. Excellent Thanks! I thought that the $conn would still be in scope? Joe
  15. Hi, I have some code which works but when I created a function and call this same code it doesn't. The error I get is as follows: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/fhlinux010/l/languageschoolsuk.com/user/htdocs/admin/email.php on line 42 Error retrieving schools The code function CreateSchoolCheckboxes() { echo '<div style="height:400px;width:400px;font:16px/26px Georgia, Garamond, Serif;overflow:scroll;">'; $querySchools = "SELECT * FROM school"; $result = mysql_query($querySchools, $conn) or die ("Error retrieving schools ".mysql_error()); while($row = mysql_fetch_array($result)) { $schoolname = $row['name']; echo '<input type="checkbox" name="school" value="'.$schoolname.'">'; echo $schoolname . '<br>'; } echo '</div>'; } Im sure that this is probably something simple but any suggestions would be much appreciated. Thanks, Joe
  16. I think it might just be working!! <?php //Function used to generate a random password function performcalculation() { // Connect to the database require ("includes/connection.php"); @$coursedetails = $_GET['coursedetails']; //Split the string getting the price and the type of accomodation $allcoursedetails = explode(',', $coursedetails); $courseid = $allcoursedetails[0]; // Store the amount of weeks booked $weeksBooked = $allcoursedetails[1]; // Now we have the relevant details, perform the calculation $query = "select discount_course.course_id, discount_course.discount_id, course.course_id, course.name AS coursename, course.level, course.price, discount.discount_id, discount.discount_name, discount.discount_qualifier_weeks, discount.discount_percentage FROM discount_course JOIN course ON discount_course.course_id = course.course_id LEFT JOIN discount ON discount_course.discount_id = discount.discount_id WHERE discount_course.course_id = '$courseid' ORDER BY discount.discount_id"; //Use this query below $result = mysql_query($query, $conn) or die ("Unable to perform course query this is where we are trying to work out the discount"); $numRows = mysql_num_rows( $result ); // Create seperate arrays to hold values $qualifiers = array(); $rates = array(); $price = 0.0; $iCounter = 0; // Populate arrays while( $row = mysql_fetch_array( $result ) ) { $price = $row['price']; $rates[ $iCounter ] = $row['discount_percentage']; $qualifiers[ $iCounter ] = $row['discount_qualifier_weeks']; $iCounter++; } array_multisort( $qualifiers, $rates ); $remaining_weeks = $weeksBooked; $total = 0.0; $last_pcnt = 0.0; $last_qualifier = 0.0; for ( $i = 0 ;$i < count( $qualifiers ); $i++ ) { if ( $remaining_weeks > ( $qualifiers[$i] - $last_qualifier ) ) { $total += (100-$last_pcnt)/100*$price*($qualifiers[$i]-$last_qualifier); } else { /* echo "In ELSE TOTAL:" . $total; echo "<br/>"; echo "<br/>"; echo "(100-".$last_pcnt.")/100*".$price."*".$remaining_weeks; */ $total += (100-$last_pcnt)/100*$price*$remaining_weeks; } $remaining_weeks = ( $remaining_weeks -( $qualifiers[$i] - $last_qualifier ) ); $last_pcnt = $rates[$i]; $last_qualifier = $qualifiers[$i]; if ( $remaining_weeks <=0 ) { break; } } if ( $remaining_weeks >0 ) { $total += (100-$last_pcnt)/100*$price*$remaining_weeks; } return round( $total ); } ?> Thank you very much this is a very neat solution!! I would have never thought of that.
  17. I cant believe I didnt see that!! Thank You. The logic is still not quite right though as it is giving a value way higher than expected! I will have another play with it and see if I can work it out! Do you use a debugger? If so is it easy to setup as I am used to using a nice IDE which makes life a lot easier Cheers. Joe
  18. Hi, I have been struggling with this.... Can you see any reason why this wouldnt work? The problem is that the price never gets any higher once it meets the first qualifier discount. <?php //Function used to generate a random password function performcalculation() { // Connect to the database require ("includes/connection.php"); @$coursedetails = $_GET['coursedetails']; //Split the string getting the price and the type of accomodation $allcoursedetails = explode(',', $coursedetails); $courseid = $allcoursedetails[0]; // Store the amount of weeks booked $weeksBooked = $allcoursedetails[1]; // Now we have the relevant details, perform the calculation $query = "select discount_course.course_id, discount_course.discount_id, course.course_id, course.name AS coursename, course.level, course.price, discount.discount_id, discount.discount_name, discount.discount_qualifier_weeks, discount.discount_percentage FROM discount_course JOIN course ON discount_course.course_id = course.course_id LEFT JOIN discount ON discount_course.discount_id = discount.discount_id WHERE discount_course.course_id = '$courseid' ORDER BY discount.discount_id"; //Use this query below $result = mysql_query($query, $conn) or die ("Unable to perform course query this is where we are trying to work out the discount"); $numRows = mysql_num_rows( $result ); // Create seperate arrays to hold values $qualifiers = array(); $rates = array(); $price = 0.0; $iCounter = 0; // Populate arrays while( $row = mysql_fetch_array( $result ) ) { $price = $row['price']; $rates[ $iCounter ] = $row['discount_percentage']; $qualifiers[ $iCounter ] = $row['discount_qualifier_weeks']; $iCounter++; } array_multisort( $qualifiers, $rates ); $remaining_weeks = $weeksBooked; $total = 0.0; $last_pcnt = 0.0; $last_qualifier = 0.0; for ( $i = 0 ;$i < count( $qualifiers ); $i++ ) { //echo "The remaining weeks " . $remaining_weeks; //echo "Qualifier in array " . $qualifiers[$i]; //echo "Last Qualifier " . $last_qualifier; if ( $remaining_weeks > ( $qualifiers[$i] - $last_qualifier ) ) { echo $addValue = ( ( 100 - $last_pcnt ) / 100 * $price * ( $qualifiers[$i] - $last_qualifier ) ); $total += $addValue; echo "<br/>"; /* $r = ( $qualifiers[$i] - $last_qualifier ); echo "<br/>"; echo "The calculation is: " .$total. "+ ( 100 - " .$last_pcnt. " ) /100 * " .$price. "*" .$r; echo "<br/>"; */ } else { $addValue = ( ( 100 - $last_pcnt ) / 100 * $price * $remaining_weeks ); $total += $addValue; echo "<br/>"; } $weeksBooked = ( $weeksBooked -( $qualifiers[$i] - $last_qualifier ) ); $last_pcnt = $rates[$i]; $price = $prices[$i]; $last_qualifier = $qualifiers[$i]; if ( $weeksBooked <=0 ) { break; } } if ( $remaining_weeks >0 ) { $addValue = ( ( 100 - $last_pcnt ) / 100 * $price * $remaining_weeks ); $total += $addValue; } return round( $total ); } ?>
  19. First of all thank you so much for your reply, I didnt expect anybody to take the time to read it as it was quite long winded. I will try this out later.. Have had a little read through and I can follow it which is a good start. It also looks really simple compared to reading the crap that I wrote!! I will be in touch, Thanks again. Joe P.s. $last_price = 100; //how do you know what price to charge when there is no discount? I get the price from the DB as the course details are passed through after a simple query.
  20. SELECT column FROM table WHERE Hit >0 ORDER BY RAND() LIMIT 1
  21. Haven't tested it but I think that you are just missing the brackets UPDATE userdata SET creditleft = (creditleft - 15) WHERE username = $_SESSION['login_name'] $query2 = "UPDATE userdata SET creditleft = (creditleft - 15) WHERE username = '".$_SESSION['login_name']."'"; mysql_query($query2, $link);
  22. Without looking but can you not adapt your echo "<meta http-equiv=refresh content=\"0; URL=photos.php\">"; to include the variable to the end in the same way as you would do it if it was on a seperate page. If not a crude solution would be to set a session variable and then null it once you have outputted it...
  23. Can you not pass it via the url? Assuming you are calling a php file to do the upload when you return to the page which contains the upload photo form you can pass the message via the URL. Upload photo //Close the connection to the database mysql_close($conn); header("Location: add_school_photo_form.php? message={$message}&schoolid={$schoolid}"); exit(); Form that contains the upload photo form if ( isset( $_GET['message'] ) ) { echo $_GET['message']; echo '<br />'; echo '<br />'; }
  24. Array of discounts to be applied based on the weeks booked all at different rate Hi, Sorry about the title, it will hopefully become clearer when I explain my problem. OK the problem is as follows: BACKGROUND INFORMATION Admin - add a course and apply some discounts. There can be multiple discounts per course. The format of a discount is: (NAME-WEEKS-DISCOUNT) NAME = The name of the discount - pointless mentioning WEEKS = The discount will be applied for subsequent weeks after this value ( if WEEKS = 2 and user books for 3 then the DISCOUNT will be applied for weeks after this value ). DISCOUNT = a decimal format for a discount rate which should be applied e.g. 10 OR 20 OR 50.6 etc NO MORE THAN 100 and more than 0. The above is all implemented. I have a course calculator which will use this information quoted above: For example: User picks a course and a duration ( 10 weeks ) When this is submitted I need to give them a price. As the weeks booked is variable and the amount of discounts for the chosen course is variable I would like to know the best way of calculating this. I currently have some code to do this and it seems to work but without a debugger I can't truely check it is accurate ( I think it might be doing something suttely wrong and if not the code is messy and hard to understand) Can anybody give me a good solution mathmatically which I can implement where by I can work out how much the total will be: Scenario in pseudo sort of code: $weeksbooked = 30 // Get the discounts from db // There are 3 so store these in array? // Example of array contents // Discount rate - qualifier(after how many weeks) - course price array[ 0 ] = 10%-5-£100 array[ 1 ] = 20%-10-£100 array[ 2 ] = 30%-15-£100 So I would need to do the following maths: 5 weeks at normal price £100 5 weeks at £100 - 10% 5 weeks at £100 - 20% THE REMAINING weeks at £100 - 30% ( £500 + £450 + £400 ) + REMAINING WEEKS at 30% discount ( £1350 + 1050 ) £2400 Please any ideas would be greatly received:
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.