Qcreate a key value array based on array two values from different arrayPHP

I have this array: $priceTableData = array( array(‘productId’=>1,’price’=>50,’discount’=>12), array(‘productId’=>2,’price’=>22,’discount’=>2), array(‘productId’=>3,’price’=>7,’discount’=>0), array(‘productId’=>4,’price’=>9,’discount’=>0), array(‘productId’=>5,’price’=>35,’discount’=>7), ); and I want to get this array out of it: array(5) { [1]=> int(12) [2]=> int(2) [3]=> int(0) [4]=> int(0) [5]=> int(7) } and I used this custom method to do so, function getDiscounts(array $priceData){ $result = array(); foreach ($priceData as $array){ [...]

QMYSQL & PHP How to show how many results in a tablePHP

Im a noob and only 16, i have a table full of videos that can be added though the website. How do i show the Number of videos in the my-sql database that i can just past in between some php tags?

Qcurl error HTTP status code 0— empty reply from serverPHP

I’m trying to scrap a website but it always said that Empty Reply from server can any one look at the code and tell me what am I doing wrong? Here is the code function spider($url){ $header = array( “Host” => “www.delivery-club.ru”, //”Accept-Encoding:gzip,deflate,sdch”, “Accept-Language:en-US,en;q=0.8″, “Cache-Control:max-age=0″, “Connection:keep-alive”,”Content-Length:725″,”Content-Type:application/x-www-form-urlencoded”, ‘Accept’ => ‘text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8′ ,”X-Requested-With:XMLHttpRequest” ); $cookie = “cookie.txt”; $ch [...]

QHow to separate sentence into array items, by a specific count of wordsPHP

I have a sentence (sometimes long, sometimes not) which has to be exploded into a string. The catch is, that it has to be separated by length (never cutting off words). Example: $sentence = ‘I slipped it into that Stevia crap that you’re always putting in your tea.’; Should be (using 15 letters top per [...]

QHow to Update a table row from a WordPress pagePHP

I’m trying to update a row from one table in Wp database, all this from a page in wordpress. I’m using a plugin that allows me to write php inside the page, and I’m writing this: $ident = $_GET['id']; echo $ident; global $wpdb; $table_name = $wpdb->prefix . ‘ wp_cf7dbplugin_submits’; $data = array( ‘field_name’ => ‘p’ [...]

Qresize script nor executing for multiple imagesPHP

i am getting this error when i attempt to use the image resize script for each of the multiple images the error:Fatal error: Cannot redeclare class SimpleImage i am using the resize script by whitehat my script for handling multiple file uploads foreach($_FILES['image']['tmp_name'] as $key => $tmp_name ) { $file = $_FILES['image']['tmp_name'][$key];//temp file $image_name = [...]

QGetting error with PDOPHP

So I’m trying to use this name = $con->real_escape_string($_POST['name']); with my code, and its not working. I get the error Fatal error: Call to undefined method PDO::real_escape_string() in /Users/idrisk/Colourity/si/r.php on line 15` I’m not sure what that means. Here’s the code I have so far. $username = “xxx”; $password = “xxx”; try { $con = [...]

QUpdate a blob file though input type filePHP

I am currently trying to update a image on database.The file information is being carried over however I getting the ‘Warning: mysql_query() expects parameter 1 to be string, resource given in ‘ . Heres my code. $size = $_FILES['file']['size'] ; $type = $_FILES['file']['type']; $tmp_name = $_FILES['file']['tmp_name']; $name = $_FILES['file']['name']; mysql_select_db($database_fot, $fot); $image = addslashes(fread(fopen($tmp_name, “rb”),$size)); [...]

QPHP Mail Function and Header Redirects Not Working TogetherPHP

The following code is used to send a email to users who’s emails were provided by the user. $from_whom_header = mysqli_real_escape_string($connect, ‘noreply@test.com’); //setting a static from field $from_whom = mysqli_real_escape_string($connect, $_POST['your_email']); // this is used to pass the email of the person sending the email into the subject line and body of email $headers = [...]

QMySql not working in a WordPress sitePHP

I’ve been trying this thing all day… I create a perfect sqk script (it works directly on PHP my Admin) and when I try to insert it using ALL possible ways (wpdb->query, mysql_db_query, wpdb->insert) it just won’t do it.. here is my script, please help, I’m really desperate! <?php ini_set(“display_errors”,true); include(“wp-config.php”); $u = 1;// $_POST['id_user']; [...]

Qphp remove “questionmarks” � from fail-encoded textPHP

i´m extracting some text from a weblink with file_get_contents, i have no influence on the text, the bits i talk about are already malformed in the sourcecode of the weblink i got the contents from , and look sth. like so : /$%§&fdsgfkgfd � fdsfdsfs � � –> <h1>m�lll</h1> <h1>m�lll</h1> <h1>m�lll</h1> <h1>m�lll</h1> <h1>m�lll</h1> <h1>m�lll</h1> or [...]

Qavoid redeclaring an interface for more one timePHP

I have an interface which I named Manager, and two classes UtilisateurManager and StageManager, and the both of them implements the Manager interface. In each class I included the interface Manager as the following : require ‘../helpers/Manager.class.php’; Then I needed to use these two classes at once in a php script, but I got the [...]

QCakephp error custom pagePHP

Hello I am new in cakephp and I want to show an error page if someone enter wrong url in my cakephp application. I am using this code as per given example on internet CakePHP 2.0 – How to make custom error pages? I am unable to see any custom error page in my application.I [...]

QGet SQL Server query result and post into a new query after clicking on itPHP

Right now the webpage is just outputting data as hyperlinks that all take you to the same page. I want to be able to click on that result and use it in a query on the next page where it will display more details about that query. while ($row = mssql_fetch_row($query_result)) { echo ‘<td><a href=”target.php”>’.$row[0].’</a></td></br>’; [...]

QWhen saving a input with type time what type it should be in WampPHP

Basically what the title says, I have a time input for a starting hour and ending hour for some event, the input type is 00:00 AM or PM, but in Wamp server the only one that looks similar is TIME which says that supports 000;00:00 (h/m/s) would saving it like that cause an error? Thanks.

Qadding element and node into existing xmlPHP

I have an XML file which includes the followings. <?xml version=”1.0″?> <users><user><firstname>ben</firstname><surname>kim</surname <email>benkim@test.com</email></user> <user><firstname>ken</firstname><surname>kim</surname><email>kenkim@test.com</email> </user></users> What I’d like to do is that appending a new user into existing XML above with the codes below. But I doesn’t work at all. Could you guys look at them please? <?php header(‘Content-Type: text/xml’); ?> <?php $firstname = $_GET["firstname"]; [...]

QPass an extended class by parameterPHP

I have a parent classes: namespace classes; abstract class MyParent{ abstract function name(); } Now, two children: namespace classes; class Foo extends MyParent{ function name(){ return “Foo class”; } } namespace classes; class Bar extends MyParent{ function name(){ return “Bar class”; } } In java, I can do this: public void doSomething(AnObject <?extends MyParent?> object){ [...]

QSimple WordPress Plugin PayPalPHP

how can I create a simple plugin for wordpress with a button, when you have made ​​the purchase, only one function to write to mysql id_user, purchase date and txn_id?

Qphp mysql insert into statementPHP

When running this code in the web page I do not get a confirmation that it is complete. I took the sql code directly from phpmyadmin sql query window. I would like a little help to this issue. it effects all the add pages. id $results=mysqli_query($con, “select * from Users where `userName` =’$userName’”); $row = [...]

Qonchange select do different mysql query without refresh pagePHP

All options of the following select element are from a database: <select id=”list” name=”list”> <option>Mercedes-Benz</option> <option>Ford</option> <option>Fiat</option> </select> I need help with onchange. I have a select element, and I need to do different MySQL queries when I choose something from select list. Example: When I select Mercedes-Benz, it would do this: $query = “SELECT [...]

QPopulating a table with data from another tablePHP

Newish to MySQL and having a tough time with this problem. Stuck in progress in my php script. Here is emailQueue Table (apologies, cant post pictures yet): http://i.imgur.com/5OOyAE9.jpg Here is the Students Table: http://i.imgur.com/inA8TUg.jpg I’d like to grab all the CourseID’s from the Students table and add them to columns 1, 2, 3 etc in [...]

QMatch an element with a dynamic attribute valuePHP

I’m trying to prototype a transform to turn xsl:schema into a php interface. I’m having a little trouble matching xsd:simpleType elements that have a name attribute matching the type attribute of xsd:element elements. Suppose I have a schema like this: <xsd:schema xmlns:xsd=”http://www.w3.org/2001/XMLSchema”> <xsd:element name=”Foo” type=”Bar”/> <xsd:simpleType name=”Bar”> <xsd:restriction base=”xsd:string”> <xsd:maxLength value=”32″/> </xsd:restriction> </xsd:simpleType> </xsd:schema> I’d [...]

Qmysql query with if and else statementPHP

I need mysql query that will : IF (result=win){SELECT dobitak} else if (result=half_win) {SELECT dobitak/2} else if (half_lost) {SELECT stake/2} else{0}; FROM matches WHERE id=$id but i dont know whats the best solution to write query like this.

QPHP number_format not working properlyPHP

i have this variable: $out .= $indent . sprintf(“{$total_space}%-{$column_total}s{$space}%{$price_width}s$newline”, ___(‘Tax’), Am_Currency::render($this->{$prefix . ‘_tax’}, $this->currency)); Which for the time being equals 4000. I need it to be formatted like this: 4,000 so i changed my code as below: $out .= $indent . sprintf(“{$total_space}%-{$column_total}s{$space}%{$price_width}s$newline”, ___(‘Tax’), Am_Currency::render(number_format($this->{$prefix . ‘_tax’}), $this->currency)); However, i dont know why but i get [...]

QWhile is $_FILE superglobal not being passedPHP

So I am working on a file upload form that seems to lose the information in the file super global from one step to another. So what I do is I print out the file super global before I verify through captcha and then print it out once I validate through the captcha. For some [...]

QIf else not working as expected in PHP–random selection from arrays based on random selection of another array's key.PHP

I’m trying to get a rudimentary PHP name generator working, but I’m hitting a bit of a speedbump here. First, the code: <?php $gender=array( “Male”=>00, “Female”=>01, ); $m_names=array( “Jack”=>00, “Bill”=>01, “Nathan”=>02, ); $f_names=array( “Betty”=>00, “Margaret”=>01, “Rachel”=>02, ); if ($gender=”Male”) { print_r(array_rand($m_names,1)); } else { print_r(array_rand($f_names,1)); } ?> The arrays all check out, and I know [...]

QCan I make this work in php if ($_POST[“answer”] == “””) [on hold]PHP

I want to be able to read quotes as quotes in my input field so how do I make this work in php: if ($_POST["answer"] == “”" ) right now all I get is a parse error

QSet alt attribute when using imagephp()PHP

Is it possible to output an image with a predetermined alt attribute? $im = @imagecreatefrompng($file) header(‘Content-Type: image/png’); imagepng($im); imagedestroy($im); Outputs the image. I want to set the alt attribute before output – can I do so?

QI would like a search for my website of existing pagesHTML

Here is what I would like to achieve. I have a music folder of 3000 songs. I want to put a search on my website that the user will be able to search for the artist or song title. I want the results to come back from the existing “playlist” page I already have in [...]

QHow to sort a result and display group wisePHP

The mysql query is returning the below result. id – name – class 1 – A – 5 2 – D – 1 3 – B – 5 4 – c – 1 5 – E – 5 (class wise ordering is not possible as order has been applied on id) Now, i want to [...]