Page 2 of 2

Re: Missing mysql Insert Column Entry

Posted: Thu Jul 30, 2009 3:47 pm
by tobimichigan
jackpf wrote:Try putting

Code: Select all

var_dump($session); die();
just before the query.

Also try inserting a number. As in 10 or something, and see if that works.

Also, this line "mt_srand((double)microtime())*1000000;" is completely useless. You're not assigning it to anything.
Sir Jack, I tried as u directed but I got this output

string(0) ""

Here's my modified code:

Code: Select all

 
<?php
include("cn.php");
 
session_start();
 
//mt_srand((double)microtime())*1000000;
$session=mt_srand();//create uniqiue sessionid
 
$date= addslashes($_POST['date']);  
$department = addslashes($_POST['department']);
$essenco=addslashes($_POST['essenco']);
$loanint =addslashes($_POST['loanint']);
$loanrepaid =addslashes($_POST['loanrepaid']);
$month=addslashes($_POST['month']);
$name=addslashes($_POST['name']);
$outloanbal=addslashes($_POST['outloanbal']);
$pfno=addslashes($_POST['pfno']);
$savings=addslashes($_POST['savings']);
$session=addslashes($_POST['session']);
$shares=addslashes($_POST['shares']);
$Year=addslashes($_POST['Year']);       
            
var_dump($session); die();
$sql= "Insert into yearly_reports(date, department,essenco,loanint,loanrepaid,month,name,outloanbal,pfno,savings,session,shares,Year) values(SYSDATE(),'$department','$essenco','$loanint','$loanrepaid','$month','$name','$outloanbal','$pfno','$savings','$session','$shares','$Year')" or die .mysql_error();  
 
//$result=mysql_query($sql) or die .mysql_error();                                  
if (!mysql_query($sql))
 {
  die('Error: ' . mysql_error()."  SQL: ".$sql);
  }
echo ("1 record added");
?>
                                 
                                                         
 
<html>
<body>
 
</body>
</html>
This returns "string(0) "" "
Sir Jack, is there something I'm missing?

Re: Missing mysql Insert Column Entry

Posted: Thu Jul 30, 2009 4:05 pm
by jackpf
I just noticed that you also have $session = $_POST['session']. Remove that.

Re: Missing mysql Insert Column Entry

Posted: Mon Aug 03, 2009 4:08 am
by tobimichigan

Code: Select all

 
<?php
include("cn.php");
 
session_start();
 
//mt_srand((double)microtime())*1000000;
$session=mt_srand((double)microtime())*1000000;//create uniqiue sessionid
 
$bankdeposits=addslashes($_POST['bankdeposits']);
$date= addslashes($_POST['date']);  
$department = addslashes($_POST['department']);
$essenco=addslashes($_POST['essenco']);
$loanint =addslashes($_POST['loanint']);
$loanrepaid =addslashes($_POST['loanrepaid']);
$month=addslashes($_POST['month']);
$name=addslashes($_POST['name']);
$outloanbal=addslashes($_POST['outloanbal']);
$pfno=addslashes($_POST['pfno']);
$savings=addslashes($_POST['savings']);
//$session=addslashes($_POST['session']);
$shares=addslashes($_POST['shares']);
$Year=addslashes($_POST['Year']);       
            
//var_dump($session); die();
$sql= "Insert into yearly_reports(bankdeposits,date, department,essenco,loanint,loanrepaid,month,name,outloanbal,pfno,savings,session,shares,Year) values($bankdeposits,SYSDATE(),'$department','$essenco','$loanint','$loanrepaid','$month','$name','$outloanbal','$pfno','$savings','$session','$shares','$Year')" or die .mysql_error();  
 
//$result=mysql_query($sql) or die .mysql_error();                                  
if (!mysql_query($sql))
 {
  die('Error: ' . mysql_error()."  SQL: ".$sql);
  }
echo ("1 record added");
?>
                                 
                                                         
 
<html>
<body>
 
</body>
</html>
 
Sir Jack, its still returning 0 any other ideas?

Re: Missing mysql Insert Column Entry

Posted: Mon Aug 03, 2009 7:39 am
by jackpf
Aha, I didn't know mt_srand() was just a seed generator - I thought it was just a better version of mt_rand().

After reading up on the function, I found that you need to use mt_srand() to seed mt_rand().

You were right the first time, sorry ^^

Try this:

Code: Select all

mt_srand((double)microtime()*1000000);
$session=mt_rand();//create uniqiue sessionid
You learn something new every day (apparently) :D