小编Eri*_*.18的帖子

PHPMailer - 重复变量

我有一个由PHP页面处理的HTML表单.我使用mail()完全按照我的需要工作,但遇到了电子邮件部分的问题.发送电子邮件非常不一致,这是不可接受的.我知道mail()只负责过程的一小部分,邮件服务器负责繁重的工作.

我正在尝试PHPMailer作为替代方案.我已经启动并运行,并且能够收到邮件但是有些功能不存在.

在我的表单中,您可以将多个"项目"添加到单个提交中.php应该循环遍历这些项目并为电子邮件中的每个项目创建一个部分.同样,这与mail()一起使用,但并不总是发送.

我想要实现的代码如下.它将发送一封电子邮件,但如果有多个,则不会循环显示表单字段.它只会看到输入的最后一个.

<?php
require 'PHPMailerAutoload.php';

date_default_timezone_set('America/New_York');
$today = date("F j - Y - g:i a");

$mail = new PHPMailer;

$mail->isSMTP();                       // Set mailer to use SMTP
$mail->Host = 'mail.example.com';      // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                // Enable SMTP authentication
$mail->Username = 'mail@example.com';  // SMTP username
$mail->Password = 'password';          // SMTP password
$mail->SMTPSecure = 'tls';             // Enable encryption, 'ssl' also accepted

$mail->From = 'mail@example.com';
$mail->FromName = 'From name';
$mail->addAddress('mail@example.com', 'personName');     // …
Run Code Online (Sandbox Code Playgroud)

php email phpmailer

3
推荐指数
1
解决办法
229
查看次数

使用PHP修改json而不保存/更新

我试图用PHP修改json文件中的数据.我正在使用的代码如下.它能够成功地准备文件内容,并且在foreach循环中它将在if语句中回显.

这很好,if语句现在是硬编码测试.我想要做的是修改各种属性并将其写回文件.这似乎不起作用.当我加载页面,然后刷新以查看是否设置了新值,它只是保持回显相同的值.我在本地下载.json,没有任何改变.

对我做错了什么的想法?

//Get file, decode
$filename = '../json/hartford.json';
$jsonString = file_get_contents($filename);
$data = json_decode($jsonString, true);

foreach ($data['features'] as $key => $segment) {

    if ($segment['properties']['UID'] == '25301') {

//echo out properties for testing
        echo("KEY: ".$key."<br/>");
        echo("UID: ".$segment['properties']['UID']."<br/>");
        echo("Full Name: ".$segment['properties']['FULLNAME']."<br/>");
        echo("FCC: ".$segment['properties']['FCC']."<br/>");
        echo("Render CL: ".$segment['properties']['RENDER_CL']."<br/>");
        echo("<hr/>");

 //set property to new value.... NOT WORKING?
        $segment['properties']['RENDER_CL'] = 111;
    }
}

//Test if file is writable to be sure
$writable = ( is_writable($filename) ) ? TRUE : chmod($filename, 0755);

if ( $writable ) …
Run Code Online (Sandbox Code Playgroud)

php json

2
推荐指数
1
解决办法
48
查看次数

将CLLocationCoordinate2D的字符串转换为数组

更新先前的问题以获得更好的解释。

var breadcrumbs: [CLLocationCoordinate2D] = []
var path: [CLLocationCoordinate2D] = []
Run Code Online (Sandbox Code Playgroud)

每10秒钟调用一次,以将CLLocationCoordinate2D附加到数组。

func addBreadcrumb(){
    let speed = (locationmanager.location?.speed)!
    let speedRounded = speed.roundTo(places: 4)
    let crumbCoordinate = locationmanager.location?.coordinate

    breadcrumbs.append(crumbCoordinate!)
    tripSpeeds.append(speedRounded)
}
Run Code Online (Sandbox Code Playgroud)

一旦用户完成行程,他们便会点击一个按钮,并调用以下功能。这会将数据输入到Firebase中。我将另存为字符串,否则将收到错误消息。

func submitTripPath(){
    let tripID: String? = tripUID
    let tripPath = String(describing: breadcrumbs) //This may be the problem
    let speeds = String(describing: tripSpeeds)

    var ref: FIRDatabaseReference!
    ref = FIRDatabase.database().reference()
    let tripRef = ref.child("TripPaths").child(tripID!)
    let tripDictionary = ["routePath" : tripPath, "routeSpeed" : speeds] as [String : Any]
    tripRef.updateChildValues(tripDictionary) { (err, ref) …
Run Code Online (Sandbox Code Playgroud)

cllocation ios firebase swift firebase-realtime-database

1
推荐指数
1
解决办法
514
查看次数

在 Swift 中将 CBUUID 转换为字符串

我正在扫描蓝牙设备。我想将它们记录在一个字符串数组中。我希望能够保存它们,但出现以下错误:

无法将“CBUUID”(0x1f2760918)类型的值转换为“NSString”(0x1f26a42d0)。

CoreBT[9728:3053605] 无法将“CBUUID”(0x1f2760918)类型的值转换为“NSString”(0x1f26a42d0)。

我在下面有以下代码。没有对数组的引用,因为我什至无法将其转换为字符串。

func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {

    if let peripheralName = advertisementData[CBAdvertisementDataLocalNameKey] as? String {


        print("peripheral Name: \(peripheralName)")

        let uniqueID = (advertisementData["kCBAdvDataServiceUUIDs"] as! NSArray).firstObject! as! String 
        // The above line produces an error
        //Removing as! String will work prevent error but still cannot get from "any" to "string"

        let x = advertisementData
        print("x: \(x)")
        let y = advertisementData["kCBAdvDataServiceUUIDs"]
        print("y: \(y)")

        print("uniqueID: \(uniqueID)")
        self.UIDCountNumber = UIDCountNumber + 1 …
Run Code Online (Sandbox Code Playgroud)

ios core-bluetooth swift

1
推荐指数
2
解决办法
2667
查看次数

Disable button based on attribute in javascript

I have a form which processes data and puts it in to a csv. A user can add multiple rows to the form to add a new item. To make this a unique item the id is incremented by 1 (ex. item[0] goes to item1)

The form works great but I am trying to add a delete / remove button. It works except I don't want it to remove the very last item.

Below is the code I …

html javascript jquery

0
推荐指数
1
解决办法
73
查看次数