spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
  Home » PHP » Page 5
Best way to apply Eloquent's ORM with Laravel?
If a Company can have multiple Treatments and a treatment can be bought from multiple companies at different prices, then you have a Many-to-many relationship, with prices being the pivot table (which if you would adhere to convention would be named company_treament, but that's not a must). So you'll need to have two models for Treatments and Companies, which would look like this: class Company e

Categories : PHP

Show a list of members whose status = 0
To get all details on users with status = 0 you need to run this query: SELECT * FROM user WHERE status = 0; To update your table, you need to use an UPDATE query: UPDATE user SET status = 1 WHERE username = '$username'; // ^table to update ^this needs to be set before (and shouldn't be used like this - see the script for prepared statements A very basic script to d

Categories : PHP

store path of image uploaded on server
You've got an extra . in there. Like you were going to concatenate the string but nothing followed. Remove the . right before the semicolon. $imagepath = "uploads/" . $_FILES["file"]["name"];

Categories : PHP

Checking PHP script running in process
You'd only see the php process running. My approach for seeing a php process running is to alias the php binary and run it with that. ln -s /usr/bin/php longrunningphp longrunningphp /path/to/your/script Then check with ps ax | grep longrunningphp

Categories : PHP

Math issue when reading and using decimal datatype from mysql
PHP does not natively support the DECIMAL(15,2) format. Instead it uses floating point numbers. My recommendation would be to have all numbers as int and do the decimal calculation at the very last moment. Something like: echo number_format($balance / 100, 2);

Categories : PHP

JSON_decode issue Returns string() and int() with data
You're getting an object back, not an array. You need to reference it as such. The data you're seeing from var_dump will not be in the output when you handle the data. That is just for debugging purposes so you can see what you're dealing with. json_decode with object returned $json = json_decode($json); echo $json->rows[0]->elements[0]->distance->text; json_decode with array retur

Categories : PHP

Extend a controller Codeigniter
Change your MY_Controller to: <?php class MY_Controller extends CI_Controller { /** * Constructor */ public function __construct() { parent::__construct(); } } This is because $this will already contain the instance as it is extending CI_Controller I can't be certain this is the issue but I hope it helps!

Categories : PHP

Chrome Developer Tools - Console - Can you inspect a PHP var?
No, you can't, but you are missing some basic coding and languages fundamentals, like the difference between compiled codes and scripting codes. In PHP you cannot debug the code in real time like in compiled codes, except if you configure your IDE (like PHPStorm) to make some real time debugging, but that is an advanced task. Supposing that you are coding on a localhost, what you can do is print

Categories : PHP

Hiding ONE category name within Wordpress
Assuming the categories are being displayed from within the loop, here is some code that will display all of the categories the post is in, with links to the categories. "Portfolio" should be excluded. <?php $categories = get_the_category(); $separator = ' '; $output = ''; if($categories){ foreach($categories as $category) { if ($category['slug'] != 'portfolio') { $output .

Categories : PHP

Codeigniter Database Insert - Not Working With Array
Try this code $datainsert=Array ( [online_name] => Discount Store, [online_nameKey] => d, [storeGroup_ID] => something, [CJ_ID] => 123456 , [online_tag] => Health and Medical , [online_businessType] => 0 , [online_businessTypeSub] => 0 ,

Categories : PHP

Recursively convert PHP Array into XML?
I will not try to understand what exactly is going on there. Yet i can tell you that your problem is your call to echo. Try returning your SimpleXMLElement from your function in a proper way and asXML() and echo it from outside the function and it will work as expected :)

Categories : PHP

How do I access this array
Convert to an array - $json2 = json_decode(file_get_contents($remote_url2, false, $context2), true); Then you can retrieve like this for each item - foreach ($json2 as $item) { $pricepaid = $item['result']['sales']['pricePaidGBP']; // ... the rest of the items

Categories : PHP

Is there a way to make __get & __set trigger for defined but empty properties in class
__get() and __set() are used for reading/writing data from/to inaccessible properties. Inaccessible properties in this case would be private or protected, never public. If they need to be public then what is wrong with just returning from the function? class User { public $groups; function loadGroups(){ $this->groups[] = "a list of groups"; return $this-&g

Categories : PHP

Exacttarget API Custom Unsubscribe Page
Honestly, your best bet for a quick, no mess user friendly solution is to use their Smart Capture capabilities on an ET landing page - unfortunately this means it has to be hosted via Exact Target though, and not your web host. Custom Unsub page with Smart Capture If you just are looking to get it branded, talk to Global Support or your Account Executive and see because I believe they allow some

Categories : PHP

Check if Variables Are Set
Use a loop and variable-variables. $fields = array('author', 'book', 'subtitle', ....); foreach($fields as $field) { if (isset($_POST[$field])) { $$field = $_POST[$field]; // variable variable - ugly, but gets the job done } else { $$field = 'not available'; } }

Categories : PHP

Custom Post Query WordPress and a better way to display posts
You need to store current post ID in a variable then you need to compare current Post ID with list item Post ID if both are same then apply active class. So your code will be something like this- <ul class="menu-advogados"> <?php global $post; $post_id = $post->ID; // Store current page ID in a variable. // WP_Query arguments $args = array (

Categories : PHP

Find existing value with PHP in mysql database for not english characters
maybe your column encode is the problem, try to alter your table and configure you column to make it support additional language. try to change your options column if your column encode is 'latin1_swedish_ci'...hope it works

Categories : PHP

cakephp 2.x: using variables in saveField()
is it possible to replace x and Y in the saveField with variables containing the altered data from the arithmetic operations above? It is. Just try it, and you'll see it works. how would i go about with string substitution here? Step 1) Replace 'x' or 'y' with your arithmetic operation. This can easily be accomplished by using your "Copy" and "Paste" shortcuts. (Ctrl+C / Ctrl+P on Wi

Categories : PHP

try/catch in php not printing anything out
Please read this first line from the PDOException documentation: Represents an error raised by PDO. You should not throw a PDOException from your own code. Just throw and catch regular old Exceptions. This would also catch a PDOException which inherits from it. This also gives you a much better way to distinguish between actual exception thrown by PDO and your own exceptions. By the way

Categories : PHP

Subquery php mysql
i hope this work for you... $sql = "SELECT `a`.*, `b`.`curriculum` FROM `curriculum` AS `a` LEFT JOIN `contactados` AS `b` ON `a`.`ci` = `b`.`curriculum` WHERE `b`.`activado` = 'si' AND `b`.`empresa` = '".$_SESSION['emp']."'";

Categories : PHP

htaccess rewrite redirect to non existing page
If you simply wanted to redirect /test?options={param} to /test/1/ and /test?options={params} to /test you could do this: RewriteCond %{QUERY_STRING} ^test=options$ [NC] RewriteRule ^/test$ /test/options/ [NC,L,R=301] RewriteCond %{QUERY_STRING} ^test=options$ [NC] RewriteRule ^/blog$ /test/ [NC,L,R=301]

Categories : PHP

Data in storage is not modifying from thread
As you can see, Stackable class has a lot of methods, mainly used for async operations and they can help you with your issue. You should modify your async classes in this way: class AsyncOperation extends Thread { private $arg; public function __construct(Storage $param){ $this->arg = $param->getData(); } public function run(){ while (true) { $this->arg++; slee

Categories : PHP

Inserting data to sql database using stored procedure in PHP
Your SQL is invalid. None of your stored procedure values are quoted, so you're producing something that looks like CALL prc_emp_add(John, Doe, jdoe@example.com, ...) This also means you are vulnerable to sql injection attacks. The quick/immediate fix is to quote the values: $mysqli->query("CALL prc_emp_add('".$firstname."','".$lastname." etc... ^----------

Categories : PHP

Missing rows after insert
I have found the problem, somewhere deep down in our application code I have found this query being executed sometimes; SET autocommit = 0 And it never being set back to 1.

Categories : PHP

parse.com : send push notification from my own CMS
https://parse.com/docs/push_guide#installations/PHP $data = array("alert" => "Hi!"); ParsePush::send(array( "channels" => ["PHPFans"], "data" => $data )); or: $query = ParseInstallation::query(); $query->equalTo("design", "rad"); ParsePush::send(array( "where" => $query, "data" => $data ));

Categories : PHP

Passing radio button to FPDF from contact form 7
When I was working with fpdf and contact form 7 I was only able to get the value of a variable by using $_POST['']; So if you try $submission = WPCF7_Submission::get_instance(); if ( $submission ) { $first_name = $_POST['first-name']; $last_name = $_POST['"last-name']; $email = $_POST['email-838']; $radio = $_POST['radio-474']; } if($radio == M) { $type = 'X';

Categories : PHP

Import and sign a pdf in php
You actually only define the soure file but you do not import any page of it. Try this: $pageCount = $pdf->setSourceFile('file.pdf'); for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) { $tplIdx = $pdf->importPage($pageNo); $pdf->AddPage(); $pdf->useTemplate($tplIdx, null, null, 0, 0, true); } This way you import all existing pages into a structure which you can reus

Categories : PHP

PHP/HTML Error - Illegal Character
Your a tag has a space before the query string parameter: <a href='display.php? url=".$book."'> this should be: <a href='display.php?url=".$book."'>

Categories : PHP

No route found for GET on symfony
At least in Symfony 2.5 you specify the pattern, with the keyword path, not pattern so if you change your code to the following: ads_fi_auth_validate: path: /validate defaults: { _controller: AdsFiAuthBundle:Auth:validate } methods: [POST, GET] You should be able to hit your route. That assuming that the bundle and the method exist. A good way to find out if Symfony is recognizing

Categories : PHP

Update files images
where num='$num'"; You use a SQL statement WHERE NUM=$num. Yet, you did not set $num anywhere in the code you gave us here. Most likely you never set the value of $num. You probally ment $i. I'm guessing you also possibly made the same mistake in your upload code (initial upload) and therefor all images have number=0. You are now updating images which have number 0, or empty string (depending

Categories : PHP

SQL SELECT to multiple table
You could join the membre table to your original query? This would be done in a similar way to the Inner join you used in your first query. You could either use an inner join again or a left join may be appropriate. Using a second join means you would not need to do two separate queries. For more information about SQL joins, you may find http://dev.mysql.com/doc/refman/5.0/en/join.html useful. It

Categories : PHP

Create new sql table by entering specific row of specified table in the same database
Select below will give you columns from top rows of 3 tables SELECT T1.DE_event, , T1.DE_RMEETI_SCORE , T1.DE_name1 , T2.DE_event , T2.DE_RMEETI_SCORE , T2.DE_name1 , T2.DE_event , T2.DE_RMEETI_SCORE , T2.DE_name1 FROM (SELECT DE_event, DE_RMEETI_SCORE, DE_name1 FROM MJ100WL LIMIT 1) AS T1 CROSS JOIN (SELECT DE_event, DE_RMEETI_SCORE, DE_name1 FROM WS100WL LIMIT

Categories : PHP

ajax request always going through else
The response never equals "". It's that simple. You need to do something like console.log(response===""); and you will see this for yourself. It will be false. The response might be " " or any number of things. There is an appropriate test to run, but you need to find out what response equals that is not "".

Categories : PHP

How do I retrieve data from my database?
You are replacing the array each time with $post A question! How many rows are there actually in P_CASE_STUDIES? while( $post = mysqli_fetch_assoc( $result ) ) { $result_array[] = $post; } Should be something like: var i = 0; while( $post = mysqli_fetch_assoc( $result ) ) { $result_array[$i] = $post; $i++; }

Categories : PHP

Starting debug without XDEBUG_SESSION_START at the of query
I don't know the exact behavior of your IDE (PHPStrom), but in my experience, after you hit run and launch a browser with the XDEBUG_SESSION_START addition to the url, you can just change the url in the browser and remove the XDEBUG_SESSION_START part. The debugger will still be active and breakpoints will hit.

Categories : PHP

How to check all user(s) to see if they're online in Laravel 4?
I want to suggest some logics to you. Yes, you need to update your database. Your users table. I suggest at a column called : is_online , tinyInt , 0 or 1. After you have that, In your Sign-In function, somewhere at the end before you redirect. set is_online = '1'; // this should be save into your database now. Apply the same similar logic in your Sign-Out function,somewhere at the end bef

Categories : PHP

Cartesian product of associative array showing key and value - PHP
I think I got it, I googled "PHP combinations" (Assuming that a combination is similar to a Cartesian product, I think it is :s) and used this code as a base. The change I needed to make was instead of merging the arrays I had to use a union because according to the php manual: Values in the input array with numeric keys will be renumbered with incrementing keys starting from zero in the resu

Categories : PHP

Datamapper orm save and update not working
At first try: $l->save($s); If this will not work, check relationship setup between the models. They should be set in both models: class Ledger extends DataMapper { var $has_many = array("staff"); } class Staff extends DataMapper { var $has_one = array("ledger"); } In your database, table staffs should have column ledger_id, which has to be set as a foreign key to field id in ledgers

Categories : PHP

find methods in COM object
All the metadata that's available for COM components come from the type library - it's usually embedded in the component as a resource or it could be a separate .tlb file next to the binaries. Type libraries describe the binary interfaces of the component(s) and support having some documentation - if the type library doesn't have the information you're looking for, it's either in the product docu

Categories : PHP


Recently Add
Extracting sentences from text based on particular pattern
How to include tags in createNotification in PushApps api?
clarification on $_Files php command
Multiple where clause on Eloquent ORM Laravel
How to get the value in field by new line and update into the column in table with same id in php mysql?
Accessing session data in other method in same controller is not working in codeigniter
Bootstrap button, how to click multipite times
How to use __autoload function when use composer load
Not sure how to handle a fairly involved query with PHP/MySQL
Regex for detecting a word enclosed but in order
Using wpdb to search usermeta values
Codeigniter Multi Insert Query
exec() error, i cant figure it out how to make it work
how to Remove array and created new array in php
Proxy server in php
Cannot install YOURLS (PHP Parse error: syntax error, unexpected ';', expecting ')' in config.php on line 66)
Codeigniter if id = 1 it's work multiple image update but id =2 it's not working
How to add more than one tabs to a single facebook page by sdk in php
php server parse simple string using JSON to Android client
Mysql - most optimal way (performance and scalability) to store and retreive multiple lines of text
Break one array in to two different array in php
remove quotes from criteria params
CodeIgniter query result (class) includes non-property fields
How to delete the original image after resizing it
Sorting An Array By Key Value
PHP function On Each Page Causes Redirect Loop
Split date ranges into corresponding weeks
codeigniter do_upload is missing argument 1 on ubuntu server
Comparing only dates From the database Timestamp Laravel
Changing an individual foreach array field tag input type
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.