Jump to content
#FlattenTheCurve ×

Frankice

Members
  • Content Count

    17
  • Joined

  • Last visited

Posts posted by Frankice


  1. Just now, Barand said:

    Have you not mastered copy and paste yet?

    
    // database connection config
    $dbHost = 'localhost';
    $dbUser = '';
    $dbPass = '';
    $dbName = '';
    
    mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT);                                                      //   <-- ADD IT HERE   !!!
                                                                                                                           
    $dbConn = mysqli_connect ($dbHost, $dbUser, $dbPass) or die ('MySQL connect failed. ' . mysql_error());
    mysqli_select_db($dbConn,$dbName) or die('Cannot select database. ' . mysqli_error());
    
    function dbQuery($sql)
    {
        $result = mysqli_query($dbConn,$sql) or die(mysql_error());
        
        return $result;
    }

    Here is the error after I correct the connection.

    
    atal error: Uncaught mysqli_sql_exception: Field 'email' doesn't have a default value in /home/psdelive/public_html/admin/add package.php:24 Stack trace: #0 /home/psdelive/public_html/admin/add package.php(24): mysqli_query(Object(mysqli), 'INSERT INTO pac...') #1 {main} thrown in /home/psdelive/public_html/admin/add package.php on line 24

     

     


  2. Just now, Barand said:

    Easiest way is to add this line to your included connection.php

    
    mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT);

    immediately before the line that connects to the database (either with mysqli_connect() or new mysqli()  )

    I understand your point on the hiring aspect.

    Here is my connection Sir,

     

    
    
    <?php
    
    
    // database connection config
    $dbHost = 'localhost';
    $dbUser = '';
    $dbPass = '';
    $dbName = '';
    
    $dbConn = mysqli_connect ($dbHost, $dbUser, $dbPass) or die ('MySQL connect failed. ' . mysql_error());
    mysqli_select_db($dbConn,$dbName) or die('Cannot select database. ' . mysqli_error());
    
    function dbQuery($sql)
    {
    	$result = mysqli_query($dbConn,$sql) or die(mysql_error());
    	
    	return $result;
    }
    
    ?>

     


  3. Please

    Just now, gw1500se said:

    Obviously the query is failing. You need to echo mysqli_error to determine why.

    Please can you add the mysqli_error to my code here

    if (isset($_POST['submit'])){
    $date  = $_POST['date'];
    $location  = $_POST['location'];
    $time = $_POST['time'];
    $track = $_POST['track'];
    
    $activity = $_POST['activity'];
    $details = $_POST['details'];
    
    
    
    {
    		$query = "INSERT INTO package(date,location,time,track_code,activity,details)VALUES('$date','$location','$time','$track','$activity','$details')";
    $check = mysqli_query($dbConn,$query);
    if($check)
    {
        header('location:success_package');
        exit;
    }
    else
    {
        $error = '<div class="alert-warning" style="height:60px;">
        <p style="line-height:40px;">Error in posting</p>
        </div>';
    
    }
    
    
    
    }
    }

     


  4. Just now, gw1500se said:

    You need to figure out why $error is not being set. As a workaround initialize $error to something at the beginning of your code. In any case that has nothing to do with your database not being updated. Which problem are you trying to solve?

    When I submit the form it goes to the $error instead of success and it doesn't update in the database.


  5. Just now, ginerjm said:

    As a newbie you need to learn to focus your post on the parts that are giving you the problem.  Posting a hundred lines of html code is not going to get the attention you need on the PHP code that is the source of your problem.  Limit your posts to the parts you want us to help you with and since this is a PHP forum, all that extraneous html code is a lot of code to wade thru.

    Thank you, I  showed the full part incase is needed my problem is to insert the datas on the database. Is still giving me error Sir.


  6. Thank you sir,

     

    Here is the place I'm having issue.

     

    Quote
    
    if (isset($_POST['submit'])){
    $date  = $_POST['date'];
    $location  = $_POST['location'];
    $time = $_POST['time'];
    $track = $_POST['track'];
    
    $activity = $_POST['activity'];
    $details = $_POST['details'];
    
    
    
    {
    		$query = "INSERT INTO package(date,location,time,track_code,activity,details)VALUES('$date','$location','$time','$track','$activity','$details')";
    $check = mysqli_query($dbConn,$query);
    if($check)
    {
        header('location:success_package');
        exit;
    }
    else
    {
        $error = '<div class="alert-warning" style="height:60px;">
        <p style="line-height:40px;">Error in posting</p>
        </div>';
    
    }
    
    
    
    }
    }

    And at the line 122 when I want to echo the error gives error Notice: Undefined variable: error

     


  7. Just now, gw1500se said:

    I suggest you learn to read. I already told you what is wrong. Did you bother to look at the formatted code you posted and the colors? It is very obvious if you just look. That is the point of the the formatter.

    Okay Sir, I'm still a newbie. I'm trying it out now, so much thanks for your concern. 


  8. Just now, gw1500se said:

    ???

    Aside from the fact you did not answer my questions there are other glaring flaws in your code. Never ever put user data directly into a database. You are wide open to injection attacks. Use prepared statements as validate the data. I am guessing that you are not validating anything on the web page before submitting it and I see nothing that validates your data in your PHP script.

    Thank you sir, for now I'm concerning for the code to work properly like submitting the data to my database. My other file adding user works fine but this file having almost the same code is not submitting just giving me this error. Notice: Undefined variable: error in /home/psdelive/public_html/admin/add package.php on line 118

     

    Sir, I can give you the link to help me look into it.


  9. 35 minutes ago, gw1500se said:

    First please use the code icon (<>) and choose PHP. It makes your code much easier to read. Which is line 118? Did you echo all your variables to make sure they contain what you expect?

    <?php 
    include('../connection.php');
    
    session_start();
    
    
    if (isset($_POST['submit'])){
    $date  = $_POST['date'];
    $location  = $_POST['location'];
    $time = $_POST['time'];
    $track = $_POST['track'];
    
    $activity = $_POST['activity'];
    $details = $_POST['details'];
    
    {
            $query = "INSERT INTO package(date,location,time,track_code,activity,details)VALUES('$date','$location','$time','$track','$activity','$details')";
    $check = mysqli_query($dbConn,$query);
    if($check)
    {
        header('location:success_package');
    }
    else
    {
    $error = '<div class="alert-warning" style="height:60px;">
    
    <p style="line-height:40px;">Error in posting</p>
    </div>';
    
    }
    }
    }
    
    $sele = "SELECT * from details";
    $query = mysqli_query($dbConn,$sele);
    
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    
    <title>Add Package</title>
    
    <link type="text/css" rel="stylesheet" href="bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/css/bootstrap.css" />
    
    <link type="text/css" rel="stylesheet" href="bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/css/bootstrap.min.css" />
    
    <link type="text/css" rel="stylesheet"  href="bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/css/bootstrap-theme.css" />
    
    <link type="text/css" rel="stylesheet" href="bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/css/bootstrap-theme.min.css" />
    
    <script src="bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/js/bootstrap.js"></script>
    
    <script src="bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
    
    <script src="bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/js/npm.js"></script>
    </head>
    
    <style>
    body
    {
        background:#EEE;
    }
    </style>
    
    <body>
    
    <div class="container-fluid" style="background:green; height:70px;">
    
    </div>
    
    
    <div class="container-fluid" style=" min-height:500px;">
    
    <div class="row" style=" min-height:80px;"> 
    
    <div class="col-lg-2" style="background:gray; height:1100px;">
    
    
    <a class="btn btn-success" style="width:100%; margin-top:20px;" href="dashboard">Dashboard</a>
    
    <a class="btn btn-success" style="width:100%; margin-top:20px;" href="add user">Add Users</a>
    
    <a class="btn btn-success" style="width:100%; margin-top:20px;" href="add package">Add Packages</a>
    
    <a class="btn btn-success" style="width:100%; margin-top:20px;" href="all packages">View Packages</a>
    
    <a class="btn btn-success" style="width:100%; margin-top:20px;" href="send">Send Mail</a>
    
    <a class="btn btn-success" style="width:100%; margin-top:20px;" href="logout">Logout</a>
    
    </div>
    
    
    <div class="col-lg-10" style="background:#EEE; height:670px;">
    
    
    <?php
    
    echo $error;\\this is the line I'm having issue with 
    ?>
    
    
    <div class="container" style=" margin-top:60px;background:white; box-shadow:5px 5px 5px gray; width:60%;">
    
    
    <form class="" action="add package.php" method="post">
    
    
    <div class="form-group">
    <label>Track Number</label>
    <select class="form-control" name="track">
    <?php
    while($row = mysqli_fetch_array($query))
    {
    
    ?>
    
    <option><?php echo $row['track_code']; ?></option>
    
    <?php
    }
    ?>
    </select>
    
    </div>
    
    <div class="form-group">
    <label>Date</label>
    <input type="text" class="form-control" name="date" style="height:40px;" placeholder="Date" />
    </div>
    
    
    <div class="form-group">
    <label>Time</label>
    <input type="text" class="form-control" name="time" style="height:40px;" placeholder="Time" />
    </div>
    
    
    <div class="form-group">
    <label>Activity</label>
    <input type="text" class="form-control" name="activity" style="height:40px;" placeholder="Activity" />
    </div>
    
    
    <div class="form-group">
    <label>Location</label>
    <input type="text" class="form-control" name="location" style="height:40px;"  placeholder="Location" />
    </div>
    
    
    <div class="form-group">
    <label>Details</label>
    <input type="text" class="form-control" name="details" style="height:40px;"  placeholder="Details" />
    </div>
    
    
    <div class="container" style=" width:30%; margin-bottom:20px;">
    <input class="btn btn-success" style="width:100%;" type="submit" name="submit" value="Save" />
    </div>
    
    </form>
    
    
    </div>
    
    
    </div>
    
    
    </div>
    
    
    </div>
    
    
    </body>
    
    </html>

    I'm facing database submission issues, please can someone with a good heart help me. Below is my code I don't know what I did wrong it won't submit mydata to the database it gives me error.   Notice: Undefined variable: error in /home/psdelive/public_html/admin/add package.php on line 118

     

     


  10. I'm facing database submission issues, please can someone with a good heart help me. Below is my code I don't know what I did wrong it won't submit mydata to the database it gives me error.   Notice: Undefined variable: error in /home/psdelive/public_html/admin/add package.php on line 118

     

    <?php 
    include('../connection.php');

    session_start();


    if (isset($_POST['submit'])){
    $date  = $_POST['date'];
    $location  = $_POST['location'];
    $time = $_POST['time'];
    $track = $_POST['track'];

    $activity = $_POST['activity'];
    $details = $_POST['details'];

    {
            $query = "INSERT INTO package(date,location,time,track_code,activity,details)VALUES('$date','$location','$time','$track','$activity','$details')";
    $check = mysqli_query($dbConn,$query);
    if($check)
    {
        header('location:success_package');
    }
    else
    {
    $error = '<div class="alert-warning" style="height:60px;">

    <p style="line-height:40px;">Error in posting</p>
    </div>';

    }
    }
    }

    $sele = "SELECT * from details";
    $query = mysqli_query($dbConn,$sele);

    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <title>Add Package</title>

    <link type="text/css" rel="stylesheet" href="bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/css/bootstrap.css" />

    <link type="text/css" rel="stylesheet" href="bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/css/bootstrap.min.css" />

    <link type="text/css" rel="stylesheet"  href="bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/css/bootstrap-theme.css" />

    <link type="text/css" rel="stylesheet" href="bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/css/bootstrap-theme.min.css" />

    <script src="bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/js/bootstrap.js"></script>

    <script src="bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>

    <script src="bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/js/npm.js"></script>
    </head>

    <style>
    body
    {
        background:#EEE;
    }
    </style>

    <body>

    <div class="container-fluid" style="background:green; height:70px;">

    </div>


    <div class="container-fluid" style=" min-height:500px;">

    <div class="row" style=" min-height:80px;"> 

    <div class="col-lg-2" style="background:gray; height:1100px;">


    <a class="btn btn-success" style="width:100%; margin-top:20px;" href="dashboard">Dashboard</a>

    <a class="btn btn-success" style="width:100%; margin-top:20px;" href="add user">Add Users</a>

    <a class="btn btn-success" style="width:100%; margin-top:20px;" href="add package">Add Packages</a>

    <a class="btn btn-success" style="width:100%; margin-top:20px;" href="all packages">View Packages</a>

    <a class="btn btn-success" style="width:100%; margin-top:20px;" href="send">Send Mail</a>

    <a class="btn btn-success" style="width:100%; margin-top:20px;" href="logout">Logout</a>

    </div>


    <div class="col-lg-10" style="background:#EEE; height:670px;">


    <?php

    echo $error;
    ?>


    <div class="container" style=" margin-top:60px;background:white; box-shadow:5px 5px 5px gray; width:60%;">


    <form class="" action="add package.php" method="post">


    <div class="form-group">
    <label>Track Number</label>
    <select class="form-control" name="track">
    <?php
    while($row = mysqli_fetch_array($query))
    {

    ?>

    <option><?php echo $row['track_code']; ?></option>

    <?php
    }
    ?>
    </select>

    </div>

    <div class="form-group">
    <label>Date</label>
    <input type="text" class="form-control" name="date" style="height:40px;" placeholder="Date" />
    </div>


    <div class="form-group">
    <label>Time</label>
    <input type="text" class="form-control" name="time" style="height:40px;" placeholder="Time" />
    </div>


    <div class="form-group">
    <label>Activity</label>
    <input type="text" class="form-control" name="activity" style="height:40px;" placeholder="Activity" />
    </div>


    <div class="form-group">
    <label>Location</label>
    <input type="text" class="form-control" name="location" style="height:40px;"  placeholder="Location" />
    </div>


    <div class="form-group">
    <label>Details</label>
    <input type="text" class="form-control" name="details" style="height:40px;"  placeholder="Details" />
    </div>


    <div class="container" style=" width:30%; margin-bottom:20px;">
    <input class="btn btn-success" style="width:100%;" type="submit" name="submit" value="Save" />
    </div>

    </form>


    </div>


    </div>


    </div>


    </div>


    </body>

    </html>

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.