Laravel 5.3解析错误:语法错误,意外' $ table'迁移时(T_VARIABLE)

时间:2017-01-20 02:54:44

标签: laravel-5.3 database-migration

继承我的迁移代码:



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;
using System.IO;

namespace JeremyThompsonLabs
{
    public class Screenshot
    {
        public static string TakeScreenshotReturnFilePath()
        {
            int screenLeft = SystemInformation.VirtualScreen.Left;
            int screenTop = SystemInformation.VirtualScreen.Top;
            int screenWidth = SystemInformation.VirtualScreen.Width;
            int screenHeight = SystemInformation.VirtualScreen.Height;

            // Create a bitmap of the appropriate size to receive the screenshot.
            using (Bitmap bitmap = new Bitmap(screenWidth, screenHeight))
            {
                // Draw the screenshot into our bitmap.
                using (Graphics g = Graphics.FromImage(bitmap))
                {
                    g.CopyFromScreen(screenLeft, screenTop, 0, 0, bitmap.Size);
                }

                var uniqueFileName = Path.Combine(System.IO.Path.GetTempPath(), Path.GetRandomFileName().Replace(".", string.Empty) + ".jpeg");
                try
                {
                    bitmap.Save(uniqueFileName, ImageFormat.Jpeg);
                }
                catch (Exception ex)
                {
                    return string.Empty;
                }
                return uniqueFileName;
            }
        }

    }
}




但在我运行' php artisan migrate'后,会出现以下错误。

[Symfony的\元器件\调试\异常\ FatalThrowableError]
解析错误:语法错误,意外' $ table' (T_VARIABLE)

请帮忙!我正在迁移到phpmyadmin数据库。

5 个答案:

答案 0 :(得分:4)

是的@Bagus Tesa是对的。 (只是想回答,因为我几乎错过了评论,因为它没有答案) 丢失的分号;可能是问题所在。检查所有修改后的迁移。

答案 1 :(得分:0)

检查到另一个迁移中是否有一些字符或丢失的东西,就我而言,我忘记了旧迁移中的一个字符:(,在删除对我有用的字符之后!

答案 2 :(得分:0)

当我将另一个程序Freemind 1.0.1的字段列表剪切并粘贴到VS Code(1.47.1之前的版本)时,发生了错误。一些粘贴的行包括前导空格。 VS Code不断显示错误,直到所有前导空格都被删除并替换为通常的Tab键。

有必要开始删除突出显示的错误行上方的前导空格。然后,错误突出显示将在代码中逐行跳动,直到消失为止。

有时错误从 意外的“ $ table” 至: 意外的''

因为问题出在前导空格,所以与丢失的分号解决方案不同,无法看到它。

答案 3 :(得分:0)

此行中缺少分号$ table-> integer('customer_name')add分号$ table-> integer('customer_name');

答案 4 :(得分:0)

$table->integer('customer_name')

缺少分号';'

同时为了避免在编码时出现这些错误,您应使用此类EA检查代码插件,通常的气味检查代码和背景检查工具