PHP

118K

Solutions

126

Articles & Videos

32K

Contributors

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

Share tech news, updates, or what's on your mind.

Sign up to Post

Hi Experts

Could you point what's necessary to make Firefox Network debbuger to retain the code is causing the error?

Accordingly to:
 img002
I'm using PHP/ Codeigniter - the controller's module f.e. that causes an error doesn't appear when it used to.

Thanks in advance!
0
Online Training Solution
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

I wrote a program to monitor an email and grab the content and attachments like a ticket system. For the most part it is working great. I ran into an issue getting the attachment from mac mail and not sure what I am doing wrong.

I am using the imap php functions:

$test = imap_fetchbody($inbox, $email_number, 1);

this command returns the data but I am not able to encode it properly. I then issue this command next but I get no results.

$test2 = base64_decode($test);

The value of $test looks like this:


--Apple-Mail=_E9B92D68-AFCB-4019-AE1D-12DC06C5E477 Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=us-ascii yes again

here is a file

--Apple-Mail=_E9B92D68-AFCB-4019-AE1D-12DC06C5E477 Content-Disposition: attachment; filename=carhartl-jquery-cookie-v1.4.1-0-g7f88a4e.zip Content-Type: application/zip; x-unix-mode=0644; name="carhartl-jquery-cookie-v1.4.1-0-g7f88a4e.zip" Content-Transfer-Encoding: base64 UEsDBAoAAAAAAOdom0QAAAAAAAAAAAAAAAAfAAkAY2FyaGFydGwtanF1ZXJ5LWNvb2tpZS05MmI3 NzE1L1VUBQABc2NdU1BLAwQKAAAAAADnaJtEJW3tHSgAAAAoAAAAKQAJAGNhcmhhcnRsLWpxdWVy eS1jb29raWUtOTJiNzcxNS8uZ2l0aWdub3JlVVQFAAFzY11Tbm9kZV9tb2R1bGVzCmJ1aWxkCi5z aXplY2FjaGUuanNvbgoqLmxvZ1BLAwQKAAAACADnaJtEGK4L93IAAADtAAAAKAAJAGNhcmhhcnRs LWpxdWVyeS1jb29raWUtOTJiNzcxNS8uanNoaW50cmNVVAUAAXNjXVNVjsENwjAMRc/2FChnJmAL RkjbTxVkJa2DKVXV3UsOCFc+vfcsyxtT6Eqt4XZ5qeHaUMtSoc70prI6xtzmJLKJePGZ/AG8k68Z Sx8nL0rU0bHlAQ/Ho5QuSntyY6LwjSnj3yk87wZdvVHMlvS3xLTzzgdQSwMECgAAAAgA52ibRHjL 

Open in new window

0
The plan is that when the form is submitted, the owner receives an email containing the user info and all form values, and the user receives an email thanking them and showing the info they entered into the form they submitted.

However, the user email is sending correctly, but the owner is getting a copy of both.

I thought $email would only go only to the user who submitted the form, and $to_email would only send the submitted values to the owner. However, it also sends the owner both.

<?php
session_start();

  if($_SESSION['captcha']['code'] != $_POST["captcha"]){
	  die('<div style="font-size: 2em; width: 60%; margin: 140px auto">We\'re sorry, but you did not enter the security code correctly.  Please click the back button on your browser and try again.</div>');
	}
// Information to be modified
$to_email = "owner@company.com"; // email address to which the form data will be sent
$subject = "Hourly Quote Request"; // subject of the email that is sent$thanks_page = "#"; // path to the thank you page following successful form submission
$thanks_page = "confirm.html";
$contact_page = "#"; // path to the HTML contact page where the form appears

$first_name = strip_tags($_POST["contact_first_name"]);
$last_name = strip_tags($_POST["contact_last_name"]);
$phone = strip_tags($_POST["contact_phone"]);
$email = strip_tags($_POST["contact_email"]);
$date = strip_tags($_POST["Date"]);
$move_from = strip_tags($_POST["move_from"]);
$move_to = 

Open in new window

0
Hi Experts

Could you point how to obtain the values from the Javascript  Objects?

Javascript
console.log(Object.values(where));

Open in new window


Produced
img001
So, what's needed to obtain these Object's values?

Thanks in advance!
0
I need to write a rule in my apache htaccess file to redirect:

/insurance-plans/year/schools/international-student-plans-2015?s=136&l=5000
to:
http://%{SERVER_NAME}/insurance-plans/year/schools/international-student-plans-2017?s=136&l=7000

The rule I wrote is as follows, but it does nothing:

RewriteRule ^insurance-plans\/year\/schools\/international-student-plans-2015?s=136&l=5000$		http://%{SERVER_NAME}/insurance-plans/year/schools/international-student-plans-2017?s=136&l=7000	[R=301,L,NC,NE]

Open in new window


I'd be grateful if someone would show me the correct htaccess code to implement my redirect.

Thanks,
Jon
0
Hi

I am running a PHP script that generate a list of variables, merges them into a email template and sends it through Manrdill Mailchimp's transactional email system).

The process might loop for several thousand iterations to generate all the emails that need sending.

The script that I am using:

//generate data for all records
while($row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC)){
//populate some additional tables with info for each record
//merge each record into the email template
//send email
//update record to show that it has been emailed
}

This runs through all the records then snds the emails/updates the table etc. Depending on the number of records, this can take quite some time to process.

I have extended the PHP timeout and max-memory size to cope, but would prefer a better solution.

Would the ob_start() / ob_get_clean()  functions help by processing each record individually and not storing everything up in memory, potentially over loading the buffer/memory and then outputting everything.

If someone can advise if this is a good idea or not and how I should implement it, I'd be very grateful.

Thank you in advance
0
Hello experts,

Need some help

We have migrated a website from cpanel accelerated2 to another hosting provider who provided latest version of cpanel. The transfer was successful. However while browsing the website we are seeing below error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at webmaster@xxxx.com to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

I have gone through the error logs in cpanel which is logging below error everytime the domain is accessed.

corealert: pid xxxxx /home/xxx/public_html/.htaccess unknown filter provider deflate

At first we though php version 5.4 not installed is the issue, we have installed 5.4 via cpanel and restarted the http webserver but still same error.

Unable to understand where to look for

Any help is appreciated.

Thank you

best regards
0
How can I tell if a string is already encoded with base64?

When I run the example below it says it is base64 but it is not. When I send actual base64 encoded string it says it is base64 encoded as well. I understand how to decode base64 but I need a way to check if a string is really base64 or plain text so I know to decode it or not.

$data = 'This is a test';

if (base64_decode($data, true) === false) {
        echo 'Not a Base64-encoded string\n\n';
} else {
        echo 'Yes it is a base64 encoded string\n\n';
}

Open in new window

0
Without having to use YouTube. I would like to know and learn how to transcode videos. What are some great places to learn?
0
So, I am really trying to get my head around JSON and I have tried this which works but I wanted to know if there is a better way to do it or if this okay. I am actually playing around with developing a hybrid mobile app which uses a php and mysql backend. I have to use ajax to retrieve data and I want to also use JSON.

This is the jQuery/Ajax. The double dollar signs are not a typo, that is the correct syntax for the application but it is identical to jQuery as far as I know.

$$( "#submit" ).click(function(e){
		$$.ajax({
			url:"content.php",
			type:"POST",
			dataType:"json",
			success: function(data) {
				var len = data.length;
				for(var i = 0; i<len; i++) {;
					var user_name = data[i].user_name;
					$$( "#phpcontent" ).append(`
					<li class="item-content">
						<div class="item-inner">
						<div class="item-title">${user_name}</div>
						</div>
					</li>
					`);
				}
			}
		});
	});

Open in new window


This is the php for content.php

$stmt = $link->prepare("SELECT `user_name` FROM `users` ORDER BY `user_name` DESC");
$stmt->execute();
$result = $stmt->get_result();
$numRows = $result->num_rows;
if($numRows > 0) {
	while($row = $result->fetch_assoc()) {
		$user_name = sanitize($row['user_name']);
		
		$return_array[] = array(
		
			"user_name" => $user_name
		
		);
	}
}
$stmt->close();
echo json_encode($return_array);

Open in new window


What I have noticed in all the examples I have looked at is that the database results have to be put into an array in order to use json_encode. Am I correct in saying that or is it just a coincidence that every example I looked at did that?
0
Salesforce Has Never Been Easier
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

hai...in phpmyadmin data base table my DOB is coming in adding foramt...did i need to change the type...???

my code in php format:

 $DOBMonth = false;
if(isset($_POST['DOBMonth'])){
    $DOBMonth = $_POST['DOBMonth'];
 }

$DOBDay = false;
if(isset($_POST['DOBDay'])){
    $DOBDay = $_POST['DOBDay'];
 }

$DOBYear = false;
if(isset($_POST['DOBYear'])){
    $DOBYear = $_POST['DOBYear'];
 }


$DateOfBirth=$DOBMonth+"/"+$DOBDay+"/"+$DOBYear;
0
Hello
I am using a script that backups and restores mysql databases. The script works fine until I include an external JS file, which is when I get the title error in firebug. There is a lot of code but I think I can narrow the error to line 692 but what ever I try, I keep getting the error.

I must add I never created the script so cannot give any further info on it's content, but it does what I want it to do, apart from this error.

I would be grateful if somone could help with this. Many thanks

<?php

// Report errors

error_reporting(E_ERROR | E_PARSE | E_NOTICE);

// error_reporting(E_ALL);	//Debug purpose

$host = 'localhost'; //HOST;//eg:localhost
$username = 'root'; //USER;//self explanatory
$passwd = ''; //PASSWORD;//self explanatory
$charset = 'utf8'; //charset keeps preferred character encoding
$port = '3306'; //self explanatory
$dateformat = 'd-m-Y H-i-s-A'; // will be appended to database backup file name eg:test_2016-Oct-25-10-30-54-AM.zip

// small utility function to detect whether secured server or not

function isSiteSSL()
{
  return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443;
}

$url = (isSiteSSL() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

if (isset($_SERVER['QUERY_STRING'])) {
  $url = str_replace('?' . $_SERVER['QUERY_STRING'], '', $url); //removing query string to get exact url
}

$url2 = $url; //$url2 used for building download url
$url.= 

Open in new window

0
If $_SERVER vars are an array, what would the code look like to access each var such as 'REQUEST_TIME'?
0
With the following code in place:

 <?php echo $form->dropDownListRow($model, 'specialty_id', DoctorSpecialty::listOptions()); ?>

How would I limit the possible choices to just two of four?  I can't delete the other two from the table because they are used in the database in other places.
0
I added codeigniter 'table' to my project and i got desired outcome for view except for the fact that the way i had it before i was able to delete record by clicking on them since they were anchor tags, i would like to know how to recreate this in new table format. Thanks!
site_model.php
site.php
options_view.php
Capture2.PNG
Capture.PNG
0
How can i show my url path in my body tag
If i am on a page example.com/abhinav
How can i show "abhinav" in<body>You are at "abhinav"</body>

and i also want a form action type code when i write in it like my name and click submit so it opens url.com/myname
i mean just whatever i write in form action that shows me in my url after slash
0
Hello
I am struggling to convert a date that I use as part of a filename of a zip file. At the moment it prints
bootstrap_21-Jun-2017-16-04-09-PM.zip
but I need to have it print
bootstrap_21/06/2017 16-04-09-PM.zip

I have posted the code I am using and would be grateful if someone could help with this. Thanks

$dateformat='d-M-Y-H-i-s-A';

case 'backupfile':
    echo    $_POST['db'].'_'.date($dateformat, time());					
break;

Open in new window

0
I have linux server and i want to count pdf pages is colored or bw.

i have used imagemagic but it takes serverd down so can you help me with alternative way?
0
As some people have encountered the need to decompress a response I got from a PHP request. I've found how to do that - assuming you have control of the request and you can set the Accept-Encoding header.
0
Industry Leaders: We Want Your Opinion!
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Hello,
I have downloaded and installed wamp on my system but I can't connect to phpmyadmin though I write "localhost/phpmyadmin" in the url.
I really need your helps .
thanks.
0
I have attached files, i am trying to display results in a table, i am new to codeigniter is there a way to do this? what would be the best way to implement this? i have read about codeigniter tables but i am not sure how to apply to my code. Any guidance will be appreciated.
Thank You!
site.php
site_model.php
options_view.php
0
See my below code.

$query_rs_media_new_group = "SELECT supplier_code, title, url, description, description_item, brand, type, weight, category, section, width, label_artwork, min(id) as id 
							 FROM media_new 
							 WHERE media_binder = '1'
							 GROUP BY title 
							 ORDER BY brand";
$rs_media_new_group = mysql_query($query_rs_media_new_group, $conn_cmyuk) or die(mysql_error());
$row_rs_media_new_group = mysql_fetch_assoc($rs_media_new_group);
$totalRows_rs_media_new_group = mysql_num_rows($rs_media_new_group);

Open in new window


The order by brand is not coming out in the correct order. Could this be something to do with the alias or group by?
0
Hi,

I keep getting an error

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[08001] SQLDriverConnect: 0 [unixODBC][FreeTDS][SQL Server]Unable to connect to data source'

Here is my log:

[ODBC][25605][1497970106.192244][__handles.c][450]
		Exit:[SQL_SUCCESS]
			Environment = 0x1ab5550
[ODBC][25605][1497970106.192302][SQLSetEnvAttr.c][182]
		Entry:            
			Environment = 0x1ab5550            
			Attribute = SQL_ATTR_ODBC_VERSION            
			Value = 0x3            
			StrLen = 0
[ODBC][25605][1497970106.192331][SQLSetEnvAttr.c][349]
		Exit:[SQL_SUCCESS]
[ODBC][25605][1497970106.192355][SQLSetEnvAttr.c][182]
		Entry:            
			Environment = 0x1ab5550            
			Attribute = SQL_ATTR_CP_MATCH            
			Value = (nil)            
			StrLen = 0
[ODBC][25605][1497970106.192378][SQLSetEnvAttr.c][349]
		Exit:[SQL_SUCCESS]
[ODBC][25605][1497970106.192405][SQLAllocHandle.c][364]
		Entry:
			Handle Type = 2
			Input Handle = 0x1ab5550
[ODBC][25605][1497970106.192431][SQLAllocHandle.c][482]
		Exit:[SQL_SUCCESS]
			Output Handle = 0x1ab5ba0
[ODBC][25605][1497970106.192462][SQLSetConnectAttr.c][321]
		Entry:            
			Connection = 0x1ab5ba0            
			Attribute = SQL_ATTR_AUTOCOMMIT            
			Value = 0x1            
			StrLen = -6
[ODBC][25605][1497970106.192497][SQLSetConnectAttr.c][504]
		Exit:[SQL_SUCCESS]
[ODBC][25605][1497970106.192527][SQLSetConnectAttr.c][321]
		Entry:            
			Connection = 0x1ab5ba0      

Open in new window

0
Hi,

I'm using PHP and dblib to connect tp a MS SQL server data base, i can connect and talk to the database fine but I'm finding it hard to pull a single row of data or a single entry

$con = new PDO("dblib:host=****;dbname=nursery",'pcbuddy','****');

Open in new window


foreach($_POST['selectedinvoices'] as $ids)
{
				
				$query_today = $con->prepare("SELECT * FROM Invoices WHERE invoice_no = :ID");
				$query_today->bindParam(':ID', $ids, PDO::PARAM_INT);
				$query_today->execute();
									
				echo $stmt["invoice_no"];

Open in new window


No matter what I try I cant do a single select query.

Please help
0
i want to generate bunch of barcode with different data in php in same page on single click.
i try or learn many source code but only single barcode will be print using php but i want multiple barcode generation code so will you please help me to solve this asap.
Thank You !!!
0

PHP

118K

Solutions

126

Articles & Videos

32K

Contributors

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.