将日期计为用户ID

时间:2014-10-23 05:37:27

标签: php

我正在创建一个票务系统,使用日期作为我的UID,但它有+数字可以计算,起初它正在工作,但现在没有出现错误,要删除的内容以及在此代码中添加的内容?随意纠正

    <?php
error_reporting(E_ALL); ini_set('display_errors', 1);
session_start();
ob_start();
$dbhost = '192.168.0.9';
$dbuser = 'dsc';
$dbpass = 'csd';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('ERROR CONNECTING TO MY
SQL');

$dbname = 'dbtips';
mysql_select_db($dbname);

if(isset($_POST['ok']))
{
                $id=$_POST['id'];
                $title=$_POST['newstitle'];
                $status=$_POST['newsstatus'];
                $street=$_POST['newsstreet'];
                $content=$_POST['newscontent'];
                $date=date("y-m-d");
                $udate=date("Y-m-d");
        $newslink=str_replace(" ","-",$id);     

        $ticket=mysql_query("select count(date) as ticketcount from tblnews where date='$date'",$conn);
        if($data=mysql_fetch_array($ticket))
        {
        $ticketcount=$data['ticketcount'];

        if($ticketcount==0)
        {
mysql_query("insert into tblnews(title,street,status,content,date,udate) values('$title','$street','$status','$content','$date','$udate-001')",$conn) or die(mysql_error());
        echo "<script>alert('1st Ticket of the day!')</script>";
        header('Refresh:0;URL=file.php');
        }
        else if($ticketcount==1)
        {
mysql_query("insert into tblnews(title,street,status,content,date,udate) values('$title','$street','$status','$content','$date','$udate-001')",$conn) or die(mysql_error());
                echo "<script>alert('2nd Ticket of the day!')</script>";
                header('Refresh:0;URL=file.php');       
        }

else
{
        header("Refresh: 0;url=file_table.php?n=".$id);
}
?>

1 个答案:

答案 0 :(得分:0)

第45行和第50行缺少关闭标记

你应该整理编码以便轻松调试

<?php
    error_reporting(E_ALL);
    ini_set('display_errors', 1);
    session_start();
    ob_start();

    $dbhost = '192.168.0.9';
    $dbuser = 'dsc';
    $dbpass = 'csd';

    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('ERROR CONNECTING TO MYSQL');

    $dbname = 'dbtips';
    mysql_select_db($dbname);

    if(isset($_POST['ok']))
    {
        $id = $_POST['id'];
        $title = $_POST['newstitle'];
        $status = $_POST['newsstatus'];
        $street = $_POST['newsstreet'];
        $content = $_POST['newscontent'];
        $date = date("y-m-d");
        $udate = date("Y-m-d");
        $newslink = str_replace(" ","-",$id);     

        $ticket = mysql_query("select count(date) as ticketcount from tblnews where date='$date'",$conn);

        if($data = mysql_fetch_array($ticket))
        {
            $ticketcount = $data['ticketcount'];

            if($ticketcount == 0)
            {
                mysql_query("insert into tblnews(title,street,status,content,date,udate) values('$title','$street','$status','$content','$date','$udate-001')",$conn) or die(mysql_error());
                echo "<script>alert('1st Ticket of the day!')</script>";
                header('Refresh:0;URL=file.php');
            }
            else if($ticketcount==1)
            {
                mysql_query("insert into tblnews(title,street,status,content,date,udate) values('$title','$street','$status','$content','$date','$udate-001')",$conn) or die(mysql_error());
                echo "<script>alert('1st Ticket of the day!')</script>";
                header('Refresh:0;URL=file.php');       
            }
        }
        else
        {
            header("Refresh: 0;url=file_table.php?n=".$id);
        }
    }
?>