Jump to content

Search the Community

Showing results for tags 'php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. This code is giving me one warning and it is not functioning as it should . Files are below.i have following problems in this code and i dont know where am i doing wrong.i am confused:( . 1. Warning: implode(): Invalid arguments passed in \upload_new\upload.php on line 11 2. it doesnot check the empty fields and upload the image .if i select image only and press upload , it uploads image and dont check for empty fields. 3.i want to display the submitted code , but it doesnot displays. upload.php <?php //session session_start(); $errorPrint = ''; if(isset($_SESSION['form_upload']['errors']) && $_SESSION['form_upload']['errors']) { $errorPrint = $_SESSION['form_upload']['errors']; unset($_SESSION['form_upload']['errors']); } echo implode("<br />",$errorPrint); ?> <!DOCTYPE HTML> <html> <head> <title>Upload Image form</title> </head> <body> <form action="formhandler.php" method="post" enctype="multipart/form-data"> <br><br> Image Title: <input type="text" name="imagetitle" ><br><br> <input type="hidden" name="MAX_FILE_SIZE" value="2000000"> <input type="file" name="userfile" id="userfile" ><br><br> Choose Date: <input type="date" name="pickdate" > <br><br> <input id="button_1" type="radio" name="option" value="button1" /><label for="button_1" >Button 1</label> <input id="button_2" type="radio" name="option" value="button2" /><label for="button_2" >Button 2</label><br><br> <select name="list1"> <option value="">Select Options</option> <option value="option1">Option 1</option> <option value="option2">Option 2</option> <option value="option3">Option 3</option> </select> <br><br> <select name="list2"> <option value="">Select Type</option> <option value="type1">Option 1</option> <option value="type2">Option 2</option> <option value="type3">Option 3</option> </select> <br><br> <input name="upload" type="submit" class="box" id="upload" value=" Upload " > </form> </body> </html> formhandler.php <?php //session session_start(); $_SESSION['form_upload']['errors'] = NULL; $description=$fileSize=$filename=$date=""; if (isset($_POST['upload'])) { if ($_FILES['userfile']['size'] > 0) { echo '<pre>'; // to get this work delete exit function at the bottom print_r($_POST); echo '</pre>'; $allowed_filetypes = array( '.jpg', '.jpeg', '.png', '.gif' ); $max_filesize = 1445760; $description = $_POST['imagetitle']; $filename = $_FILES['userfile']['name']; $ext = substr($filename, strpos($filename, '.'), strlen($filename) - 1); if (!in_array($ext, $allowed_filetypes)) die('The file you attempted to upload is not allowed.'); if (filesize($_FILES['userfile']['tmp_name']) > $max_filesize) die('The file you attempted to upload is too large.'); $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $date= $_POST['pickdate']; $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); if (!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } //!get_magic_quotes_gpc() include 'config.php'; include 'opendb.php'; $query = "INSERT INTO upload (name, size, type, content ,date,description ) " . "VALUES ('$fileName', '$fileSize', '$fileType', '$content', '$date','$description')"; mysql_query($query) or die('Error, query failed'); include 'closedb.php'; echo "<br>File $fileName uploaded<br>"; }//isset($_POST['upload']) && $_FILES['userfile']['size'] > 0 else { echo 'Please Upload an Image.'; } } //isset($_POST['upload']) echo "<h2>Your Input:</h2>"; echo "Title =".$description; echo "<br>"; echo "Filename =".$filename; echo "<br>"; echo "File size =".$fileSize; echo "<br>"; echo "Date =".$date; if($errors) $_SESSION['form_upload']['errors'] = $errors; header('Location: upload.php'); exit; ?>
  2. Hello, I have the follow situation: I have a php login system thats redirect you to another page if the login was successful, the username from the login is stored in a session. So i have the username from the person who logged in, on the website: 'Welcome username'. But i want to have: 'Welcome Full Name'. I already have a sql database with the usernames, passwords and full names, but i don't know how to implement it. Database: Full Name Username Password John Smith john123 mypassword My question to you is if you can write a example code for me, that i can implement it on my login system. Thanks! Regards, Enrico
  3. Hi, I am using a unlimited server for uploading some files but after using so many code , i am not able to achieve my goal. So now i want i use my current server to php code and upload my files into another server, where limit will not be any issue. Example. Let's say i have two server ( www.rajesh.com and www.rathor.com), now i am using below code into www.rajesh.com if (file_exists("http://www.rathor.com/demo/rajesh/" . $_FILES["uploadedfile"]["name"])) { echo $_FILES["uploadedfile"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["uploadedfile"]["tmp_name"], "http://www.rathor.com/demo/rajesh/" . $_FILES["uploadedfile"]["name"]); echo "Stored in: " . "http://www.rathor.com/demo/rajesh/" . $_FILES["uploadedfile"]["name"]; } So i just want to know, is it possible to do? if yes then how i can achieve this? Thanks
  4. I am trying to change the size of the Excerpt box for new posts. I know how to change the excerpt word length in the php code but can't find a solution to changing the size of the box itself. Any help would be appreciated
  5. how can we send message to other mobile numbers using our website setup..? please help..?
  6. Here is my ajax $(".submit").click(function(){ var vp = $("input#vehicle_plate").val(); var vm = $("input#vehicle_model").val(); var vt = $("input#vehicle_type").val(); var da = $("input#date_acquired").val(); var ad = $("input#assigned_driver").val(); var dataString = 'vehicle_plate='+ vp + '&vehicle_model='+ vm + '&vehicle_type='+ vt + '&date_acquired='+ da + '&assigned_driver='+ ad; $.ajax({ type: "POST", url: "process.php", data: dataString, success: function(){ $('.success').fadeIn(200).show(); $('.error').fadeOut(200).hide(); } }); return false; }); And here is my PHP where i pass my 'dataString' <?PHP include("db.classes.php"); $g = new DB(); $g->connection(); if($_POST) { $vehiclePlate = $g->clean($_POST["vehicle_plate"],1); $vehicleModel = $g->clean($_POST["vehicle_model"],1); $vehicleType = $g->clean($_POST["vehicle_type"]); $assignedDriver = $g->clean($_POST["assigned_driver"],1); $ad = date('Y-m-d', strtotime($_POST["datepicker"])); $g->add($vehiclePlate, $vehicleModel, $vehicleType, $assignedDriver, $ad); } $g->close(); ?> And here is my database query public function add($vehiclePlate, $vehicleModel, $vehicleType, $assignedDriver, $ad) { $sql = "insert into vehicles(`vehicle_plates`,`DA`,`type`, `model`, `driver`) values('$vehiclePlate', '$ad', '$vehicleType', '$vehicleModel', '$assignedDriver')"; if(!mysql_query($sql)) { $this->error = mysql_error(); return true; } else { return false; } } the AJax is succesful but when i try and see the table in my databse the inserted row are al 'Undefined' what seems to be causing this?
  7. Respected Users, Few days ago i created a bot site regarding auto comment and response comment etc. but whenever i try to login there using my facebook id and password an error shows up "Login Session Expired". The Problem is with the login script, i am unable to find that errorIts my humble request to you, kindly go through the post and fix me the problem. If u need anything regarding this Error kindly Msg me. Sorry for my poor English. Login PHP Code Posted Below: code removed
  8. When I search my database I can only get results returned back if I search for only a single letter, when I type a whole word I get 0 matches returned. I have the following if statment where I have been trying to get the correct regular expressions but I am unsure where I am going wrong, What expression would I need to use to be able to type in a city name for example Tucson and get a result? if($_POST['filter1'] == "City") { $sqlCommand = "SELECT city_id AS id, city_name AS title FROM city WHERE city_name LIKE '%$searchquery%'"; //$sqlCommand = "SELECT city_id AS id, city_name AS title FROM city WHERE MATCH (city_name) AGAINST ('searchquery')"; //$sqlCommand = "SELECT city_id AS id, city_name AS title FROM city WHERE city_name REGEXP '%$searchquery%'"; }
  9. Hi I am quite wet behind the ears working with php MySQL ect, I have been trying to make a webpage that will search a MySQL database that I have that holds a vareity of information about US States. however when I hit the search button I get the message "No database Selected" ive been trying to figure this out on and off for most of the day. would anyone with more experience be able to see where I am going wrong. Thanks connect.php <?php $dbConnect = array('server' => 'localhost', 'user' => 'root', 'pass' => '', 'name' => 'states2014' ); $db = new mysqli($dbConnect['server'], $dbConnect['user'], $dbConnect['pass'], $dbConnect['name'] ); echo $db ->host_info; echo "<br>"; echo $db ->connect_errno; echo "<br>"; if($db->connect_errno>0) { echo "Database Connection Error".$db->connect_error; exit; } ?> search.php <?php $search_output = ""; if(isset($_POST['searchquery']) && $_POST['searchquery'] != "") { $searchquery = preg_replace('#[^a-z 0-9?!]#i', '', $_POST['searchquery']); if($_POST['filter1'] == "City") { $sqlCommand = "SELECT city_id, city_name AS city_name FROM city WHERE city_name LIKE '%$searchquery%'"; } else if($_POST['filter1'] == "Attractions") { //$sqlCommand = "SELECT city_id, city_name AS city_name FROM city WHERE city_name LIKE '%$searchquery%'"; } else if($_POST['filter1'] == "Famous_Person") { //$sqlCommand = "SELECT city_id, city_name AS city_name FROM city WHERE city_name LIKE '%$searchquery%'"; } include_once("connect.php"); $query = mysql_query($sqlCommand) or die(mysql_error()); $count = mysql_num_rows($query); if($count > 1) { $search_output .= "<hr />$count results for <strong>$searchquery</strong><hr />$sqlCommand<hr />"; while($row = mysql_fetch_array($query)) { $city_id = $row["city_id"]; $city_name = $row["city_name"]; $search_output .= "Item ID: $city_id - $city_name <br/>"; } // close while } else { $search_output = "<hr />0 results for <strong>$searchquery</strong><hr />$sqlCommand"; } } ?> <html> <head> </head> <body> <h2>US States Info</h2> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> Search For: <input name="searchquery" type="text" size="44" maxlength="88"> Within: <select name="filter1"> <option value="City">City</option> <option value="Attractions">Attractions</option> <option value="Famous_Person">Famous_Person</option> </select> <input name="myBtn" type="submit"> <br /> </form> <div> <?php echo $search_output; ?> </div> </body> </html>
  10. I am working on OpenShift and my PHP files in my sub directories are not working when pushed to the server. They work through localhost when using XAMPP so I dont know what is going wrong. Any help would be great. I have a link from my main index.php that links to the one in the subdir but when hosted it just pulls up a blank page. I am not sure if this as something to do with PHP permissions or what. /index.php /racedata/index.php
  11. I'm having trouble understanding this syntax error: Parse error: syntax error, unexpected T_STRING in /home/students/phannum/public_html/n413/ooplr/classes/Cookie.php on line 19 Here it is in my code, highlighted and bolded: <?php class Cookie { public static function exists($name) { return (issest($_COOKIE[$name])) ? true : false; } public static function get($name) { return $_COOKIE[$name]; } public static function put($name, $value, $expiry) { if(setcookie($name, $value, time() + $expiry, '/')) { return true; } return false; } public static function delete($name){ self::put($name, ',' time() - 1); } } Anything to help would be awesome!
  12. Here's my script $( "#button" ).button(); $( "#button" ).click(function( event ) { <?PHP ... ?> }); And here's the input tag <input id="button" type="submit" value="Add" name = "subBtn" /> Whenever i click the button it triggers postback how can i avoid this?
  13. Currently I have 10-15 hours a week available within my schedule which I would obviously like to get filled, so I am available to take on either smaller projects, or larger projects over a longer periods of time. I am by no means a cheap developer, but you get what you pay for. I work professionally as a contracted developer and as such any business dealings will be dealt with in a professional manner following tried and true practices. I have close to ten years experience in the industry, I am an admin on this very forum am an active member of the community here. I have experience with many of the modern frameworks and libraries including Symfony, Laravel, Guzzle & React as well as years of experience maintaining Linux & BSD based servers (mostly Debian, Gentoo and FreeBSD). I work to standards and believe in quality through test driven design and implementation. I can be contacted via a PM on the forums here or emailed directly via trq+freaks at thorpesystems.com https://github.com/trq http://thorpesystems.com
  14. I had a working script that no longer works due to a change in the curl hoping someone4 can help me was told this was a great place to go and that someone would help thanks in advance i included the script and a working account was hoping to make it so all my accounts could be loaded in it account http://play.degeneratesapp.com/?k=1396308992&v=6b66afb791a6139db8aa4c0bcacec66e27174fa1 <?php $id=""; $auth=""; $deposit_heal_cash=TRUE; // Deposits all your cash into bank if needed to heal your account. $target_id[]="1102992285"; // Make as many lines of IDs as you want. ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// echo "\n RACiO - WWW.STFUALLDAY.COM\n Attacker Script v1.0\n\n"; sleep(3); echo "\n \\=============================\\"; echo "\n ...STARTING ATTACKER SCRIPT..."; echo "\n \\=============================\\\n\n\n"; $source_link="http://96.126.127.237/dynamic/"; $stats=file_get_contents($source_link."get_stats.php?target_id=".$id."&user_id=".$id."&auth_key=".$auth); $name= split("<name>", $stats); $name= split("<", $name[1]); $level= split("<level>", $stats); $level= split("<", $level[1]); $cash= split("<cash>", $stats); $cash= split("<", $cash[1]); $decoded_name=urldecode($name[0]); if ($name[0]==""){ echo " Invalid Auth/User ID."; sleep(18923); } $sat=-1; for($l=0; $l<$sat || $sat == -1; $l++){ $stats=file_get_contents($source_link."get_stats.php?target_id=".$id."&user_id=".$id."&auth_key=".$auth); $stamina= split("<stamina>", $stats); $stamina= split("<", $stamina[1]); $bank= split("<stamina>", $stats); $bank= split("<", $bank[1]); $health= split("<health>", $stats); $health= split("<", $health[1]); $max_health= split("<max_health>", $stats); $max_health= split("<", $max_health[1]); $percent_health = (100 * $health[0] / $max_health[0]); if($percent_health < 67){ $heal=file_get_contents($source_link."heal.php?user_id=".$id."&auth_key=".$auth); xml_parse_into_struct($iP=xml_parser_create(), $heal, $iS, $iX); xml_parser_free($iP); $msg="".strip_tags(str_replace("<br>","\n",$iS[$iX['MESSAGE'][0]]['value'])).""; $message=urldecode($msg); if (stristr($message, "declined")&&$deposit_heal_cash==FALSE){ echo " [".$decoded_name."] ".date("H:i:s").": Not enough cash in bank to heal... Deposit more manually or turn 'deposit_heal_cash' to TRUE and restart the program.\n"; sleep(1864); } $heal_pts= split("You regained ", $message); $heal_pts= split(" health", $heal_pts[1]); echo " [".$decoded_name."] ".date("H:i:s").": You regained ".$heal_pts[0]." health.\n"; if (stristr($message, "declined")&&$deposit_heal_cash==TRUE){ $stats=file_get_contents($source_link."get_stats.php?target_id=".$id."&user_id=".$id."&auth_key=".$auth); $cash= split("<cash>", $stats); $cash= split("<", $cash[1]); if($cash < 2000){ echo " [".$decoded_name."] ".date("H:i:s").":Not enough cash to heal... Get more cash and restart the program.\n"; sleep(1864); } $deposit=file_get_contents($source_link."deposit.php?amount=".$cash[0]."&user_id=".$id."&auth_key=".$auth); xml_parse_into_struct($iP=xml_parser_create(), $deposit, $iS, $iX); xml_parser_free($iP); $msg="".strip_tags(str_replace("<br>","\n",$iS[$iX['MESSAGE'][0]]['value'])).""; $message=urldecode($msg); echo " [".$decoded_name."] ".date("H:i:s").": ".$message."\n"; } $stats=file_get_contents($source_link."get_stats.php?target_id=".$id."&user_id=".$id."&auth_key=".$auth); $health= split("<health>", $stats); $health= split("<", $health[1]); $max_health= split("<max_health>", $stats); $max_health= split("<", $max_health[1]); $percent_health = (100 * $health[0] / $max_health[0]); echo " [".$decoded_name."] ".date("H:i:s").": Your account is ".$percent_health."% healed.\n"; } foreach ($target_id as $v => $trolol){ $attack=file_get_contents($source_link."attack.php?target_id=".$trolol."&user_id=".$id."&auth_key=".$auth); xml_parse_into_struct($iP=xml_parser_create(), $attack, $iS, $iX); xml_parser_free($iP); $msg="".strip_tags(str_replace("<br>","\n",$iS[$iX['MESSAGE'][0]]['value'])).""; $message=urldecode($msg); echo " [".$decoded_name."] ".date("H:i:s").": ".$message."\n"; } } ?> } } ?> new curl $url = "http://degeneratesapp.net/dynamic/skill_points.php?user_id=".trim($Vlinks[0])."&auth_key=".trim($Vlinks[1])."&sess=".trim($Vlinks[2]); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET'); curl_setopt($ch, CURLOPT_ENCODING, "UTF8"); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Accept:application/xml, text/xml, */*; q=0.01', 'Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3', 'Accept-Encoding:gzip,deflate,sdch', 'Accept-Language:en-US,en;q=0.8', 'Connection:keep-alive', 'Cookie:; ', 'Host:degeneratesapp.net', 'Referer:http://degeneratesapp.net/degencanvas.php?k=1=1', 'User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31', 'X-Requested-With:XMLHttpRequest', ) ); $data = curl_exec($ch);
  15. Hello. I' have a Table in MySQL That stores data (name/email/time) of when a person last run X script. I'm trying to pull that information for each user unique to their account to display so they know that they've already ran that script today How it works. Run script > Create's Row storing the data > MySQL Events deletes row after 24 hours. My code to display notification if they have already ran it; $sql = 'SELECT a.name, a.time FROM timecheck a, users b WHERE a.name = b.name'; mysql_select_db('My_DB'); $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('Could not get data: ' . mysql_error()); } while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) { echo "Account: {$row['name']} <br> ". "Last Time Run: {$row['time']} GMT -1<br> "; } echo "It seems you have done this already today!"; ?> Now my problem is. It's displaying every row to every user. I want it to only show the user their row... What I've tried. Creating a session variable "$sessionID" $sql = 'SELECT a.name, a.time FROM timecheck a, users b WHERE a.name = b.name AND a.name=$sessionID"'; But I'm not getting any lucky. All help is appreciated, thank you in advance.
  16. Hi, When I run an UPDATE query in my PHP code, nothing happends, no errors or anything. The weardest thing is, is that if I echo the query, it's the correct output. Any other queries that come after them are still executed. This is my query code: mysql_query("UPDATE users SET cash='".clean_string($info["cash"]-$_POST["bet"])."' WHERE login='".$info["login"]."'") or die(mysql_error()); mysql_query("UPDATE objecten SET bank='".clean_string($object["bank"]+$_POST["bet"])."' WHERE type='4' AND land='".$info["land"]."'") or die(mysql_error()); Thanks in advance, iRoot121.
  17. Good day, I want to know if I can save the first entry and delete the remaining duplicate enty. This is what I did to get all the records with duplicate entry SELECT a.*, b.totalCount AS Duplicate FROM table a INNER JOIN ( SELECT email, COUNT(*) totalCount FROM psuser GROUP BY email HAVING COUNT(*) >= 2 ) b ON a.email = b.email ORDER BY a.email,a.userId Sample record result ID , EMAIL 100 , A 101 , A 102 , A 200 , B 222 , B 235 , C 262 , C 276 , D 278 , D 300 , E 301 , E 302 , E 305 , E Don't delete the first entry and delete all those remaining. Can I do that?
  18. On my current blog development project,when the user clicks post reply, is there a way I can have the page retain it's location or to auto scroll the user back down to where they clicked post reply at the buttom of the page? This is most useful when the reply or comment thread is long. Also when their is an error when a user posts a reply, he also needs to be auto scrolled down to the reply/comment form and not the top of the page. Kindly advice steps i may take to address this. Point to note: The reply form posts to itselt, that is the action attribute is blank.Find below an excerpt of my reply.php script. if (isset($_POST['post_reply'])) { $missing = array();//Declare An Array to store any error message if (empty($reply)) { $missing[] = 'Please Enter a reply.'; } if (empty($missing)) { // initialize flag $OK = false; // initialize prepared statement $stmt = $mysqli->stmt_init(); // create SQL $sql = 'INSERT INTO comments (post_content, post_date, post_topic, post_by) VALUES(?, NOW(), ?, ?)'; if ($stmt->prepare($sql)) { // bind parameters and execute statement $stmt->bind_param('sis', $reply, $id, $Memberid); // execute and get number of affected rows $stmt->execute(); if ($stmt->affected_rows > 0) { $OK = true;} } } } if(isset($missing)) { echo '<div class="panel callout error"> <ul>'; foreach ($missing as $key => $values) { echo '<li>'.$values.'</li>'; } echo '</ul></div>'; } //show reply box echo '<form method="post" action=""> <textarea name="reply-content" rows="9"></textarea><br /><br /> <input type="submit" value="Submit reply" name="post_reply" /> </form>';
  19. I'm looking for a PHP Developer, preferably someone who is familiar with MVC frameworks such as Laravel. Please message me your bitbucket code or if you prefer to send in email, I will give you my email after you send a note. Please include your hourly rate or if you prefer to be paid by the project (feature), please list a general explanation of that. This is for a gaming site called Evocality, a sim breeding site. You'll be working with me, the main developer, but this is a long-term project! So please have open availability! Thank you, Haley
  20. I want to edit an xml using PHP and POST from iOS app. The XML Looks like: <?xml version="1.0" encoding="UTF-8"?> <rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"> <channel> <atom:link rel="self" type="application/rss+xml" href="http://www.316apps.site90.net/Test.xml"/> <lastBuildDate>Mon, 3 Feb 2014 09:26:14 -0500</lastBuildDate> <title>Prayer Warrior</title> <description><![CDATA[Prayer Warrior]]></description> <link>http://www.316apps.site90.net</link> <language>en</language> <copyright>2014 Prayer Warrior</copyright> <item> <first_name>John</first_name> <last_name>Doe</last_name> <title>I need money</title> <date>Mon, 3 Feb 2014 09:26:14 -0500</date> <anonymous>No</anonymous> <prayer_warriors>1</prayer_warriors> <location>USA</location> </item> <item> <first_name>Jane</first_name> <last_name>Doe</last_name> <title>I need money</title> <date>Tue, 4 Feb 2014 09:26:14 -0500</date> <anonymous>No</anonymous> <prayer_warriors>1</prayer_warriors> <location>USA</location> </item> </channel> </rss> Over time, the XML will grow. In my iOS app I have a UITableView that parses the XML into different rows. When they view a row, I want it to increase the count on the prayer. PHP I am using now is: <?php $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $title = $_POST['title']; $xml = simplexml_load_file("http://www.316apps.site90.net/Test.xml") or die("Not loaded!\n"); $responses = $xml->xpath("//channel/item[title = $title and first_name = $first_name and last_name = $last_name]/prayer_warriors"); $responses[0][0] = $responses[0] + 1; print_r($responses); $xml->asXML("Test.xml"); ?> The iOS app uses this code for POST to it: RSSEntry *entry = [_allEntries objectAtIndex:indexPath.row]; NSString *myRequestString = [NSString stringWithFormat:@"first_name=%@&last_name=%@&title=%@", entry.firstName, entry.lastName, entry.prayerRequest]; // Create Data from request NSData *myRequestData = [NSData dataWithBytes: [myRequestString UTF8String] length: [myRequestString length]]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString: @"http://www.316apps.site90.net/Increase.php"]]; // set Request Type [request setHTTPMethod: @"POST"]; // Set content-type [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"]; // Set Request Body [request setHTTPBody: myRequestData]; // Now send a request and get Response NSData *returnData = [NSURLConnection sendSynchronousRequest: request returningResponse: nil error: nil]; // Log Response NSString *response = [[NSString alloc] initWithBytes:[returnData bytes] length:[returnData length] encoding:NSUTF8StringEncoding]; NSLog(@"Response%@",response); However, nothing changes, and I get an invalid predicate message on the response on my iPhone for the line: $responses = $xml->xpath("//channel/item[title = $title and first_name = $first_name and last_name = $last_name]/prayer_warriors"); Thoughts?
  21. In the bulletin board, that i am designing, I have included a bbcode script shown below. Also, I am using htmlentities to sanitize user input. However for the user-submitted code (via use of bbcode tag) to be printed out when a user views the topics page, I had to implement array_flip() which is capable of reversing the text-to-HTML translation achieved with htmlentities(). My question is, does this sequence of operation compromise the site and is there a better way of doing this? htmlentities $post_content= htmlentities(stripslashes($_POST['post_content'])); bbcode script. function phpbbcode($s) { $s = str_replace("]\n", "]", $s); $match = array('#\[php\](.*?)\[\/php\]#se'); $replace = array("'<span>'.highlight_string(stripslashes('$1'), true).'</span>'"); return preg_replace($match, $replace, $s); } array_flip Script. $text=$comments_row['post_content']; $entities = get_html_translation_table(HTML_ENTITIES); $translate = array_flip($entities); $new_text=strtr($text, $translate); echo $new_text;
  22. Hi, I create a simple code to upload file using php code. index.php <?php @ini_set('upload_max_filesize', '1024000000000M'); @ini_set('post_max_size', '1024000000000M'); @ini_set('max_input_time', 3600000000000); @ini_set('max_execution_time', 3600000000000); ?> <!doctype html> <head> <title>Proalbum: File Upload </title> <style> body { padding: 30px } form { display: block; margin: 20px auto; background: #87bb2f; border-radius: 10px; padding: 15px } .progress { position:relative; width:400px; border: 1px solid #ddd; padding: 1px; border-radius: 3px; background:#FF0000;} .bar { background-color:#87bb2f; width:0%; height:20px; border-radius: 3px; } .percent { position:absolute; display:inline-block; top:3px; left:48%; } </style> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <h1>Select a File to Upload</h1> <form action="video_upload.php" method="post" enctype="multipart/form-data"> <input type="file" name="uploadedfile"><br> <input type="submit" value="Upload File"> <input type="hidden" name="MAX_FILE_SIZE" value="99999999"/> </form> <div class="progress"> <div class="bar"></div > <div class="percent">0%</div > </div> <div id="status"></div> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script> <script src="http://malsup.github.com/jquery.form.js"></script> <script> (function() { var bar = $('.bar'); var percent = $('.percent'); var status = $('#status'); $('form').ajaxForm({ beforeSend: function() { status.empty(); var percentVal = '0%'; bar.width(percentVal) percent.html(percentVal); }, uploadProgress: function(event, position, total, percentComplete) { var percentVal = percentComplete + '%'; bar.width(percentVal) percent.html(percentVal); }, complete: function(xhr) { bar.width("100%"); percent.html("100%"); status.html(xhr.responseText); } }); })(); </script> </body> </html> video_upload.php <?php @ini_set('upload_max_filesize', '1024000000000M'); @ini_set('post_max_size', '1024000000000M'); @ini_set('max_input_time', 3600000000000); @ini_set('max_execution_time', 3600000000000); //$upload_dir = $_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF']); $upload_dir='rajesh'; $upload_url = '/'; $temp_name = $_FILES['uploadedfile']['tmp_name']; $file_name = $_FILES['uploadedfile']['name']; $file_path = $upload_dir.$upload_url.$file_name; if(move_uploaded_file($temp_name, $file_path)) { echo "File uploaded Success !"; } ?> and php.ini max_execution_time: 3600000000000 max_input_time 3600000000000 post_max_size 1024000000000M upload_max_filesize 1024000000000M and in .htaccess file php_value max_execution_time 3600000 php_value max_input_time 3600000 php_value post_max_size 1024000M php_value upload_max_filesize 1024000M But still can't able to upload file more than 20 mb. Can anyone please help me in this. Thanks
  23. I am learning to build a shopping cart script. When a new item is added to the cart that already has the new item added, rather than use array_splice to update the existing cart quanties, I want to do the following: Check if the item already exists in the cart, provide feedback to the user that, he has already added that item to cart. Use array_unique to eliminate the duplicate item. So far, my use of array_unique in my cart.php script below is not working, with regard to providing user feedback. Note: I have executed array_splice() to be sure the item quantity is increased before attempting to use array_unique to remove the duplicate item. I will appreciate any help in resolving this. CART.PHP if (isset($_POST['pid'])) { $pid = $_POST['pid']; $wasFound = false; $i = 0; // If the cart session variable is not set or cart array is empty if (!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) { // RUN IF THE CART IS EMPTY OR NOT SET $_SESSION["cart_array"] = array(0 => array("item_id" => $pid, "quantity" => 1)); } else { // RUN IF THE CART HAS AT LEAST ONE ITEM IN IT foreach ($_SESSION["cart_array"] as $each_item) { $i++; while (list($key, $value) = each($each_item)) { if ($key == "item_id" && $value == $pid) { // That item is in cart already so let's prevent its addition using array_unique() array_splice($_SESSION["cart_array"], $i-1, 1, array(array("item_id" => $pid, "quantity" => $each_item['quantity'] + 1))); $wasFound = true; echo 'item already in cart'; array_unique($_SESSION["cart_array"]); } // close if condition } // close while loop } // close foreach loop if ($wasFound == false) { array_push($_SESSION["cart_array"], array("item_id" => $pid, "quantity" => 1)); } } header("location: cart.php"); exit(); }
  24. Hi guys I know this might be a repeated post, someone has looked at the code and they seem to think that it all look fine, but I'm getting this following message again Warning: mysqli_query(): Couldn't fetch mysqli in C:\xampp\htdocs\submit-form.php on line 19 The following SQL Failed INSERT INTO 'users' ('firstname', 'lastname', 'username', 'confirmusername', 'password', 'confirmpassword', 'email' ,'confirmemail') VALUES ('richard', 'Hemmings', 'hemmo001', 'hemmo001', 'password', 'password', 'richardgwhemmings@msn.com' , 'richardgwhemmings@msn.com') I just cant seem to see where I'm going wrong, at first there was a single quote missing from firstname' this I have now addressed, I've been woriking on this now for 2 weeks today! Config.php <?php $connection = mysqli_connect("localhost","root","","registration"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } mysqli_close($connection); ?> submit-form.php <?php $connection = mysqli_connect("localhost", "root", "", "registration") or die("Error!!"); //select your database //$b=mysql_select_db("Registration",$a); $firstname=$_POST['firstname']; $lastname=$_POST['lastname']; $username=$_POST['username']; $confirmusername=$_POST['confirmusername']; $password=$_POST['password']; $confirmpassword=$_POST['confirmpassword']; $email=$_POST['email']; $confirmemail=$_POST['confirmemail']; //Database connection require_once("config.php"); //mysql query to insert value to database $query = "INSERT INTO `users` (`firstname`, `lastname`, `username`, `confirmusername`, `password`, `confirmpassword`, `email`, `confirmemail`) VALUES ('$firstname', '$lastname', '$username', '$confirmusername', '$password', '$confirmpassword', '$email', '$confirmemail')"; $result = mysqli_query($connection,$query); //if value inserted successyully disply success message if(!$result) { die("The following SQL Failed $query"); } echo 'Registred successfully..!!</div>'; ?> Any help would be appreciated
  25. Hi I have one issue. I do not know how to solve and also no idea. It is my scenario. I have Product table with details,selling price, purchase price and so on. I want to invoice to clients. Clients can buy lots of item in single invoice. If I select product, it will display the Name of item,Sell price Uom in text box. If I click the add button, it will show in grid in php page. I have to do this one by one until client's ordered items completed. Then I click submit, then the items in Grid should be saved into Mysql Data table. It look like cart, but not If there is any idea and how to do this, pls share your knowledge with me. Thank you Maideen
×
×
  • 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.