Jump to content

Search the Community

Showing results for tags 'mysqlphp'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 2 results

  1. Hi people I have a table created like this: -- -- Database: `mydatabase` -- -- -------------------------------------------------------- -- -- Tablestructure for table `table_name` -- CREATE TABLE `table_name` ( `num` int(4) NOT NULL, `fol_num` int(7) DEFAULT NULL, `col3` varchar(30) DEFAULT NULL, `col4` int(1) DEFAULT NULL, `num_nonce` varchar(20) DEFAULT NULL, `col6` varchar(30) DEFAULT NULL, `col7` varchar(15) DEFAULT NULL, `col8` varchar(15) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- I also created a function and the goal of the function is to read the random number from fol_num with a mysql query with WHERE. fol_num should match with the number found and show num_nonce belonging to that record. query: SELECT num_nonce, FROM table_name WHERE fol_num = ? ; function: <?php function my_func() { // global global $fol_num; global $num_nonce; $servername = "localhost"; $username = "myname"; $password = "mypassword"; $dbname = "mydatabase"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } var_dump($fol_num); // select nonce from database table $stmt = $conn->prepare("SELECT num_nonce, FROM table_name WHERE fol_num = ? ;" ) ; $stmt->bind_param('is', $fol_num, $num_nonce); $stmt->execute(); $stmt->bind_result($fol_num, $num_nonce); $stmt->fetch(); var_dump($num_nonce); // var_dump($fol_num2); //$stmt->close(); $conn->close(); } my_func(); ?> I receive errors that sound like: Fatal error: Uncaught Error: Call to a member function bind_param() on boolean in ...... pointing to this line: $stmt->bind_param('is', $fol_num, $num_nonce); what is not good and how to solve it?
  2. I found an online function called GetDays and I slightly modified it to calculate the number of days between a past date and the current time. The function works fine for 1 input, but I have a table full of records and want to use the function to get the total days for each record separatedly. <?php // function GetDays($sStartDate, $sEndDate){ // Firstly, format the provided dates. // This function works best with YYYY-MM-DD // but other date formats will work thanks // to strtotime(). $sStartDate = gmdate("Y-m-d", strtotime($sStartDate)); $sEndDate = gmdate("Y-m-d", strtotime($sEndDate)); // Start the variable off with the start date $aDays[] = $sStartDate; // Set a 'temp' variable, sCurrentDate, with // the start date - before beginning the loop $sCurrentDate = $sStartDate; // While the current date is less than the end date while($sCurrentDate < $sEndDate){ // Add a day to the current date $sCurrentDate = gmdate("Y-m-d", strtotime("+1 day", strtotime($sCurrentDate))); // Add this new day to the aDays array global $aDays; // deze global heb ik zelf toegevoegd en MOET hier staan, iig niet buiten deze conditie global $tot_days; $aDays[] = $sCurrentDate; } $tot_days = count($aDays); $tot_days = $tot_days +1; return $tot_days; } // function ends // // here the records are fetched from the database table while($row = $result->fetch_assoc()){ echo "<center>"; $array = implode(" / " , $row); $sStartDate = $row['created_on']; $sEndDate = date("Y-m-d"); GetDays ($sStartDate, $sEndDate); echo "</center>"; ?> <center> <form action="#" method="post" > <input type="text" name="test" value="<?php echo $array . ' / ' . $sEndDate . ' / ' . $tot_days ; ?>" size="60"/> </center> <?php } // rest of the code to complete the form --> ?>
×
×
  • Create New...