Click here to Skip to main content
15,888,610 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: File Upload Using Query String in PHP Pin
jasonalien3-Sep-14 21:33
jasonalien3-Sep-14 21:33 
GeneralRe: File Upload Using Query String in PHP Pin
Richard MacCutchan3-Sep-14 22:05
mveRichard MacCutchan3-Sep-14 22:05 
AnswerRe: File Upload Using Query String in PHP Pin
Richard Deeming4-Sep-14 1:37
mveRichard Deeming4-Sep-14 1:37 
GeneralRe: File Upload Using Query String in PHP Pin
jasonalien4-Sep-14 2:04
jasonalien4-Sep-14 2:04 
QuestionHow to update a form and submit using jquery and ajax Pin
Member 109499862-Sep-14 6:41
Member 109499862-Sep-14 6:41 
SuggestionRe: How to update a form and submit using jquery and ajax Pin
Kornfeld Eliyahu Peter2-Sep-14 7:12
professionalKornfeld Eliyahu Peter2-Sep-14 7:12 
Questionvb.net web form generates extra blank lines Pin
dcof1-Sep-14 7:31
dcof1-Sep-14 7:31 
Questionmysqli update Pin
Charlie Kirk26-Aug-14 15:32
Charlie Kirk26-Aug-14 15:32 
XML
Hi, The following code selects and displays a record from the "emailtbl" table
as desired except for the the date and it doesn't update the "lastused" (date)
field to the "numbers" table via "lastused.php" include. No error messages. I need help.

<pre lang="PHP"><html><head>
</head>
<BODY>
     <?php
include ("lastused.php");
include ("counter.php");
$id="''";
    $con=mysqli_connect("localhost","root","cookie","homedb");

    // ============== check connection

    if(mysqli_errno($con))
    {echo "Can't Connect to mySQL:".mysqli_connect_error();}
    else
    {echo "</br>";}

// ==========This creates the drop down box using records in the table

       echo "<select name= 'target'>";
    echo '<option value="">'.'---select email account ---'.'</option>';
    $query = mysqli_query($con,"SELECT target FROM emailtbl");
    $query_display = mysqli_query($con,"SELECT * FROM emailtbl");
    while($row=mysqli_fetch_array($query))
    { echo "<option class=highlight value='". $row['target']."'>".$row['target']
    .'</option>';}
    echo '</select>';
    ?>
<input type="submit" name="submit" value="Submit"/>
    </form>
     <?php
        if(isset($_POST['target']))
  {
    $id = ' ';
    $name = $_POST['target'];
    $fetch="SELECT target, username, password, emailused, lastused, purpose, saved FROM emailtbl WHERE target = '$name'";
    $result = mysqli_query($con,$fetch);
    if(!$result)
    {echo "Error:".(mysqli_error($con));}

// =============================== this displays the table

    echo '<table border="1">'.'<tr>'.'<td bgcolor="#FFD47F" align="center">'. 'email menu'. '</td>'.'</tr>';
    echo '<tr>'.'<td>'.'<table border="1">'.'<tr>'.'<td bgcolor="#ccffff">'.'target'.'</td>'.'<td bgcolor="#ccffff">'.'username'.'</td>'.'<td bgcolor="#ccffff">'. 'password' .'</td>'.'<td bgcolor="#ccffff">'. 'emailused'. '</td>'.'<td bgcolor="#FFD47F">'. 'lastused' .'</td>'.'<td bgcolor="#ccffff">'. 'purpose'. '</td>'.'<td bgcolor="#ccffff">'. 'saved' .'</td>'.'</tr>';
//    while( $row = mysqli_fetch_assoc( $result ) )
// while($data = mysqli_fetch_row($fetch))
    while($data=mysqli_fetch_row($result))
    {echo ("<tr><td>$data[0]</td><td>$data[1]</td><td>$data[2]</td><td>$data[3]</td><td>$data[4]</td><td>$data[5]</td><td>$data[6]</td></tr>");}
    echo '</table>'.'</td>'.'</tr>'.'</table>';
  }
    ?>
    </body></html>


lastused.php
PHP
?php
error_reporting(E_ALL);
ini_set('display_errors', true); // set to false for production

if(!empty($_POST['update_lastused']))
 {
    $dbconnect = mysqli_connect('localhost','root','cookie');
    mysqli_select_db($dbconnect, 'homedb') or die( "Unable to select database");

// let prepared statements with bound parameters take care of input sanitation
    $sql = "UPDATE emailtbl SET lastused = NOW() WHERE id = ?";
    $stmt = mysqli_prepare($dbconnect, $sql);

// make sure it worked
    if($stmt == false)
    {throw new Exception("Prepare failed".PHP_EOL.mysqli_error($dbconnect).PHP_EOL.$sql);}
    mysqli_stmt_bind_param($stmt, 'i', $sql);
    $update = mysqli_stmt_execute($stmt);

// ditto
    if($update == false)
    {throw new Exception("Update failed:".PHP_EOL.mysqli_stmt_error($stmt).PHP_EOL.$sql);}
 }
   ?>


AnswerRe: mysqli update Pin
Graham Breach26-Aug-14 22:48
Graham Breach26-Aug-14 22:48 
AnswerRe: mysqli update Pin
Charlie Kirk30-Aug-14 17:47
Charlie Kirk30-Aug-14 17:47 
QuestionSample Mvc 4 Application t Insert data into the database and Bind Them to grid Pin
Member 1103238424-Aug-14 1:19
Member 1103238424-Aug-14 1:19 
AnswerRe: Sample Mvc 4 Application t Insert data into the database and Bind Them to grid Pin
Anurag Gandhi24-Aug-14 7:12
professionalAnurag Gandhi24-Aug-14 7:12 
AnswerRe: Sample Mvc 4 Application t Insert data into the database and Bind Them to grid Pin
Suraj Sahoo | Coding Passion16-Sep-14 19:32
professionalSuraj Sahoo | Coding Passion16-Sep-14 19:32 
QuestionGeneral Web Development Question Pin
Kevin Marois20-Aug-14 5:22
professionalKevin Marois20-Aug-14 5:22 
AnswerRe: General Web Development Question Pin
Anurag Gandhi22-Aug-14 8:59
professionalAnurag Gandhi22-Aug-14 8:59 
GeneralRe: General Web Development Question Pin
Kevin Marois24-Aug-14 7:52
professionalKevin Marois24-Aug-14 7:52 
GeneralRe: General Web Development Question Pin
Anurag Gandhi24-Aug-14 8:07
professionalAnurag Gandhi24-Aug-14 8:07 
GeneralRe: General Web Development Question Pin
Kevin Marois24-Aug-14 8:17
professionalKevin Marois24-Aug-14 8:17 
AnswerRe: General Web Development Question Pin
Richard MacCutchan22-Aug-14 21:14
mveRichard MacCutchan22-Aug-14 21:14 
AnswerRe: General Web Development Question Pin
Wombaticus24-Aug-14 1:22
Wombaticus24-Aug-14 1:22 
AnswerRe: General Web Development Question Pin
uspatel1-Sep-14 1:32
professionaluspatel1-Sep-14 1:32 
AnswerRe: General Web Development Question Pin
Nathan Minier5-Sep-14 3:57
professionalNathan Minier5-Sep-14 3:57 
AnswerRe: General Web Development Question Pin
Dominic Burford15-Sep-14 2:42
professionalDominic Burford15-Sep-14 2:42 
QuestionGoogle search - why does it do this? Pin
#realJSOP20-Aug-14 4:52
mve#realJSOP20-Aug-14 4:52 
AnswerRe: Google search - why does it do this? Pin
Richard Deeming20-Aug-14 5:21
mveRichard Deeming20-Aug-14 5:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.