Forum Sementara Putera.com

Bersama kita perkemaskan forum ini sementara forum asal dalam pemulihan.

Forum putera dah kembali. Masalah sudah berjaya diselesaikan. Sila lawati http://forum.putera.com/tanya


    tak leh insert value dlm database (PHP MySQL)

    Share

    jeliey
    Ahli Baharu
    Ahli Baharu

    Number of posts : 26
    Registration date : 01/04/2009

    tak leh insert value dlm database (PHP MySQL)

    Post by jeliey on Tue Nov 24, 2009 12:08 pm

    Ada tak sesapa yg leh tolong...

    ERROR:INSERT INTO issues (title,catid,pid,desc,date) VALUES ('Online Selling System','1','2','How to create cart?',NOW()).You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc,date) VALUES ('Online Selling System','1','2','How to create cart?',NOW())' at line 1

    aku dapat error macam kat atas tu...ni coding aku...dah tak larat daa

    Code:

    <?php

       if(isset($_POST['submit']))
       {
          //check form input for errors
          //check title
          if(trim($_POST['title'])=='')
          {
             die('ERROR:Please enter title');
          }
          
          mysql_connect("localhost","root","") or die (mysql_error());
          mysql_select_db("system") or die (mysql_error());
          
          //generate and execute query to insert question
          $query="INSERT INTO issues (title,catid,pid,desc,date) VALUES ('{$_POST['title']}','{$_POST['catid']}','{$_POST['pid']}','{$_POST['desc']}',NOW())";
          $result=mysql_query($query)or die("ERROR:$query.".mysql_error());
          
          //print success message
          echo "Issues successfully added to the database! Click <a href='view.php>here</a> to view page";
       }
       else
       {
          die('ERROR:Data not correctly submitted');
       }
    ?>
    Embarassed

    ayoi
    Moderators
    Moderators

    Gender : Male Number of posts : 1090
    Age : 86
    Registration date : 04/03/2009

    Re: tak leh insert value dlm database (PHP MySQL)

    Post by ayoi on Tue Nov 24, 2009 12:59 pm

    jeliey wrote:Ada tak sesapa yg leh tolong...

    ERROR:INSERT INTO issues (title,catid,pid,desc,date) VALUES ('Online Selling System','1','2','How to create cart?',NOW()).You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc,date) VALUES ('Online Selling System','1','2','How to create cart?',NOW())' at line 1

    aku dapat error macam kat atas tu...ni coding aku...dah tak larat daa

    Code:

    <?php

       if(isset($_POST['submit']))
       {
          //check form input for errors
          //check title
          if(trim($_POST['title'])=='')
          {
             die('ERROR:Please enter title');
          }
          
          mysql_connect("localhost","root","") or die (mysql_error());
          mysql_select_db("system") or die (mysql_error());
          
          //generate and execute query to insert question
    //ubah yang ni
          //$query="INSERT INTO issues (title,catid,pid,desc,date) VALUES ('{$_POST['title']}','{$_POST['catid']}','{$_POST['pid']}','{$_POST['desc']}',NOW())";
       //   $result=mysql_query($query)or die("ERROR:$query.".mysql_error());
          $sql = "INSERT INTO `issues` (title,catid,pid,desc,date)
                    VALUES ('$title','$catid','$pid','$desc','$date')";
    $post = mysql_query($sql);
    if ($post){
          
          echo "Issues successfully added to the database! Click <a href='view.php>here</a> to view page";
    echo $sql;
                    }
                else
                  echo "Error message = ".mysql_error(); 
       
            }
        }
    }


    ?>
    Embarassed


    --------------------------------------------
    ku mencuba survey
    Don't break my heart

    dans kam
    Ahli Baharu
    Ahli Baharu

    Gender : Male Number of posts : 172
    Age : 35
    Location : Wangsa Maju
    Job/hobbies : PHP
    Registration date : 19/02/2009

    Re: tak leh insert value dlm database (PHP MySQL)

    Post by dans kam on Tue Nov 24, 2009 2:20 pm

    Nak tanya, pid tu ape? primary key atau id ape?
    kalo primary key, xyah la insert jugak, buat auto_increment je la..

    jeliey
    Ahli Baharu
    Ahli Baharu

    Number of posts : 26
    Registration date : 01/04/2009

    Re: tak leh insert value dlm database (PHP MySQL)

    Post by jeliey on Tue Nov 24, 2009 2:28 pm

    skarang ni nk insert value dlm table issues(id,title,catid,desc,pid,date)

    pid dan catid tu foreign key...

    pid is PK for priority table and catid is PK for category table

    yang bawah ni form utk user input data
    Code:

    <h3>New Post</h3>
    <form action='submit.php' method='POST'>
       <table>
          <tr>
             <td>Title</td><td>:</td><td><input type='text' name='title'></td>            
          </tr>
          <tr>      
             <td>Category</td><td>:</td><td>
                <?php
                
                   mysql_connect("localhost","root","") or die (mysql_error());
                   mysql_select_db("system") or die (mysql_error());
       
                   $query="SELECT catid,catname FROM category";
                   $result=mysql_query ($query);
                   echo "<select name='catid'>";
                   
                   while ($nt=mysql_fetch_array($result))
                   {
                      echo "<option value=$nt[catid]>$nt[catname]</option>";
                   }
                   echo "</select>";
                ?>               
             </td>            
          </tr>
          <tr>
             <td>Priority</td><td>:</td><td>
                <?php
                
                   mysql_connect("localhost","root","") or die (mysql_error());
                   mysql_select_db("system") or die (mysql_error());
                   
                   $query="SELECT pid,pname FROM priority";
                   $result=mysql_query($query);
                   echo "<select name='pid'>";
                   
                   while ($nt=mysql_fetch_array($result))
                   {
                      echo "<option value=$nt[pid]>$nt[pname]</option>";
                   }
                   echo "</select>";
                ?>
             </td>      
          </tr>
          <tr>
             <td>Description</td><td>:</td>
                <tr><td><td></td></td><td><textarea name='desc' rows='15' cols='50'></textarea></td></tr>            
          </tr>
          <tr>
             <td><td></td></td><td align='right'><input type='submit' name='submit' value='Post Issue'></td>                       
          </tr>
       </table>
    </form>

    tp bila user click post kuar error yg macam atas tu

    dans kam
    Ahli Baharu
    Ahli Baharu

    Gender : Male Number of posts : 172
    Age : 35
    Location : Wangsa Maju
    Job/hobbies : PHP
    Registration date : 19/02/2009

    Re: tak leh insert value dlm database (PHP MySQL)

    Post by dans kam on Tue Nov 24, 2009 2:58 pm

    Nape tah akupun confius nape jadi mcm tu. Razz

    Bleh tgk table issues ko x? kot2 dpt idea ke. ...

    Farlee
    Ahli Baharu
    Ahli Baharu

    Gender : Male Number of posts : 38
    Age : 33
    Location : Kuala Lumpur, Kuala Terengganu (Malaysia)
    Job/hobbies : Looking at Computer
    Registration date : 16/03/2009

    Re: tak leh insert value dlm database (PHP MySQL)

    Post by Farlee on Tue Nov 24, 2009 3:36 pm

    sama ada dia silap susunan nama "padang" (field) utk table ataupun nama "padang" tu yg salah...
    Anyway, mcm dans mintak.. tunjukkan table issue + category bersama nama field masing2 (dan atribut skali)..

    neology
    Ahli Baharu
    Ahli Baharu

    Gender : Male Number of posts : 372
    Age : 30
    Registration date : 25/04/2009

    Re: tak leh insert value dlm database (PHP MySQL)

    Post by neology on Tue Nov 24, 2009 5:17 pm

    Code:
    $query="INSERT INTO issues (title,catid,pid,desc,date) VALUES ('{$_POST['title']}','{$_POST['catid']}','{$_POST['pid']}','{$_POST['desc']}',NOW())";

    cuba tukar

    Code:
    $query="INSERT INTO system.issues (title,catid,pid,desc,date) VALUES ('{$_POST['title']}','{$_POST['catid']}','{$_POST['pid']}','{$_POST['desc']}',NOW())";

    jeliey
    Ahli Baharu
    Ahli Baharu

    Number of posts : 26
    Registration date : 01/04/2009

    Re: tak leh insert value dlm database (PHP MySQL)

    Post by jeliey on Wed Nov 25, 2009 9:20 am

    neorology, xdapat la...error sama jgk

    ni table:

    Code:

    $sql="CREATE TABLE category
       (
          catid int(11) NOT NULL auto_increment PRIMARY KEY,
          catname varchar(255) NOT NULL,
          catdesc varchar(255) NOT NULL
       )
       engine='innodb'";
       
    $sql="CREATE TABLE issues
          (
          id int(11) NOT NULL auto_increment PRIMARY KEY,
          title varchar(255) NOT NULL,
                    catid int(11) NOT NULL,
          desc varchar(255) NOT NULL,
                    pid int(11) NOT NULL,
          date date NOT NULL
       )
       engine='innodb'";

    $sql="CREATE TABLE priority
       (
          pid int(11) NOT NULL auto_increment PRIMARY KEY,
          pname varchar(255) NOT NULL
       )
       engine='innodb'";   

    johnburn
    Moderators
    Moderators

    Gender : Male Number of posts : 755
    Location : Terengganu
    Registration date : 07/03/2009

    Re: tak leh insert value dlm database (PHP MySQL)

    Post by johnburn on Wed Nov 25, 2009 10:14 am

    jap aku try tgk. nt aku reply blk.
    --edit--
    bleh x ko bg sql dump dr phpmyadmin ke Very Happy


    --------------------------------------------

    tahukah kamu saat kamu menangis
    adalah air mata ku yang jatuh berlinang
    tahukah kamu saat kamu tersakiti
    adalah aku yang pertama terluka
    Jangan Klik

    jeliey
    Ahli Baharu
    Ahli Baharu

    Number of posts : 26
    Registration date : 01/04/2009

    Re: tak leh insert value dlm database (PHP MySQL)

    Post by jeliey on Wed Nov 25, 2009 11:25 am

    macamane nk wat attachment kat sini?ingat nk attach sql tu...

    johnburn
    Moderators
    Moderators

    Gender : Male Number of posts : 755
    Location : Terengganu
    Registration date : 07/03/2009

    Re: tak leh insert value dlm database (PHP MySQL)

    Post by johnburn on Wed Nov 25, 2009 11:28 am

    attachment xleh kot. ko paste je. pkai bbcode [code]


    --------------------------------------------

    tahukah kamu saat kamu menangis
    adalah air mata ku yang jatuh berlinang
    tahukah kamu saat kamu tersakiti
    adalah aku yang pertama terluka
    Jangan Klik

    jeliey
    Ahli Baharu
    Ahli Baharu

    Number of posts : 26
    Registration date : 01/04/2009

    Re: tak leh insert value dlm database (PHP MySQL)

    Post by jeliey on Wed Nov 25, 2009 11:34 am

    Aku dah ubah sket table issues,tambah userid coz nk display sape yg post issue
    pastu,sume values dlm table issues tu,aku masukkan manual dlm database,saje nk test...
    tp kalu insert mmg xmasuk la

    Code:

    -- phpMyAdmin SQL Dump
    -- version 2.9.1.1
    -- http://www.phpmyadmin.net
    --
    -- Host: localhost
    -- Generation Time: Nov 24, 2009 at 09:19 PM
    -- Server version: 5.0.45
    -- PHP Version: 5.2.9
    --
    -- Database: `system`
    --

    -- --------------------------------------------------------

    --
    -- Table structure for table `category`
    --

    CREATE TABLE `category` (
      `catid` int(11) NOT NULL auto_increment,
      `catname` varchar(255) NOT NULL,
      `catdesc` varchar(255) NOT NULL,
      PRIMARY KEY  (`catid`)
    ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;

    --
    -- Dumping data for table `category`
    --

    INSERT INTO `category` (`catid`, `catname`, `catdesc`) VALUES
    (1, 'PHP', 'Related to PHP'),
    (2, '.NET', 'Related to .NET'),
    (3, 'Java', 'Related to Java');

    -- --------------------------------------------------------

    --
    -- Table structure for table `issues`
    --

    CREATE TABLE `issues` (
      `id` int(11) NOT NULL auto_increment,
      `title` varchar(255) NOT NULL,
      `catid` int(11) NOT NULL,
      `desc` varchar(255) NOT NULL,
      `pid` int(11) NOT NULL,
      `date` date NOT NULL default '0000-00-00',
      `userid` int(11) NOT NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;

    --
    -- Dumping data for table `issues`
    --

    INSERT INTO `issues` (`id`, `title`, `catid`, `desc`, `pid`, `date`, `userid`) VALUES
    (2, 'Foreign Key', 1, 'How to create foreign key in MySQL database?', 3, '2009-11-17', 1),
    (3, 'Online Shopping System', 1, 'Is it possible to drag the items into cart? it means that, users don''t have to click', 2, '2009-11-24', 1);

    -- --------------------------------------------------------

    --
    -- Table structure for table `priority`
    --

    CREATE TABLE `priority` (
      `pid` int(11) NOT NULL auto_increment,
      `pname` varchar(255) NOT NULL,
      PRIMARY KEY  (`pid`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;

    --
    -- Dumping data for table `priority`
    --

    INSERT INTO `priority` (`pid`, `pname`) VALUES
    (1, 'Normal'),
    (2, 'Important'),
    (3, 'Urgent');

    -- --------------------------------------------------------

    --
    -- Table structure for table `users`
    --

    CREATE TABLE `users` (
      `userid` int(11) NOT NULL auto_increment,
      `username` varchar(255) NOT NULL,
      `email` varchar(255) NOT NULL,
      `password` varchar(255) NOT NULL,
      PRIMARY KEY  (`userid`)
    ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

    --
    -- Dumping data for table `users`
    --

    INSERT INTO `users` (`userid`, `username`, `email`, `password`) VALUES
    (1, ' liana ', ' liana@gmail.com ', ' liana ');

    --
    -- Constraints for dumped tables
    --

    --
    -- Constraints for table `issues`
    --
    ALTER TABLE `issues`
      ADD CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`id`) REFERENCES `category` (`catid`) ON DELETE CASCADE;


    Last edited by jeliey on Wed Nov 25, 2009 11:37 am; edited 1 time in total

    jeliey
    Ahli Baharu
    Ahli Baharu

    Number of posts : 26
    Registration date : 01/04/2009

    Re: tak leh insert value dlm database (PHP MySQL)

    Post by jeliey on Wed Nov 25, 2009 11:35 am

    camna nk wat foreign key dlm MySQL admin tu?

    johnburn
    Moderators
    Moderators

    Gender : Male Number of posts : 755
    Location : Terengganu
    Registration date : 07/03/2009

    Re: tak leh insert value dlm database (PHP MySQL)

    Post by johnburn on Wed Nov 25, 2009 11:37 am

    aku agak prob tu sbb ko pkai FK. die ade constrain tu. tp xtgk btol2 lg. jap lg aku rply blk


    --------------------------------------------

    tahukah kamu saat kamu menangis
    adalah air mata ku yang jatuh berlinang
    tahukah kamu saat kamu tersakiti
    adalah aku yang pertama terluka
    Jangan Klik

    jeliey
    Ahli Baharu
    Ahli Baharu

    Number of posts : 26
    Registration date : 01/04/2009

    Re: tak leh insert value dlm database (PHP MySQL)

    Post by jeliey on Wed Nov 25, 2009 11:40 am

    sebab aritu aku main klik2 ja, igt nk create foreign key dlm table issues tu...tp xtau cmna...

    jeliey
    Ahli Baharu
    Ahli Baharu

    Number of posts : 26
    Registration date : 01/04/2009

    Re: tak leh insert value dlm database (PHP MySQL)

    Post by jeliey on Tue Dec 01, 2009 9:11 am

    Sad xde sape ke leh tolong....?

    johnburn
    Moderators
    Moderators

    Gender : Male Number of posts : 755
    Location : Terengganu
    Registration date : 07/03/2009

    Re: tak leh insert value dlm database (PHP MySQL)

    Post by johnburn on Tue Dec 01, 2009 11:25 am

    sori, lupe psal ni. nt aku tgk blk. tp aku terperasan satu bnde. untuk table issues tu, field date ngan desc tu xleh name tu sbb mysql dh reserve word tuh. try tukar jd issues_date ngan issues_desc. pe2 pn, nt ade mase aku tgk blk. try tukar name field tu dlu


    --------------------------------------------

    tahukah kamu saat kamu menangis
    adalah air mata ku yang jatuh berlinang
    tahukah kamu saat kamu tersakiti
    adalah aku yang pertama terluka
    Jangan Klik

    jeliey
    Ahli Baharu
    Ahli Baharu

    Number of posts : 26
    Registration date : 01/04/2009

    Re: tak leh insert value dlm database (PHP MySQL)

    Post by jeliey on Tue Dec 01, 2009 12:43 pm

    sama je error yg dapat...still tak leh insert userid...dapat error macam ni
    Code:

    Notice: Undefined index: userid in /opt/lampp/htdocs/system/submit.php on line 19
    INSERT INTO issues(title,catid,idesc,pid,idate,userid) VALUES ('issue',1,'Put your issue here',1,'2009-11-30',)ERROR:.Query was empty

    ni coding tuk submit.php...dah ubah sket kot,tambah session pun still xleh insert gak userid..tak paham toll
    Code:

    <?php
       session_start();

       if(isset($_POST['submit']))
       {
          //check form input for errors
          //check title
          if(trim($_POST['title'])=='')
          {
             die('ERROR:Please enter title');
          }
          
          //generate and execute query to insert question
          $title=$_POST['title'];
          $catid=$_POST['catid'];
          $pid=$_POST['pid'];
          $idesc=$_POST['idesc'];
          $idate=date("Y-m-d");
          $userid=$_SESSION['userid'];
          
          $connection=mysql_connect("localhost","root","")or die('ERROR:Unable to connect!');
          mysql_select_db("system",$connection)or die('ERROR:Unable to select database!');
          $sql = "INSERT INTO issues(title,catid,idesc,pid,idate,userid) VALUES ('".$title."',".$catid.",'".$idesc."',".$pid.",'".$idate."',".$userid.")";
          echo $sql;
          $query=mysql_query($sql);
          
          $result=mysql_query($query)or die("ERROR:$query.".mysql_error());
          
          
          mysql_close($connection);
          
          //print success message
          echo "Issues successfully added to the database! Click <a href='view.php'>here</a> to view the posted issues";
       }
       else
       {
          die('ERROR:Data not correctly submitted');
       }
    ?>

    johnburn
    Moderators
    Moderators

    Gender : Male Number of posts : 755
    Location : Terengganu
    Registration date : 07/03/2009

    Re: tak leh insert value dlm database (PHP MySQL)

    Post by johnburn on Tue Dec 01, 2009 2:58 pm

    $_SESSION['userid'] tu kosong xde pe2. bleh tunjukkn x kt mne ko initialize $_SESSION['userid'] tu? satu lg ape reason die ko nk mskkn user id tu?


    --------------------------------------------

    tahukah kamu saat kamu menangis
    adalah air mata ku yang jatuh berlinang
    tahukah kamu saat kamu tersakiti
    adalah aku yang pertama terluka
    Jangan Klik

    dans kam
    Ahli Baharu
    Ahli Baharu

    Gender : Male Number of posts : 172
    Age : 35
    Location : Wangsa Maju
    Job/hobbies : PHP
    Registration date : 19/02/2009

    Re: tak leh insert value dlm database (PHP MySQL)

    Post by dans kam on Tue Dec 01, 2009 9:32 pm

    kalo ko guna session, form ko kene .php jugak dan kat form ko pun kene letak session_start()..

    jeliey
    Ahli Baharu
    Ahli Baharu

    Number of posts : 26
    Registration date : 01/04/2009

    Re: tak leh insert value dlm database (PHP MySQL)

    Post by jeliey on Thu Dec 03, 2009 3:10 pm

    $_SESSION['userid'] tu kosong xde pe2. bleh tunjukkn x kt mne ko initialize $_SESSION['userid'] tu? satu lg ape reason die ko nk mskkn user id tu?

    $_SESSION['userid'] initialize kat login.php
    start from login.php,sume file aku letak session_start()

    johnburn
    Moderators
    Moderators

    Gender : Male Number of posts : 755
    Location : Terengganu
    Registration date : 07/03/2009

    Re: tak leh insert value dlm database (PHP MySQL)

    Post by johnburn on Thu Dec 03, 2009 3:15 pm

    erm tp session tu dh xde. pelik gak tu
    bleh bg login.php pnye script x?


    --------------------------------------------

    tahukah kamu saat kamu menangis
    adalah air mata ku yang jatuh berlinang
    tahukah kamu saat kamu tersakiti
    adalah aku yang pertama terluka
    Jangan Klik

    dans kam
    Ahli Baharu
    Ahli Baharu

    Gender : Male Number of posts : 172
    Age : 35
    Location : Wangsa Maju
    Job/hobbies : PHP
    Registration date : 19/02/2009

    Re: tak leh insert value dlm database (PHP MySQL)

    Post by dans kam on Thu Dec 03, 2009 5:53 pm

    Cuba bila dah login tu ko 'echo'kan $_SESSION['userid'] tu. Ada value x?

    jeliey
    Ahli Baharu
    Ahli Baharu

    Number of posts : 26
    Registration date : 01/04/2009

    Re: tak leh insert value dlm database (PHP MySQL)

    Post by jeliey on Fri Dec 04, 2009 4:58 pm

    Code:
    <?php
       session_start();
       
       function isAdmin()
       {
          if($_SESSION['username']=='admin')
          {
             header('Location: view.php');
          }
          else
          {
             header('Location: view_user.php');
          }
       }
       
    // Connects to your Database
       mysql_connect("localhost", "root", "") or die(mysql_error());
       mysql_select_db("system") or die(mysql_error());

       //if the login form is submitted
       if (isset($_POST['submit']))
       { // if form has been submitted

          // makes sure they filled it in
          if(!$_POST['username'] | !$_POST['password'])
          {
             die('You did not fill in a required field.');
          }
          
          $check = mysql_query("SELECT * FROM users WHERE username = '".$_POST['username']."'")or die(mysql_error());

          //Gives error if user doesn't exist
          $check2 = mysql_num_rows($check);
          if ($check2 != 0)
          {
             $row = mysql_fetch_array($check);
             $_SESSION['userid'] = $row['userid'];
             
             $_SESSION['username']=$_POST['username'];
             isAdmin();
          }
          else
          {
             die('That user does not exist in our database. <a href=register.html>Click Here to Register</a>');
          }

          while($info = mysql_fetch_array( $check ))
          {
             $_POST['password'] = stripslashes($_POST['password']);
             $info['password'] = stripslashes($info['password']);
             $_POST['password'] = md5($_POST['password']);

             //gives error if the password is wrong
             if ($_POST['password'] != $info['password'])
             {
                die('Incorrect password, please try again.');
             }
             else
             {
                header("Location: view.php");
             }
          }
          
       }
       else
       {
          //if they are not log in
          ?>
          <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
             <table border="0">
                <tr>
                   <td colspan="2"><h1>Login</h1></td>            
                </tr>         
                <tr>
                   <td>Username:</td>
                   <td><input type="text" name="username"></td>            
                </tr>
                <tr>
                   <td>Password:</td>
                   <td><input type="password" name="password"></td>            
                </tr>
                <tr>
                   <td colspan="2" align="right"><input type="submit" name="submit" value="Login"></td>            
                </tr>
             </table>
          </form>
       <?php
       }
    ?>

    johnburn
    Moderators
    Moderators

    Gender : Male Number of posts : 755
    Location : Terengganu
    Registration date : 07/03/2009

    Re: tak leh insert value dlm database (PHP MySQL)

    Post by johnburn on Fri Dec 04, 2009 10:56 pm

    ok gini, skang ni, kl tgk dr code submit.php tu, post data untuk description dh tukar kpd $idesc=$_POST['idesc'];
    pastikan dlm form, name untuk textarea tu idesc.
    Code:
    <textarea name='idesc' rows='15' cols='50'></textarea>

    pastu, kl tgk code submit.php tu, ade kesilapan query. data query tu dh disimpan dalam variable $query then awk pegi query blk data tu:
    Code:
          $sql = "INSERT INTO issues(title,catid,idesc,pid,idate,userid) VALUES ('".$title."',".$catid.",'".$idesc."',".$pid.",'".$idate."',".$userid.")";
          echo $sql;
          $query=mysql_query($sql);
         
          $result=mysql_query($query)or die("ERROR:$query.".mysql_error());
    so tukar code tu jd gini:
    Code:
          $sql = "INSERT INTO issues(title,catid,idesc,pid,idate,userid) VALUES ('".$title."',".$catid.",'".$idesc."',".$pid.",'".$idate."',".$userid.")";
          echo $sql;//untuk check sql btol ke x sblom query ke db
         
          $result=mysql_query($sql)or die("ERROR:$query.".mysql_error());//query sql td ke db
    kl dh xde pe2 error, sy ade beberape bnde nk komen psal sume2 code awk ni. kl ade error lg, gtau blk


    --------------------------------------------

    tahukah kamu saat kamu menangis
    adalah air mata ku yang jatuh berlinang
    tahukah kamu saat kamu tersakiti
    adalah aku yang pertama terluka
    Jangan Klik

    Sponsored content

    Re: tak leh insert value dlm database (PHP MySQL)

    Post by Sponsored content Today at 4:27 am


      Current date/time is Sun Dec 11, 2016 4:27 am