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. Hello, I'm pretty new at building websites using php (and mysql) and was most recently given the task to create a database image gallery, which was to be accessed through a php website. I made a full site which allowed me to upload said images & it worked perfectly. However after doing my last checks I have been told that mysql is deprecated and that I need to use mysqli. I've had a look at some tutorials on websites to help direct me but it's simply confusing me more and more each time I look at it. Is it possible I am over thinking this and there is an easier way to approach it? Thank you kindly. This is my php code:
  2. Hi I'm currently experiencing problems with my super global outputs. I'm using to retrieve info but in the place of a space it gets replaced with a + I've also tried using special characters like this in my name But the output is Is there maybe a way to clean it up to show as normal text in Sentence case?
  3. Hello everybody! I have been asked by a customer to develop a GTP website (Get To Pay, those websites where people earn money from clicking on ads). I managed to write the backend, signup and login but I am unsure how the ads part, with built-in user-tracking works and fallback link works. I would really appreciate any kind of help. Thank you very much! P.S. For the user tracking I was thinking of sessions with matching ip and user agents together with an anti-proxy online service (e.g. MaxMind, Proxystop, ...)
  4. I am trying to create a simple voting form. Everything goes well until I submit and then I get a Warning: mysqli_error() expects exactly 1 parameter, 0 given on line 79 error. I am assuming it is not pulling the ID correctly but as I am new to php and mysqli I cannot exactly say if it the way the code is written or if I am calling the parameter incorrectly in the query. Again I am new to to this so please be gentle. Below is my code. It pulls the drop down list correctly and echo's correctly but I believe my post query to be a little out of wack. Could someone point me in the correct direction? It would be very appreciated. <form action="businesstype_update.php" method="post"> <?php if(isset($_POST['voteall'])){ $vote_lg = "update membertest where id={$row_lg['id']} set vote=vote+1"; $run_lg = mysqli_query($con, $vote_lg) or die(mysqli_error()); } $result_lg = mysqli_query($con, "SELECT id, business FROM membertest WHERE businesstype='large'"); echo "Vote for large business of the year! <SELECT name='business'>\n"; echo "<option>Select a large business</option>"; while($row_lg = $result_lg->fetch_assoc()) { echo "<option value='{$row_lg['id']}'>{$row_lg['business']}</option>\n"; } echo "</select></br></br>\n"; echo "<input type='submit' name='voteall' value='voteall'>"; $result_lg->close(); $con->close();
  5. HI. I have written a mysql database query to add up invoice totals. It seems to be automatilaly adding .01 to the result when I run a group by. Let me explain more .. When I do a select on the field that I am adding up the result is $132.25 - the query is as follows select ttl_invoice_due from 65_it where st_id = 96011; When I run the following query that uses sum and group by - the $132.25 becomes $132.26 - the sum query is SELECT 65_st.job_compid, 65_client.uid_client, 65_client.comp_name, Sum(65_it.ttl_invoice_due) AS SumOftotal_due, Sum(65_it.ttl_invoice) AS SumOftotal_invoice, Sum(65_it.ttl_invoice_payments) AS SumOftotal_amnt_paid FROM 65_client INNER JOIN (65_st INNER JOIN 65_it ON 65_st.st_id = 65_it.st_id) ON 65_client.uid_client = 65_st.uid_client WHERE 65_st.uid_client = 1905 and 65_st.job_compid = 1 and 65_st.sales_date<=curdate() GROUP BY 65_st.job_compid, 65_client.uid_client HAVING (((Sum(65_it.ttl_invoice_due))<>0)) order by 65_client.comp_name; The 65_it.ttl_invoice_due field is defined in the table as Double(12,2) I dont know why the sum is returing $132.26 where it should be $132.25 as in the simple query ?.
  6. Im setting up members on my site i want the profile url to be like www.mywebsite.com/NATHAN but not go to a folder on my server called nathan but instead go to mywebsite.com/?profile=Nathan
  7. <?php $i = 2; $i = $i++; echo $i; ?> Output of above code is 2. <?php $i = 2; $p = $i++; echo $i; ?> Output of above code is 3. Why this difference? I mean how these codes are processed to give an output?
  8. I have this code and its downloading file nicely. But I want to show a progress bar while downloading file from external server. My existing code shows progress bar but its not effective (ex. if i try to download two media file, one video and another audio, and video size is larger than audio size the audio finishes first and the progress bar shows 100% also suddenly it drops to 50% as the video is still downloading ). I mean it actually shows two progress and I need one. If I could get average percentage value of two progress that would be better. Any suggestion regarding this will be greatly appreciated. <?php set_time_limit ( 0 ); function define_progress_callback($i) { global $conn; curl_setopt($conn[$i], CURLOPT_PROGRESSFUNCTION, function ($resource,$download_size, $downloaded, $upload_size, $uploaded) { if($download_size > 0) $progress = round($downloaded / $download_size * 100); echo '<script language="javascript">$(".loader").loader("setProgress", '.$progress.');</script>'; echo str_pad("",1024," "); flush(); usleep(20000); }); } $urls = array("http://example.com/file.mp3", "http:/example.com/file.mp4"); $save_to='./tmp/'; $conn = array(); $fp = array(); $mh = curl_multi_init(); foreach ($urls as $i => $url) { $g = $save_to . basename($url); $conn[$i]=curl_init($url); $fp[$i]=fopen ($g, "wb"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // No certificate curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt ($conn[$i], CURLOPT_FILE, $fp[$i]); curl_setopt ($conn[$i], CURLOPT_HEADER ,0); curl_setopt($conn[$i],CURLOPT_CONNECTTIMEOUT,60); curl_setopt ($conn[$i], CURLOPT_MAXCONNECTS, 10); curl_setopt($conn[$i], CURLOPT_NOPROGRESS, false); define_progress_callback($i); curl_multi_add_handle ($mh,$conn[$i]); } do { $n=curl_multi_exec($mh,$active); } while ($active); foreach ($urls as $i => $url) { curl_multi_remove_handle($mh,$conn[$i]); curl_close($conn[$i]); fclose($fp[$i]); } curl_multi_close($mh); ?>
  9. Hello guys, I was just wondering what I was doing wrong here, I've 'created' a website form in PHP but when I click my submit button it doesn't seem to fetch: php.php?s=1 or php.php?s=2 which is then used to print either Success or Failure. Here's my code: <html> <head> <title></title> <meta charset="utf-8" /> <link rel="stylesheet" href="footer.css" type="text/css"/> <link rel="stylesheet" href="header.css" type="text/css"/> <link rel="stylesheet" href="php/phpbody.css" type="text/css"/> </head> <!--body--> <body> <div id="container"> <h3 id="h3">Contact Me:</h3> <?php $s = isset($_GET['s']) ? $_GET['s'] : ''; if ($s=="1") { echo ('<span class="success">Success! Your enquiry has been sent.</span>'); }else if ($s=="2"){ echo ('<span class="fail">Sorry! Your enquiry has not been sent. Please ensure you have filled in the form correctly.</span>'); } ?> <h5 id="h5">To contact me, please use this form, created with PHP:</h5> <form id="form1" name="form1" method="POST" action"php/send.php"> <strong>First Name:</strong><br><input type="text" name="firstname" id="firstname"><br><br> <strong>Last Name:</strong><br><input type="text" name="lastname" id="lastname"><br><br> <strong>E-mail:</strong><br><input type="text" name="email" id="email"><br><br> <strong>Enquiry:</strong><br><textarea name="enquiry" id="enquiry" cols="45" rows="5"></textarea><br><br> <strong>Security:</strong> 6 + 4 = <input type="text" name="security" id="security" size="1"><br><br> <input type="submit" name="submit" id="submit" value="Submit"/> </form> </div> <?php include('header.php'); ?> <?php include('footer.php'); ?> </body> </html> Send.php: <?php $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $email = $_POST['email']; $enquiry = $_POST['enquiry']; $security = $_POST['security']; $to = "example@Outlook.com"; $subject= "New Form Enquiry"; $message = "A potential employer has submitted an enquiry from your website:\n\n First Name: $firstname\n\n Last Name: $lastname\n\n Email: $email \n\n Enquiry: $enquiry\n\n You should probably respond."; if($security = "10"){ mail($to,$subject,$message); header("Location:php.php?s=1"); //php.php being the forms location }else{ header("Location:php.php?s=2"); //php.php being the forms location } ?> Any ideas would be much appreciated. Thanks.
  10. Sir/ma'am, With the script I'm using to run my website, I've been trying to add an additional feature for the users to add/edit. I'll try to provide as much info as I can, hopefully it'll help. Here is the code I'm using to display the user's unique info from the db. <a class="wallet-edit"><?php echo $_SESSION['simple_auth']['INFO']?></a> That displays the user's info from the column 'INFO' perfectly. It's also a js popup to a menu to where I'm hoping to add a single textbox to edit the INFO. The script uses a similar function to edit the password with a popup. I've tried modifying the code to edit the INFO column but it doesn't work. Here is the default code it has to edit the password. I'm not sure if it can be changed to edit another column or needs a new piece of code for that. // user edit $('body').on('click', '.username-edit', function() { $('#modal').html(' '); var output = '<div class="modal-content"><h5><?php echo lang::get("Change password")?></h5><hr />'; output += '<h5><?php echo lang::get("New password:")?></h5><input type="password" name="password" id="password" value="" class="text ui-widget-content ui-corner-all" />'; output += '<h5><?php echo lang::get("Confirm password:")?></h5><input type="password" name="password2" id="password2" value="" class="text ui-widget-content ui-corner-all" />'; output += '</div>'; output += '<div class="modal-buttons right">'; output += '<button id="confirm-button" type="button" class="nice radius button"><?php echo lang::get("Change")?></button>'; output += '</div>'; output += '<a class="close-reveal-modal"></a>'; $('#modal').append(output); $('#second_modal').hide(); $('#modal').reveal(); $('#confirm-button').click(function(){ $('#password').css('border-color', '#CCCCCC'); $('#password2').css('border-color', '#CCCCCC'); var password = $('#password').val(); var password2 = $('#password2').val(); if(typeof(password) === 'undefined' || password == ''){ $('#password').css('border-color', 'red'); return false; } if(password != password2){ $('#password2').css('border-color', 'red'); return false; } password_data = encodeURIComponent(password); $.post("<?php echo gatorconf::get('base_url')?>", { changepassword: password_data} ).done(function(data) { // flush window.location.href = '<?php echo gatorconf::get('base_url')?>'; }); }); }); If the code above can be edited to work with what I'm trying to do, it of course only needs one textbox and doesn't have to be confirmed by a second input. Please help! Thanks!
  11. Here's the code that deals with the client side: search.php <?php //testing if data is sent ok echo "<h1>Hello</h1><br>" . $_GET['search']; ?> This is the link I get after sending foo. http://www.family-line.dx.am/Community/index.php?&search=foo Is that mean it was sent, but I'm not processing it correctly? I'm new to the whole AJAX thing.
  12. I have some files saved outside the webroot and need to allow posts in WordPress to be able to access the files. Following is the location of one of the files: /home1/Mathone/TESTS/Test1/index1.html I created a Download.php file with the following code and saved it to public_html of my site: <?php $path = '/home1/Mathone/TESTS/'. $_GET['filename']; $mm_type="application/octet-stream"; header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Type: " . $mm_type); header("Content-Length: " .(string)(filesize($path)) ); header('Content-Disposition: attachment; filename="'.basename($path).'"'); header("Content-Transfer-Encoding: binary\n"); readfile($path); // outputs the content of the file exit(); ?> Next, I created a post in wordpress with the following link: <a href="www.mysite.com/download.php?filename=Test1/index1.html">download</a> I am getting an error This is somewhat embarrassing, isn’t it? It seems we can’t find what you’re looking for. Perhaps searching can help. Can anyone tell me what I am doing wrong? Thank you
  13. i have a form for my admin to update the products and their deails on my site. but i have decided to add stock and supplier tables to the database. so i have a products table, stock and supplier. each have an id. in my admin form, id like the admin to submit once to multiple tables... php code that i need to improve <?php // Parse the form data and add inventory item to the system if (isset($_POST['product_name'])) { $product_name = $_POST['product_name']; $price = $_POST['price']; $category = $_POST['category']; $stock = $_POST['stock']; $details = $_POST['details']; $rating =$_POST['rating']; $letter = $_POST['letter']; $supplier = $_POST['supplier']; // See if that product name is an identical match to another product in the system $sql = mysqli_query($con, "SELECT id FROM products WHERE product_name='$product_name' LIMIT 1"); $productMatch = mysqli_num_rows($sql); // count the output amount //if product match is greater than 0 if ($productMatch > 0) { echo 'Sorry you tried to place a duplicate "Product Name" into the system, <a href="inventory_list.php">click here</a>'; exit(); } // Add this product into the database now by sql query $sql = mysqli_query($con, "INSERT INTO products (product_name, price, details, category, stock, letter, supplier, rating, date_added) VALUES('$product_name','$price','$details','$category', '$stock' ,'$letter',' $supplier' , '$rating' now())") or die (mysqli_error()); $pid = mysqli_insert_id($con); // Place image in the folder $newname = "$pid.jpg"; move_uploaded_file($_FILES['fileField']['tmp_name'], "../inventory_images/$newname"); //_FILES is a global var header("location: inventory_list.php"); //auto refresh, and it wont try to re add the item exit();//not necessary but its always safe to exit } ?> html form <form action="inventory_list.php" enctype="multipart/form-data" name="myForm" id="myForm" method="post"> <table width="95%" border="0" align="center" cellpadding="5" cellspacing="0" summary="this is where the admin will insert new items"> <caption><div id="title"><a id="add_new_item"></a>Add New Inventory Item</div> </caption> <tr > <th width="30%" scope="col" align="left">Product Image</th> <th width="70%"><label class="desc"> <input type="file" name="fileField" id="fileField" autofocus required /> </label></td> </tr> <tr > <th width="30%" scope="col" align="left">Product Name</th> <th width="70%" scope="col" align="left"> <label class="desc"> <input name="product_name" type="text" id="product_name" size="64" autofocus required /> </label></th> </tr> <tr> <th width="30%" scope="row" align="left">Letter</th> <td width="70%"> <label class="desc"> <input name="letter" type="text" id="letter" autofocus required /> </label></td> </tr> <tr> <th width="30%" scope="row" align="left">Product Price</th> <td width="70%"> <label class="desc"> <input name="price" type="text" id="price" autofocus required /> </label></td> </tr> <tr> <th width="30%" scope="row"align="left">Category</th> <td width="70%"><label class="desc"> <select name="category" id="category"> <option value="Fruits">Fruits</option> <option value="Vegetables">Vegetables</option> <option value="Indoor Plants">Indoor Plants</option> <option value="Outdoor Plants">Outdoor Plants</option> </select> </label></td> </tr> <tr> <th width="30%" scope="row" align="left">Suppliers</th> <td width="70%"> <label class="desc"> <select name="supplier" id="supplier"> <option value="Kenny's Organic Supplies">Kenny's Organic Supplies</option> <option value="Mom's Garden">Mom's Garden</option> <option value="Big Brother">Big Brother</option> </select> </label></td> </tr> <tr> <th width="30%" scope="row" align="left">Stock</th> <td width="70%"> <label class="desc"> <input name="stock" type="text" id="stock" autofocus required /> </label></td> </tr> <tr> <th width="30%" scope="row"align="left">Product Details</th> <td width="70%"><label class="desc"> <textarea name="details" id="details" cols="35" rows="5" autofocus required></textarea> </label></td> </tr> <tr> <th width="30%" scope="row" align="left">Rating</th> <td width="70%"><label class="desc"> <select name="rating" id="rating" > <option value="1">1 of 3 Stars</option> <option value="2">2 of 3 Stars</option> <option value="3">3 of 3 Stars</option> </select> </label></td> </tr> <tr> <th width="30%" scope="row"> </th> <td width="70%" align="right"><label class="desc"> <input type="submit" name="button" id="button" value="Add This Item Now" /> </label></td> </tr> <tr> <th width="30%" scope="row"> </th> <td width="70%"> </td> </tr> </table> </form>
  14. HI, I am triying to check a domain is valid or not using PHP. If the domian is not a valid one the name shoud be empty string. So I tried using preg_match() and preg_replace(). But I couldn't get it to work. This is my code sofar - if (preg_match ('/^((?!-)[A-Za-z0-9-]{1,63}(?<!-)\\.)+[A-Za-z]{2,6}$/', $domain)) { $mydomain = $domain; } else { $mydomain = preg_replace("/^((?!-)[A-Za-z0-9-]{1,63}(?<!-)\\.)+[A-Za-z]{2,6}$/", "", $domain); } When I am tring using valid and invalid domain name its always going to else part. Eg: example.com example.t.t.c Hope somebody may help me out. Thank you.
  15. Hi, I'm quite new to OOP PHP and i'm trying to make a dynamic insert function , i've followed an example on Stackoverflow to do so since its my first try at making something dynamic.http://stackoverflow.com/a/13333344/3559635 It works but im still quite confused about the two foreach loops , and if possible could someone explain that part to me please and or is there an easier more clean way to do this for a new guy like me? Im sending my POST values from the index.php <?php include("Database.php"); $db = new Database(); var_dump($db); $table = "users"; $whitelist = array('username', 'password'); $data = array_intersect_key($_POST, array_flip($whitelist)); if(isset($_POST['username']) AND ($_POST['password'])) { $db->postTesting($data, $table); } else { echo "Please fill in everything!"; } Database.php <?php class Database { private $connection; private $typedb = "mysql"; private $host = "127.0.0.1"; private $dbname = "oopphp"; private $username = "root"; private $password = ""; public function __construct() { try{ $this->connection = new PDO($this->typedb. ":host=".$this->host. ";dbname=".$this->dbname, $this->username, $this->password); $this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); return $this->connection; } catch(PDOException $e) { throw new Exception("Connection failed: ".$e->getMessage()); } } public function postTesting($data, $table) { try{ //var_dump($table, $data); $columns = ""; $holders = ""; foreach ($data as $column => $value) { //var_dump($column); //var_dump($value); $columns .= ($columns == "") ? "" : ", "; $columns .= $column; $holders .= ($holders == "") ? "" : ", "; $holders .= ":$column"; //var_dump($columns); //var_dump($holders); } $sql = "INSERT INTO $table ($columns) VALUES ($holders)"; //return $sql; $stmt = $this->connection->prepare($sql); //var_dump($stmt); foreach ($data as $placeholder => $value) { $stmt->bindValue(":$placeholder", $value); //var_dump($stmt); //var_dump($placeholder); //var_dump($value); } //var_dump($sql); //var_dump($stmt); $stmt->execute(); } catch(PDOException $rError) { throw new Exception("Registering Failed: ".$rError->getMessage()); } } } Im seriously confused about this part. foreach ($data as $column => $value) { //var_dump($column); //var_dump($value); $columns .= ($columns == "") ? "" : ", "; $columns .= $column; $holders .= ($holders == "") ? "" : ", "; $holders .= ":$column"; //var_dump($columns); //var_dump($holders); } Thanks in advance for the help
  16. Right now my website url appears like this. http://www.mywebsite.com/index.php I was wondering if there is a way to remove the index.php and just have it show like this when someone goes to the website? http://www.mywebsite.com
  17. So I have been slowly working on a custom forum. I have recently been trying to implement an achievement system. For the most part achievements would work based on the users amount of posts amount of characters in a post amount of replies on a post time past from the users join date. I was hoping to find out how I could put an entry into a database field based on the above. Any help would be greatly appreciated
  18. About the project. We are looking to build a Car Dealer Platform (CMS) to be able to offer it as a “Software as a Service” to range of our clients. What we would like to achieve is something similar to what is currently available on the market. I did a little research and the are a lot of scripts, plugins, software and such already available online (i.e. http://www.hotscripts.com/category/scripts/php/scripts-programs/classified-ads/autos/, http://www.worksforweb.com/classifieds-software/iAuto/, http://intersofts.com/) however, we require some functionality that are not included in the above mentioned and we want this to be a bespoke platform tailored for us. The platform must have: ability to accommodate Comcar data (http://comcar.co.uk/) ability to accommodate Cap data (http://www.cap.co.uk/) ability to accommodate finance calculator (i.e. https://ivendi.com/) ability to accept stock feeds from Dealership Management System (i.e. http://www.2ndbyte.com/) ability to send used car stock feed to used car portals such as AutoTrader (http://www.autotrader.co.uk/), Motors (http://www.motors.co.uk/), AA Cars (http://www.vcars.co.uk/) full registration lookup on used car stock through a Vehicle Registration Mark (http://business.cap.co.uk/products-and-services/vrm-look) Service and MOT booking to include registration lookup easily add multi locations and assign stock for each location capture leads via contact forms of course must be responsive, SEO friendly and compliant with the latest web standards easy to add new pages, locations, franchise easy to upload the offer banners for the home page easy to customize for each client / dealer (CSS, HTML, JS) I am fully aware this is not a small project and it will take a lot of time and manpower to accomplish this, however I am positive about it. This would be developed in stages so we could start offering it to our clients with ideally long time support from the creators of the platform. Here are some examples of platforms currently available on the market and few websites created based on these platforms: NetDirector - http://www.gforces.co.uk/ http://www.hrowen.co.uk/ http://www.thurlownunn.co.uk/ http://www.deswinks.com/ http://www.glynhopkin.com/ http://www.trustford.co.uk/ http://www.westlandsmotorgroup.co.uk/ (as two franchises and uses latest version of platform) Web21st - http://www.web21st.com/ http://www.wjking.co.uk/ http://www.sussexusedcars.uk.com/ http://www.wilsonandco.com/ http://www.findvauxhall.co.uk/ Bluesky Interactive - http://www.blueskyinteractive.co.uk/ - Cognition CMS based (http://www.blueskyinteractive.co.uk/admin/) http://www.fish-bros.co.uk/ http://www.nowvauxhall.co.uk/ http://www.alandayvw.co.uk/ http://dinnages.co.uk/ http://griffinmill.co.uk/ Denison Automotive - http://www.denison.co.uk/automotive/ http://www.perrys.co.uk/ http://www.trusteddealers.co.uk/ http://www.westwaynissan.co.uk/ http://www.tilsungroup.com/ Please feel free to PM me anything related to the topic and ask questions if something is unclear as well as if you require more info. What I am hoping to achieve by posting this here is to get some advice from experienced / senior php developers to point us in the right direction and hopefully to start a partnership. We are based in North London. Thank you. Alek
  19. Hi there, new to the forum Ok so i have a crm and i'm trying to add bits, been pretty succesful at most of it, however i've added a new field "status" and i want to be able to search this field, i've tried copying and changing the existing code, but it doesn't seem to be grabbing it. So here's some exisiting code (that works and searches the field marked "Address" 'address' => array( 'title' => _l('Address:'), 'field' => array( 'type' => 'text', 'name' => 'search[address]', 'value' => isset($search['address'])?$search['address']:'', 'size' => 15, ) ), 'status' => array( 'title' => _l('Status:'), 'field' => array( 'type' => 'text', 'name' => 'search[status]', 'value' => isset($search['status'])?$search['status']:'', 'size' => 15, ) ), I thought a simple name change like above would work, but it doesn't pull anything through, anyone got any ideas?
  20. Hi, I'm using TCPDF to create a PDF from a webpage. This works great but I have the following problem: I'm building in WordPress and as you may know WP saves images on different sizes. (e.g. 150x150, 300x300 and 1024x1024) The thing I'm trying to create is that users can download a PDF ready for printing. So High Resolution images. I use a preg_match_all function to match the image source and remove the additional image size from the filename so the original high resolution image is loaded. e.g. image-150x150.jpg will be replaced by image.jpg. So now the original image that has a image size of 6024x6024px and 300 DPI is loaded. Then TCPDF uses a resize function that resizes the image back to 150x150 px but sets the DPI to 300 so it can be printed on a good quality. This all works but now the problem comes: If I do the preg_match_all function the image gets "pulled" from the rest of the content and looses it's position. So my thought to fix this was. Get a preg_replace function and replace the image tag with a function that executes the whole image change like described above. This doesn't work...... So i'm stuck here. Hope anyone can assist me with this. Here is what I have done so far. function execute(){ preg_match_all("/<img[^>]+src=(?:\"|\')\K(.[^\">]+?)(?=\"|\')/",$content,$matches,PREG_PATTERN_ORDER); for( $i=0; isset($matches[1]) && $i < count($matches[1]); $i++ ) { $search = array('-'.$s1.'x'.$s2.'', '-'.$s3.'x'.$s4.'', '-'.$s5.'x'.$s6.''); $replace = array('', '', ''); $a = $matches[1][$i]; if (strpos($a,'-'.$s1.'x'.$s2.'') !== false) { $w = $s1; $w = $pdf->pixelsToUnits($w); $h = $s2; $h = $pdf->pixelsToUnits($h); $l = '57'; $l = $pdf->pixelsToUnits($l); $t = '170'; $t = $pdf->pixelsToUnits($t); }elseif (strpos($a,'-'.$s3.'x'.$s4.'') !== false) { $w = $s3; $w = $pdf->pixelsToUnits($w); $h = $s4; $h = $pdf->pixelsToUnits($h); $l = '217'; $l = $pdf->pixelsToUnits($l); $t = '20'; $t = $pdf->pixelsToUnits($t); }elseif (strpos($a,'-'.$s5.'x'.$s6.'') !== false) { $w = $s5; $w = $pdf->pixelsToUnits($w); $h = $s6; $h = $pdf->pixelsToUnits($h); $l = '57'; $l = $pdf->pixelsToUnits($l); $t = '310'; $t = $pdf->pixelsToUnits($t); } $content .= $pdf->Image(str_replace($search,$replace,$matches[1][$i]), $l, $t, $w, $h, 'JPG', '', '', true, 300, '', false, false, 0, false, false, false); } }; global $post; $id = $_GET['id']; $content_post = get_post($id);// get the content $content = $content_post->post_content; $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); $content = preg_replace('/<img[^>]+./e',execute(), $content); // replace the image tag with the new image // EXPORT IT ALL $pdf->writeHTML($content, true, false, true, false, '');
  21. hi, im a php noob trying to echo session variable based on what the user name is but neither is the session initialising nor is it destroying as i can go from index to home page by typing it in the browser with out the user input can any one help me with this(pardon my english) my code is as follows(if im missing something please tutor me on that too as that wud b helpful becoz web resources on sessions r not helpful) code in home.php: <?php include '1.1.php'; include '1.php'; ob_start(); session_start(); $_SESSION['uname']=$s1||$b1; ?> <!DOCTYPE html> <html> <head> <title>fetch-array</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </script> <link href="css/hello.css" rel="stylesheet"> <script type="text/javascript" src="tinymce/tinymce.min.js"></script> <script> tinymce.init({ selector: "textarea#elm1", theme: "modern", width: 500, height: 150, plugins: [ "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker", "searchreplace wordcount visualblocks visualchars code media insertdatetime media nonbreaking", "save table contextmenu directionality emoticons template paste textcolor" ], content_css: "css/content.css", toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | outdent indent | link image | print preview media fullpage | forecolor backcolor emoticons", style_formats: [ {title: 'Bold text', inline: 'b'}, {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}}, {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}}, {title: 'Example 1', inline: 'span', classes: 'example1'}, {title: 'Example 2', inline: 'span', classes: 'example2'}, {title: 'Table styles'}, {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'} ] }); </script> </head> <body> <header> <div align="left"><a href="session_stop.php">logout</a></div></header> <br> <div id="container"> <div class="Container-left"> <?php echo $_SESSION['uname'];?> </div> note that it isn't also echoing any session variable too then here is my session stop page: <?php session_start(); session_unset(); session_destroy(); if(session_destroy()==1){ setcookie('', NULL, time()-100,'/'); header('location:index.php');} were am i going wrong???
  22. Hey guys, I am stuck on this piece of code. Within the function I am using I need to include an mysql query. I am not sure how to insert it within the echo. Currently the query works but the code stops once close the '' and </ul> and </section> are cut out. Please note that there is alot more code within the echo, not just the section and ul. Just simplified it for my question. Any help would be appreciated. Thanks <?php $query = mysql_query('SELECT id FROM videos WHERE user="'.$id.'"'); list ($video_id) = mysql_fetch_array($query); if ($video_id != '') { echo '<section> <ul >'; $query = mysql_query('SELECT video FROM videos WHERE id="'.$id.'" ORDER BY RAND()'); $i = 0; class myCounter implements Countable { public function count() { static $count = 0; return ++$count; } } $counter = new myCounter; while ($row = mysql_fetch_array($query)) { if($i % 5 === 0) { } echo "<li data-path='feeds/api/videos/".$row['video']."' ></li>"; $i++; } '</ul> </section>'; ?>
  23. Hi everyone, I'm trying to get my head around blending in and out of php and html. I've seen some simple examples which work great but now I have this variable that comes from the database and I would like to style the variable in-line with html markup. Here's what I'm trying to do: <?php echo "Price : ",'<Font size="100"> $tournament["pricePerPlayer"] </font>'; ....more of the same code goes here... ?> I can't get $tournament["pricePerPlayer"] to be controlled by the font tag. How do I do this? Any help would be greatly appreciated. Thanks,
  24. I've finished designing my website home page and I've now moved on the some of the other pages, I want my header and footer to appear the same on every page. I've tried this basic way of linking the same stylesheet that makes up my header/footer in the second HTML file (already used in the homepage): <link rel="stylesheet" href="footer.css" type="text/css"/> <link rel="stylesheet" href="header.css" type="text/css"/> I now understand that this isn't going to work. Would a server-side scripting language be my best bet here? Something like PHP? If so, would anyone be able to link me with an article on how I could do this in PHP, I presume with the include function? I've had answers elsewhere but this, for me, isn't working: "You are currently only linking the css for the header and footer. If you want to include the html as the same, create two separate files header.php and footer.php, then include them into each webpage. <?php include('path/to/header.php');?> // in the location you want the header in the page <?php include('path/to/footer.php');?> // in the location you want the footer Essentially, you're making partials and placing them wherever you want them" Any help would be greatly appreciated.
  25. There is no SEO section so I do not know where exactly to ask this question, but here it is. https://www.google.ca/?gfe_rd=cr&ei=jgm3VIqFNtCy8wfH3YD4CA#q=twitter.com Do you see how Google lists Twitter results in two columbs underneath the main heading title? How does one achieve that result with their website? Does only Google decides to make it show up that way?
×
×
  • 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.