PHP - Help Me To Test Script
I got this script for change language and don't know is it working. In this array are supported language s for this site, so if you come from some of this 7 country should open your language, for others english version. Don't know any other way to test it!
http://www.lacman.hr/index.php Code: [Select] $jezici = array("hr", "en", "de", "it", "fr", "cz", "pl"); Similar TutorialsIs there any php function I can test how fast my server is performing, like how fast its carrying out a certain action so I can see its resource usage. PHP code: Code: [Select] <? //login variable $username = $_POST ['username']; $password = $_POST ['password']; $database = $_POST ['database']; //table variable $table = $_POST ['table']; //stats variables $name = $_POST ['name']; $force = $_POST ['force']; $armor = $_POST ['armor']; $strength = $_POST ['strength']; $value = $_POST ['value']; mysql_connect ("localhost","$username","$password"); @mysql_select_db ($database) or die ("no database name"); $query = "INSERT INTO `$database`.`$table` ('name', 'force', 'armor', 'strength', 'value') VALUES ('$name', '$force', '$armor', '$strength', '$value')"; mysql_query ($query); if (mysql_query($query)) { die('Error: ' . mysql_error()); } echo "1 record added<br>"; echo "<br>variable $name test"; echo "<br>variable $force test"; echo "<br>variable $armor test"; echo "<br>variable $strength test"; echo "<br>variable $value test"; mysql_close(); ?> HTML files code: Code: [Select] <form action = "datainput.php" method = "post"> <div align="center">Item Submission Form</div><br><br> <br> <div align="center"><input type="text" name="table" value="head neck back or chest" size="32" maxlength="32"></div> <br> <br> <div align="center"><input type="text" name="name" value="Type Name Here" size="32" maxlength="32"></div> <br> <br> <div align="center"><input type="text" name="force" value="Type force number" size="32" maxlength="32"></div> <br> <br> <div align="center"><input type="text" name="armor" value="Type armor value" size="32" maxlength="32"></div> <br> <br> <div align="center"><input type="text" name="strength" value="Type strength value" size="32" maxlength="32"></div> <br> <br> <div align="center"><input type="text" name="value" value="Type cost Here" size="32" maxlength="32"></div> <br> <br> <br> <div align="center"><input type="text" name="username" value="username here" size="32" maxlength="32"></div> <br> <div align="center"><input type="text" name="password" value="password here" size="32" maxlength="32"></div> <br> <div align="center"><input type="text" name="database" value="database Here" size="32" maxlength="32"></div> <br> <div align="center"><input type="submit" name="Submit_button" value="Submit"></div> </form> What is funky is the page seems to work, it says it writes a record but the record never appears in the database. I did verify MIME types were correct for HTML to be allowed to write as php if needed, any idea why it wouldn't create a record? write the algorithm to draw a sphere, the function should have parameters 1. diameter (how many line) 2. character (use which character to draw) eg, draw_sphere(10, '8') will produce: 88888 8888888888888 8888888888888888888 888888888888888888888 88888888888888888888888 88888888888888888888888 888888888888888888888 8888888888888888888 8888888888888 88888 the above is a sphere of 10 lines, which is drawn using the character "8" i cant figure out how to do it, thanks in advanved! Hi
so i've been learning php for 3 mouth now by reading php 6 Bible and watching lynda and so on...
i was looking for a job in few past weeks and i found out i don't have that kind of self confidence to go for it ! you know when they say : PHP Project Manager , it scar's me...
the thing is , i know all about basic to medium php , array...MySQL....all those essentials but i don't know what do they want from a php web developer .
so i began to search for intern job somewhere and i told myself i should bust my ass 24/7 for few mouth and after that i ll be real php guy and it seems like there is no place to reach not php but almost all programming languages
a year ago i was searching for the same thing but in networking section and there was 100's of intern ship jobs but in programming there is none !
so i want some one to give me (us) simple to pro real life projects .
what do they want php junior or senior developer's for ? what do they do?
what is the most common needs ?
what is the most essential things to know?
what is a hired php developer should do in the office?
some people doesn't need you in the office and want you to work from home , they give you project's , what's that?
is there any source in the web to offer what is need ?
i know its too much , but this was my last option , so if anyone can help i would practically owe him/her my whole future salaries...
I am trying to select text to display on condition of the current date. I've set a Unix timestamp for the current date: <?php $todays_date = date("Y-m-d"); $today = strtotime($todays_date); ?> Next I test for the first condition. I want the text to appear for 2 weeks then terminate: <?php $exp_date = "2011-05-09"; $expiration_date = strtotime($exp_date); $start_date = strtotime("-14 days", $expiration_date); if ($start_date < $today && $expiration_date > $today) { echo "<h2>Special Event #1</h2>"; } elseif { At this point, I want to set the exp_date for the next event and test again, but I don't know how to do it. The techniques I've tried appear to evaluate as false and display the default text which follows the final "else": } else { echo "<h2>Default Text</h2>"; } ?> Hello All happy new year I am trying to make a php page that detects if something is plugged in to the ethernet port. This would be complex if not impossible. I however managed to do something similar the device that will be plugged in has a static address 192.168.1.1. so I created a ping that says if the device is up or down. function ping($host, $port, $timeout) { $fP = fSockOpen($host, $port, $errno, $errstr, $timeout); $status; if ($fP) { echo "Device is ready to accept data";} else { echo "Device Down - Retrying connection"; } } What I would like to do is have a script that is constantly checking is the device is plugged or when it is not (so sort of a loop or auto detect). The idea is to have an image with the device up or down. Regards and a happy new year JG I have an issue that with some testing on an Access class with a method getControlAccess it should only return true or false but as soon as I place a string of any sort into the return my tests always returns true. Any help to point out if it is the way I am testing or the way I have written the method would be great. In the example below it would return true. In one class I have this method Code: [Select] class Access{ public function getControlAccess(){ return 'I am stuffed'; } } In the second class I have this Code: [Select] class AccessTests extends Access{ public function controlAccessTest(){ $return = "<ul>"; if ($this->getControlAccess() == TRUE){ $return .= "<li>getControlAcess should be true and is returning:<b> ". $this->getControlAccess() ."</b></li>"; } elseif ($this->getControlAccess() == FALSE){ $return .= "<li>getControlAcess should be false and is returning:<b> ". $this->getControlAccess() ."<b></li>"; } else { $return .= "<li>getControlAcess is really stuffed:<b>". $this->getControlAccess() ."<b></li>"; } $return .= "</ul>"; return $return; } public function setAccessTest($set){ return $set; } } I want to do a test while refreshing the page 100 times with 500 rows in a table, and then without 500 rows in a table and with different kind of php code, i need to do some type of testing to get results back in to show which way is faster for mysql/php. Any idea how to do this any scripts out there or a built in php/mysql function? Thanks I can't seem to figure out how to calculate the score the user gets when they hit the score button. I figured it would look something like this... $result_score = $right / 9 * 100.... but I've tried a few methods and I can't seem to figure out why its not working. Here is my code for the application.... Code: [Select] <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Multiplication Test</title> </head> <body> <?php require_once('database.php'); define ('ROWS', 3); define ('COLS', 3); define ('MAX_NUMBER', 12); date_default_timezone_set('America/New_York'); if (isset($_POST['btn_score'])) { $result_name= $_POST['result_name']; $result_score= $_POST['result_score']; $result_score = / 9 * 100; $sql = "INSERT INTO results (result_name, result_score, result_date_time) VALUES ('$result_name','$result_score', NOW());"; $db->exec($sql); //print_r ($_POST); $time1 = $_POST['ts']; $time1_object = new DateTime($time1); $now = new DateTime(); $time_span = $now->diff($time1_object); $minutes = $time_span->format('%i'); $seconds = $time_span->format('%s'); $seconds+= $minutes * 60; echo "It took $seconds seconds to complete the test<hr />"; foreach ($_POST as $problem => $answer) { if ($problem <> "btn_score" && $problem <> "ts") { //echo "$problem -- $answer <br />"; $problem = explode('_', $problem); $num1 = $problem[2]; $num2 = $problem[3]; $right = $num1 * $num2; if ($answer != $right) { echo "$num1 * $num2 = $answer , The right answer is $right<br />"; } } } } ?> <h1>Multiplication Test</h1> <form name="lab5" method="post" action="lab5b.php"> <?php $now = new DateTime(); //echo $now->format('Y-m-d H:i:s'); echo "<input type='hidden' name='ts' value='" . $now->format('Y-m-d H:i:s') . "'>"; ?> <table border="1" cellspacing="5" cellpadding="5"> <?php $no_of_problems = 0; for ($row=0; $row<ROWS; $row++) { echo "<tr>"; for ($col=0; $col<COLS; $col++) { $num1 = mt_rand(1,MAX_NUMBER); $num2 = mt_rand(1,MAX_NUMBER); echo "<td>$num1 * $num2 </td>"; echo "<td><input type='text' size='2' name=${no_of_problems}_mult_${num1}_${num2}></td>"; $no_of_problems++; } echo "</tr>"; } $colspan = 2 * COLS; echo "<tr><td colspan=$colspan align='right'><input type='submit' value='Score' name='btn_score'></td></tr>"; ?> </table> <br> <br> <label for="result_name">Student Name:</label> <input type="text" id="result_name" name="result_name" /><br /> </form> <br> <br> </body> </html> Hello, Having trouble inserting plain text to the output of this php. The code below outputs categories in the database which pertain to certain products in this manner, cat1, cat2, cat3, cat4, cat5 etc. What I want to add is the text "Fits These Products" this to the output, Fits These Products cat1, cat2, cat3, cat4, cat5 etc Code: [Select] $lc_align = ''; if(isset($HTTP_GET_VARS['language'])) { $env_language = $HTTP_GET_VARS['language']; $language_query = tep_db_query("select languages_id from ". TABLE_LANGUAGES . " where code ='" . $env_language . "'"); $language_arr = tep_db_fetch_array($language_query); $language_id = $language_arr['languages_id']; } else { $language_id = (int)$languages_id; } $products_to_catagories_query = tep_db_query("SELECT categories_name FROM ". TABLE_PRODUCTS_TO_CATEGORIES ." p2c, ". TABLE_CATEGORIES_DESCRIPTION ." cd WHERE p2c.products_id = " . (int)$listing[$x]['products_id'] . " and p2c.categories_id = cd.categories_id and language_id ='".(int)$language_id."'"); $category_list = " "; do { if($category_list != " ") $category_list .=" , "; else $products_to_categories_array = tep_db_fetch_array($products_to_catagories_query); $category_list .= $products_to_categories_array['categories_name']; } while($products_to_categories_array = tep_db_fetch_array($products_to_catagories_query)); $category_list .="<br><br>"; Thank you JR this is pretty decent right? Code: [Select] mySQL_array SPEED TEST - [ 30,000 Numbers ] - SERIALIZED with BASE64 ENCODING AND GZ COMPRESSION 52.8KiB WRITE ARRAY in: 0.15 seconds. 52.8KiB READ ARRAY in: 0.03 seconds. 52.8KiB ROUND TRIP in: 0.18 seconds. (approx: 3.41 milliseconds per KiB) --- running on FIREFOX + EASY PHP 5.3.8.0 - ON ASUS G51VX - 2GHz dual core (x64) - 4GB RAM --- Hey Guys.
Im trying to show if the selected user has had all the required tests they need so they can have a treatment at a hairdressers. For example the client needs to of had a skin test before they can have their hair dyed. Im struggling on showing which tests the user still needs to have
Currently I'm working with 3 tables.
The treatmentTest table which stores all the required tests
treatmentTest
idtreatmentTest
the user table which has the users details
user
iduser
and the usertest table which stores when they had the test and if it has expired (if it has expired is set to 1)
userTest
iduser
idtreatmentTest
expired
so I need this box to pop up with a warning on each test that is still outstanding but I dont want it to show if there are no tests needed. I obviously need to loop through the results of my query but the query its self is confusing me...
<ul class="list-unstyled"> <li>[treatment Name]</li> <li class="text-italic text-muted">Expired [date]</li> <li><a href="#" class="btn btn-success">Update</a></li> </ul>First I tried looping through all the treatments then inside that loop writing the following <?php do { //now foreach treatment test get the resulting test from the usertest table if (isset($row_testReq['idtreatmentTest'])) { $col_userTest = $row_testReq['idtreatmentTest']; } if (isset($_SESSION['cClient'])) { $colname_userTest = $_SESSION['cClient']; } if (isset($expire)) { $colname_userTestExpire = '1'; } mysql_select_db($database_dbconnect, $dbconnect); $query_userTest = sprintf("SELECT * FROM userTest WHERE idtreatmentTest = %s AND iduser = %s AND userTestExpire=%s", GetSQLValueString($col_userTest, "int"), GetSQLValueString($colname_userTest, "int"), GetSQLValueString($colname_userTestExpire, "text")); $userTest = mysql_query($query_userTest, $dbconnect) or die(mysql_error()); $row_userTest = mysql_fetch_assoc($userTest); $totalRows_userTest = mysql_num_rows($userTest); ?> <li class="list-group-item"> <div class="col-sm-2"><i class="fa fa-2x fa-close text-danger"></i></div> <div class="col-sm-9"> <ul class="list-unstyled"> <?php if($totalRows_userTest>0){?> <li><?php echo $row_testReq['treatmentTestName'];?></li> <li class="text-italic text-muted">Expired <?php echo $fn->sqlShowDate($row_userTest['userTestExpire']); ?></li> <li><a href="client-treat-test.php?i=<?php echo $row_testReq['idtreatmentTest'];?>&t=<?php echo $row_testReq['treatmentTestToken'];?>" class="btn btn-success">Update</a></li> <?php } ?></ul> </div> <div class="clearfix"></div> </li> <?php } while ($row_testReq = mysql_fetch_assoc($testReq)); ?> this doesnt work properly at all. It gave me all the treatments that have expired but if a new treatmenttest was added it wouldnt display that there was a test required. Does anybody know a different way? I also tried getting all the treatments then all the rows in the userTest table then comparing what the differences where but I struggle with arrays comparisons and im not even sure that was the best way to go about it. Am I going to need two queries? One like the loop above and one that looks for expired treatments and one that looks for treatments the user hasn't had or can this be done in one and if so how?? Edited by fife, 18 November 2014 - 02:39 PM. Hi there i just need to assign a class to my echoed vairable. Code: [Select] echo $test class="somecssclass"; Im sure im missing some braces here or something but i cant seem to find it out. Heres the error: Parse error: syntax error, unexpected T_CLASS, expecting ',' or ';' Please help Thanks hi
i want to use proxy in php with curl for scraping contet .but some proxy not suport post request .
plz tell me how to chek before use proxy post request suported or not also want proxy speed in ms..
plz help me out .
thanks .
Edited by ShivaGupta, 23 May 2014 - 04:49 PM. I have a class I use to handle my various DB objects. I want to close any connections, if needed, in my destructor. I want to do this even though I already know the connection has been closed previously. What I am looking for is a way to test the $connection variable I have to see if it's in need of closing. I can't figure out how to do this. if (isset($this->connection)) { echo "is set"; } if ($this->connection) { echo "here"; } The above would output "is set" and "here", because in both tests say the already closed connection is still there. Can anyone offer any help? I created this to test the connection to my ms sql server with a web page. I can connect with isql with out fail.
when I open this I get
PHP SQL Test
END PHP SQL Test
I was expecting to get sql data between the above lines. What am I doing wrong.
<html> <head> <title>PHP SQL Test</title> </head> <body> <p> PHP SQL Test </p> <? $conn =odbc_connect("datasource","user","password"); if(!$conn) { exit("Connection Failed: " . $conn); } $sql="SELECT top 10 * from WIP_master"; $rs =odbc_exec($conn,$sql); print_r($rs); if(!$rs){ exit("Error in SQL"); } odbc_close($conn); ?> <p> End PHP SQL Test </p> </body> </html> I have tested my code and got it working but when it was uploaded to my web host of godaddy.com it suddenly stops working on one page; it literally comes up a blank page, the page source is completely empty as well. the code on the page is Code: [Select] <?PHP session_start(); include("../functions/common.php"); $sqldb = open_database(); //Open the database include("../functions/create_game.php"); #This is the actual game creation code header('Location:'.$_SESSION['web_site'].'/home.php'); //Go back to the home page ?> first thing I did was put error code reporting in Code: [Select] <?PHP error_reporting( E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR ); ini_set ('display_errors', '1'); session_start(); include("../functions/common.php"); $sqldb = open_database(); //Open the database include("../functions/create_game.php"); #This is the actual game creation code header('Location:'.$_SESSION['web_site'].'/home.php'); //Go back to the home page ?>The test server the code still worked fine but on the production server it gave me Quote Fatal error: Call to undefined function PHPerror_reporting() in /home/content/74/8039674/html/testcricketmanager.com/gameplay/challenge.php on line 1 Out of frustration I put Code: [Select] <BR>1 <?PHP #error_reporting( E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR ); #ini_set ('display_errors', '1'); echo "<br>2"; /* session_start(); include("../functions/common.php"); $sqldb = open_database(); //Open the database include("../functions/create_game.php"); #This is the actual game creation code header('Location:'.$_SESSION['web_site'].'/home.php'); //Go back to the home page*/ ?> <BR>3 and the output was Quote 1 3 James NOTE: All the code works fine on the test server (at home on a Linux box); production server (godaddy) the PHP code works on each page except this one This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=328252.0 hello dear friends - i want to test if the DOMdocument [class] exists? Can i do this in the shell (on OpenSuse 11.3)? bool class_exists ( string $class_name [, bool $autoload = true ] ) bool class_exists ( string $DOMdocument [, bool $autoload = true ] ) or do i have to create a file that i call itself in the shell!? look forward for an idea / hint / tipp regards db1 How can I test if a chunk exceeds the image size and wrap that text to the next line. Not sure if I am even doing this correctly with my if statement. $text="Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem http://somelongurl.com/then-we-make-it-super-long-with-some-more/ Lorem Ipsum Lorem Ipsum Lorem Ipsum http://www.anotherlinks.com/"; $string_chunks = explode(' ', $text); foreach ($string_chunks as $chunk) { if($end_x + $chunk > $image_width){ $start_x = 5; $start_y += 20; } $coords = imagettfbbox($fontsize, $angle, $font, $chunk); $end_x = $coords[0] + $coords[4] + 10; $color_to_draw = is_a_url($chunk) ? $linkcolor : $black; imagettftext($im, $fontsize, $angle, $start_x, $start_y, $color_to_draw, $font, $chunk); $start_x += $end_x; } With this code I get: Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem http://somelongurl.com/then-we-make-it-super-long-with-some-more/ Lorem Ipsum Lorem Ipsum Lorem Ipsum http://www.anotherlinks.com/ What I would like to happen is something like: Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem http://somelongurl.com/then-we -make-it-super-long-with-some-more/ Lorem Ipsum Lorem Ipsum Lorem Ipsum http://www.anotherlinks.com/ |