w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
  Home » PHP » Page 36
Inserting webpage (frontend)
  • to MySQL table
  • Well your code is at least wrong in 2 places. (If this is the code you are using and not just a part of it.) Your sql query will result in the following: INSERT INTO table (column_name) VALUES I suspect column_name is not a column name. And ($keywords) is empty so there are no values to put into the table.

    Categories : PHP

    Android connecting on MySQL using PHP
    I think you have two problems : Change localhost to your machine's IP address. You are doing network calls on UI thread and it's bad for performance. you can use AsyncTask instead or use libraries like Retrofit that rocks! ;)

    Categories : PHP

    add meta key to all posts - custom post type
    I'm not sure, but should work. Try this: Main function: function get_post_meta_data($post_id){ global $wpdb; $wpdb->query("SELECT 'post_id','meta_key','meta_value' FROM $wpdb->postmeta WHERE 'post_id' = $post_id"); foreach($wpdb->last_result as $k => $v){ //data: //$v->meta_key == meta_key of post //$v->meta_value == meta_value of post //$post_id == post id

    Categories : PHP

    Laravel query doesn't work
    You cannot create queries on object, you should do it this way: public function index($type_id) { $product = Product::where('type_id', $type_id); if(array_key_exists('ages', Input::get())) { $product->where('age_id', $_GET['ages']); } $productsAll = $product->get(); $productsPaginated = $product->where('type_id', $type_id)->paginate(2); return View::mak

    Categories : PHP

    sending email from php application
    the problem was the port is not working and the $config['smtp_host'] = 'smtp.gmail.com'; instead i put the IP address in numeric form 192.168.0.x and the port is 25 instead

    Categories : PHP

    Redbean + Slim Framework issue , RedBeanPHPRedExceptionSQL SQLSTATE[42S02]: Base table or view not found: 1146 Table 'test_api.post' doesn't exist
    If your still wanting ReadBean to change the schema to (create the table on-the-fly) then it needs to be in fluid mode. This is the default mode, but you explicitly changed it R::freeze(true); When the mode is set to freeze it cannot modify the schema. You only need to set R::freeze(true); in production after the schema has been created.

    Categories : PHP

    $i not incrementing in while loop
    You are re-using the $result variable for the other queries, which is destroying its value needed for the main loop. P.S. Also, you're not actually executing the query for the venue details.

    Categories : PHP

    WordPress: Apache Basic Auth applied, now my contact form triggers Appache Auth too?
    Found the solution by myself: The apache access.log shows this line each time one tries to send a message via my wordpress contact form: 188.xxx.xxx.xxx - - [16/Nov/2014:12:10:58 +0100] "GET /wp-admin/admin-ajax.php?action=pp_contact_mailer&your_name=Kurt&email=kurti%40home.ch&message=Kurti&captcha-code=inif+sqcu HTTP/1.1" 401 671 "http://example.domain.ch/contact/" "Mozil

    Categories : PHP

    Structuring URI's for a multi-page signup form?
    If you are not building a REST API i'd say having different URLs for each step is fine as they represent different views. /signup-step1, /signup-step2 ... /signup-finished This also makes funnel tracking a lot easier, than passing the data in a hidden field. It'll also play nicer with the browser history, if users would go back through steps. Also for separation of logic you could route the

    Categories : PHP

    Validate Form With PHP Array
    Try to take a look at array_intersect or for you needs array_intersect_keys http://php.net/manual/en/function.array-intersect-key.php

    Categories : PHP

    Cannot connect to MYSQL using PHP
    Mysql is deprecated. Use Mysqli. Create a file and name it as db_connect.php and copy the below code. <?php $connection = mysqli_connect("localhost","username","password","database_name"); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } Open browser and type http://localhost/db_connect.php. If you see a blank page, your connection is fine. I

    Categories : PHP

    Why am I getting this array to string conversion error?
    You are comparing wrong values. var_dump($phone_number[0]); //go to the next row if (is_array($phone_number[0]) && count($phone_number[0]) == 0) // check if an array... { //..codes goes here... } else { $query3 = "UPDATE usedcars SET phonenumber = (' ".$phone_number[0][0]." ') WHERE `key` = $x"; echo "<font color='#00FF00'>INSERTING NUMBER $phone_number[0][0] INTO DAT

    Categories : PHP

    PHP - how does serialize work? I need to serialize an array manually
    It looks like this is something like a:2 where a stands for array, 2 is element count. Then you got i (integer), its value, ; as separator. then another element, s (string), its length and the value.

    Categories : PHP

    How to organize PHPUnit tests and autoloading with NetBeans IDE
    Man, what a big question. :) Ok, let's address some of the issues. PHPUnit Skelgen tests in wrong path That definitely is not mirror symmetric True. It's an odd (and i think unresolved) path issue with skelgen. Just move the generated *Test files into their correct folders. Same question over here: PHPUnit, Netbeans and Symfony2 and wrong tests location Folder structure for your project

    Categories : PHP

    Sort multidimensional array prioritising substring
    I think that usort is actually what you need, but I think you are wrong in the way you are using it. If you need to sort first in the ascending order of the last two characters of product_code then in the ascending order of the characters preceding the '.' of product_code just write a function which do this and pass it to usort: function cmp($a,$b){ $lastTwoDigitsCmp=strcmp(s

    Categories : PHP

    PHP representation of given JSON output
    No need for that other nesting, just push them inside the container and encode them: $column = array(); if($count > 0) { while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $column[] = array( 'tid' => $row['TID'], 'fname' => $row['FNAME'], 'lname' => $row['LNAME'] ); } } echo json_encode(array('tutor

    Categories : PHP

    Cannot send to database
    Your problems certainly come from the fact that you didn't want to separate your files. You now have a mess aggregated into one file, playing all in itself the rôle of the model, view and controller. If you can't see any change in the database but the INSERT instruction has been executed, then you should see an error. What is in $mysqli->error? Activate PHP errors by putting this at the beggi

    Categories : PHP

    PHP specifying timeout duration for DOMDocument?
    Alternatively, you could use fil_get_contents() and set there the timeout duration, then feeding the return values into the DOMDocument class: $context = stream_context_create(array( 'http' => array('timeout' => 60), // 60 seconds )); $html_page = file_get_contents('http://www.example.com', false, $context); $grep = new DoMDocument(); @$grep->loadHTML($html_page); $finder = new Do

    Categories : PHP

    How would I delete any "word" that includes dashes in PHP?
    foreach ($array as $index=>$value) { if (strstr($value,'-')) { $ex=explode(" ",$value,2); $array[$index]=@$ex[0]; } } Simply walk through the array and check if the value contains dash ... Please note the foreach is associative, so you will get the index of the value inside the array, this is why you can unset it.

    Categories : PHP

    Hosting Codeigniter site on GoDaddy with shared hosting
    It's better to use the Anchor function for generating links. See documentation here. The htaccess should remove the index.php before the url, and you should change this line to: $config['index_page'] = '';

    Categories : PHP

    how i can grab value and node as string using simplexml in php
    You can use DOMDocument then load that xml into it. Target that desc1 then get its children, save it and put it inside a container string. Example: $dom = new DOMDocument(); $dom->loadXML($xml); $output = ''; $desc1 = $dom->getElementsByTagName('desc1')->item(0)->childNodes; foreach ($desc1 as $children) { $output .= $dom->saveHTML($children); } echo $output;

    Categories : PHP

    Is it possible to get Facebook feed, likes and comments from a closed group that I own using the Facebook API + PHP
    There was a missing token and permission definition. This webpage has a simple example of how it suppose to look like: http://www.benmarshall.me/facebook-sdk-php-v4/

    Categories : PHP

    Deleted yiiAssets and the entire site throws an CException
    You can resolve this issue, go to protected/runtime/ and open all log files in notepad and remove every thing from it and run your application once again. After this your whole application will rebuild the assets folder automaticaly which ever is required. And after that all the issues will be rectified.

    Categories : PHP

    Populating a from value from include (.php) file
    When you include a file in PHP, the variables defined in the included file could be used in the file <?php include "login.php"; // $user is defined in this file ?> <form ....> <input type="hidden" value="<?php echo $user ?>"> </form>

    Categories : PHP

    php - Group array by key
    This should work for you: <?php $old = array( "A1" => 4, "A2" =>5, "B1" => 2, "B2" =>7, "C1" => 4, "C2" =>5, "D1" => 4, "D2" =>5, ); $arr1 = array(); $arr2 = array(); foreach($old as $k => $v) { $arr1[s

    Categories : PHP

    Why is my regex returning false?
    ([0-9]?[- .(]*[0-9]{3}[- .)][0-9]{3}[- .][0-9]{4}) Didnt exactly understand your regex but you can try this.More testing would be required though.Try here. http://regex101.com/r/lZ5mN8/1 Your regex will not work because of the anchors ^ and &.They will match the start and end of the line.I have removed them and modified your regex.

    Categories : PHP

    Pass value to from ajax call to PHP
    You could just add another query string into that: data: registerForm.serialize() + '&region=' + $("#regio option:selected").text(), Then, just treat it like a normal post value in PHP $region = $_POST['region'];

    Categories : PHP

    How to get all rows from mysql database without while() loop to increase page load time?
    The first thing you should do is stop running a query to get company name inside your while loop. You need to use a JOIN to select the company name from the company table with your main query. Since you didn't include your main query, I can't write it for you. But it will look something like this (I'm assuming your main table is named "employees"): SELECT e.*, c.company_name FROM employees AS e

    Categories : PHP

    Laravel Eloquent ORM - how to save multiple instances in a single function
    Your Message@sendMessage method is recursively updating the same exact model, not creating new models. As Ali Gajani has said, this is better done in a Controller. You didn't provide your attempt at doing this in the controller, but the same issue was probably happening there as well. Here's what your MessagesController@store method should look like (untested): public function store() { $i

    Categories : PHP

    Connecting to ms access database using php
    If you're getting an could not find file error then that means your path is probably wrong. Try adding echo $dbName; right below $dbName = $_SERVER["DOCUMENT_ROOT"] . "msdbjcdbone.mdb"; and then compare that path to the actual location of your jcdbone.mdb file and then adjust accordingly. A quick Google shows you probably picked this example up from a sitepoint article. The code sample sho

    Categories : PHP

    Load more instead of going to next page using pagination/API
    I changed the the api to work with client_id rather than access_token. You can change it back it will have no effect. Demo: https://tjay.co/l/instagrampagination ajax.php <?php function jsongram($next = null) { $userid = "xxx"; $accessToken = "xxx"; $url = ("https://api.instagram.com/v1/users/{$userid}/media/recent/?client_id={$accessToken}"); if ( !empty($next) ) { $url.= '&

    Categories : PHP

    Divide by the previous value in an array in PHP?
    This should work for you: <?php $close = array(100,101,99,98,99,103,102); $new = array(); foreach($close as $k => $v) { if($k == 0) continue; $new[] = round($close[$k]/$close[$k-1], 2); } print_r($new); ?> Output: Array ( [0] => 1.01 [1] => 0.98 [2] => 0.99 [3] => 1.01 [4] => 1.04 [5] => 0

    Categories : PHP

    Codeigniter on return type from model
    Get $row from query result. Then can return the country_id property of $row. Example: public function get_country_id($cname){ $this->db->select('country_id'); $this->db->where('country_name',$cname); $d = $this->db->get('countries'); $row = $d->row(); return $row->country_id; }

    Categories : PHP

    Does PHP has interface for print_r or var_dump?
    If you use print_r and then just copy the output and paste it into an array beautifier(google it) it will make a nice readable output. Its by far the easiest way to check array data within php without a huge amount of work. I use it all the time :) Good luck!

    Categories : PHP

    how do I stop looping in php and wait for user input to continue the loop?
    This could look something like this: (Here i'm using session so i can display every form every time if they was submitted once) <?php session_start(); if(isset($_POST['submit1']) && !empty($_POST['test1'])) $_SESSION['form2'] = TRUE; if(isset($_POST['submit2']) && !empty($_POST['test2'])) $_SESSION['form3'] = TRUE; echo ' form1:

    Categories : PHP

    how to make permalink in codeigniter
    You could use the like operator in your WHERE clause for string comparison if post titles are available like post IDs on the page: $var = $_GET['post_title']; $query = "SELECT * FROM myposts where mypost.post_title like $var"; $get = $this->db->query($query); $a = $query->fetchAll(PDO::FETCH_ASSOC);

    Categories : PHP

    Why does filter_input() not pick up arbitrary POST data?
    $_POST is the parsed POST body, turned into an array. When you add a key to $_POST, you're adding it to the array after that POST body data has been parsed. When you use filter_input, it's getting its data from the actual POST body, not from $_POST.

    Categories : PHP

    Ionic framework and php mysql
    You can put your php files in localhost or live server.I had the same problem (Cross-Origin Request Blocked) when the app is run in browser.Here are solutions from my experience 1.Test the app in emulator not in browser and change the localhost address to this http://10.0.2.2/test/test.php.This will works fine for me 2.if you are run in android device you cant access from the localhost,so put th

    Categories : PHP

    Send file to element in the database
    I did not find any relationship between your agency and the tasks table. I think you need a field in your task table named something like agency_id. Then after selecting the employee name, you can search in your task table with your employee_id: SELECT * FROM `task` WHERE agency_id = employee_id LIMIT 1

    Categories : PHP




    © Copyright 2018 w3hello.com Publishing Limited. All rights reserved.