Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. That is not the code that caused the last post to be incorrect. the word 'echo' is still in php mode here but in the last the only way it would have shown would be if you turned off php mode. BTW - as my normal practice I NEVER exit php mode in my scripts. I begin with the first line of every script as <?php and never use the ?> tag EVER. To output my js or my html or my css I use the Heredocs construct. Read up on it in the manual. Either that or a simple echo for a small amount of non-PHP code. In your last you left and re-entered and then left at the end all for no reason other than lack of knowledge.
  2. When you have an issue with code it helps TREMENDOUSLY if you post the code From the look of it I think you altered my code by exiting php mode when there was no php tag in the code I gave you. I told you it worked EXACTLY as written.
  3. The code that I provided can be used EXACTLY AS WRITTEN. The "echo" is the beginning of a long statement that writes the html to the client. Follow the double quotes. So it seems that your phpadmin is working and showing you table names. But you didn't tell me if your 'missing' tablename showed up when you showed the database names. So - is the problem here that you script cannot connect to the db server?
  4. I don't know why you are repeating your posts. I fixed some code from your past post and gave it to you. I don't know why you are using the htmlentities but you were using it wrong and I changed that. If you can ask a direct pointed question about some one thing that is giving you an error, then please do that because this is a long conversation that is going nowhere
  5. So is your 'missing' database name there???? And what are the "default" ones? My host has only one 'default' db named "information_schema". I am curious what other default ones you have.
  6. If you have phpadmin then simplyy run the query I gave you right there. Simply type in 'show databases' in phpadmin's query window and let's see if your 'missing' database name is present.
  7. I am not following you. Can you make a connection or not? And if you can make that connection can you run the simple query I asked for to tell me what database names you DO HAVE? A simple yes or no could be all you have to say here, and not repeat my whole post
  8. So since you did not do as I asked I'm guessing that the issue is not a 'missing dbname' but rather your db connection. I thought it was something else.
  9. Have you run some sql to list out the databases that ARE defined? Is this the only database name that you are missing? Try "Show Databases".
  10. Some corrections to the entities code and removal of the horrible use of those single quotes to wrap your values. Don't know why you didn't see them as bad coding. $fname = htmlentities($_POST['fname'],ENT_QUOTES); $sname = htmlentities($_POST['sname'],ENT_QUOTES); $email = htmlentities($_POST['email'],ENT_QUOTES); echo " <form method='post'> <label> <b>First Name:</b> <input type='text' name='fname' size='20' maxlength='40' value='$fname'> </label> <br> <label> <b>Surname:</b> <input type='text' name='sname' size='20' maxlength='40' value='$sname'> </label> <br> <label> <b>Email:</b> <input type='text' name='email' size='20' maxlength='40' value='$email'> </label> <br> <br> <input type='submit' name='btn' value='Submit'> </form> "; And the addition of a name attribute to your submit. Now - can you see what you have to use to 'grab' the input values? Don't know why you are using the htmlentities but there must be a reason.
  11. Post the entire contents of html form. No php, no JS, just the html that begins with the <form> tag and ends with the </form> tag.
  12. The connection that Barand is asking about is you seem to have trouble understanding why the errors that you are getting on your POST vars seem haphazard to you. When you get an error saying undefined index that means you are using an index that doesn't exist. (An index in this case is the piece in the square brackets of an array variable name.) In this case that array is the $_POST array that is generated from your form's POST method. Furthermore it indicates that you do not have any element declared in your form with that name= attribute. Previously told us that you see that you changed the form name entry to first_name from fname but you are still having trouble why you are getting errors when you try and reference fname. For a quick analysis of everything declared in your $_POST simply do an echo like this at the top of your script: echo "POST array is<pre>",print_r($_POST,true),"</pre>"; exit(); This will show you a list of all the indices defined by your form if you type it into your script correctly. From there you can go modify your code to use the correct names. BTW - as Barand told you do NOT use ^NOTICE when you make your error settings. IMHO you should always use "error_reporting(E_ALL);"
  13. This is not yet an OOP thingie. It is a simple programming thingie. If you Want to use OOP, fine, but first put some code together to show us what you are having problems with. That will answer the question whether it is your algorithm or you knowledge of using OO
  14. Did some clean up of your code to get a better picture. And still don't see it $sql = "SELECT * FROM studentrequest"; // DON'T USE * $result = mysqli_query($conn,$sql); if($result) { while($row = mysqli_fetch_assoc($result)) { $srequestid = $row['studentrequestid']; $studentid = $row['studentID']; $studentname = $row['studentName']; $roomnumber = $row['roomNumber']; $instructor = $row['instructor']; $dateuse = $row['dateUsed']; $ts = $row['timeStart']; $te = $row['timeEnd']; echo "<tr> <th scope='row'>$srequestid</th> <td>$studentid</td> <td>$studentname</td> <td>$roomnumber</td> <td>'.$instructor.'</td> <td>'.$dateuse.'</td> <td>'.$ts.'</td> <td>'.$te.'</td> <td> <button type='button' class='btn btn-outline-success' data-toggle='modal' data-target='#'> Confirm </a> </button> <div class='modal fade' id='confirm' tabindex='-1' role='dialog' aria-labelledby='comfirms' aria-hidden='true'> <div class='modal-dialog' role='document'> <div class='modal-content'> <div class='modal-header'> <h5 class='modal-title' id='confirms'>Alert!</h5> <button type='button' class='close' data-dismiss='modal' aria-label='Close'> <span aria-hidden='true'>&times;</span> </button> </div> <div class='modal-body'> Are you sure you want to confirm this? <br><br> <h3>Details</h3> Name: $studentname <br> Room number: $roomnumber <br> Date use: $dateuse <br> Time start: $ts <br> Time end: $te <br> </div> You need: NEED A CLOSING BRACE FOR YOUR ROW PROCESSING NEED SOME CLOSING DIV TAGS NEED AN ENDING ROW TAG and an ending quote for all the html you have echoed. NEED TO MOVE THAT TH TAG TO ITS OWN ROW NEED TO CHANGE THE BUTTON TAG TO EITHER USE SOME JS CODE OR TO DO A SUBMIT AND IF IT'S TO BE A SUBMIT YOU NEED A FORM CREATED.
  15. modal? I see a sample of some output and a long stretch of code that doesn't do anything other than produce some html table output. Not well done either - a row with one heading element combined with data items is not proper syntax and I actually wonder what it would produce. And I see a button tag. What does that button actually do? It's not a submit and it doesn't trigger any JS so I'm lost. And if it were a submit, there is no form to tell it where to go.
  16. .... without seeing your code. Hint, hint...
  17. I would wonder about what I was doing if I had a task that took 20 seconds of execution time.... Are you by any chance running queries that process only one record at a time and doing a lot of them? That's not good. Or are you processing a data collection in a loop that executes multiple times to do something for you? 20 seconds is a huge amount of time in the computer processing world. Unless you have a couple hundred thousand records that you go thru I think there is something wrong. And no you cannot run a cron job that converses with a client/user. Cron jobs are run as a completely isolated task by the server with no concurrent contact with anything else. As for a 'hosting panel' and a cron job - again - the two do not converse. The cron job runs when it is scheduled to do so and you working thru that panel or any other such as phpadmin will not interfere with the cron job not communicate with it.
  18. I am not familiar with the new JS code you are showing so I'll skip that, but you posted php code has some issues. (in php mode) require_once 'assets/config/config.php'; require_once "vendor/autoload.php"; use PhotoTech\CMS; use PhotoTech\Pagination_New as Pagination; $cat = []; /* Makes it so we don't have to decode the json coming from javascript */ header('Content-type: application/json'); /* * The below must be used in order for the json to be decoded properly. */ try { $cat = json_decode(file_get_contents('php://input'), true, 512, JSON_THROW_ON_ERROR); } catch (JsonException $e) // LINE MISSING SOMETHING { } if ($cat['category'] === $_SESSION['category'] && isset($_SESSION['category'])) { $_SESSION['current_page'] + 1; // WHAT IS THIS LINE DOING? } elseif (!isset($cat['category'])) { $_SESSION['category'] = $cat['category']; $_SESSION['current_page'] = 1; } else { $_SESSION['category'] = $cat['category']; $_SESSION['current_page'] = 1; } $per_page = 12; // Total number of records to be displayed: $total_count = CMS::countAllPage('blog', $_SESSION['category']); // Total Records in the db table: /* Send the 3 variables to the Pagination class to be processed */ $pagination = new Pagination($_SESSION['current_page'], $per_page, $total_count); /* Grab the offset (page) location from using the offset method */ $offset = $pagination->offset(); /* * Grab the data from the CMS class method *static* * and put the data into an array variable. */ $cms = CMS::page($per_page, $offset, 'blog', $_SESSION['category']); output($cms); //********************************** function output($output): void { http_response_code(200); try { echo json_encode($output, JSON_THROW_ON_ERROR); } catch (JsonException) // LINE MISSING A COUPLE OF SOMETHINGS { } } You s/b getting some error messages from my noted spots.
  19. NOt sure I follow what you are wishing to do. Perhaps you would like a task that runs at a certain time each day or hour that gathers some data from previous actions that have happened and updates a db with that info. If that is what you are saying have you thought about setting up a cron job?
  20. You say that errors are on, but we can't see the code for that so .... And you say the line 69 is your problem. How about telling us what line that is? And showing the error handling lines? You also do not need the braces around those variables in your query. More importantly though is that you s/b using prepared query statements to avoid hackers providing invalid inputs to your database.
  21. I"d like to see your error message since the problem is NOT with the echo. The if statement is something you should do whenever you do something that relies on a proper response. Such as a query. Or the opening of a db connection. Or the opening of an external file to be read. Things you want to be sure that they actually happen. And I know what your error is, but just want to see how you mis-interpreted the message.
  22. I would think that if this value is promised to be unique all over the world that the company using and relying on them would be the ONLY place that one that fits could be created. Not you.
  23. Look at it like this: // process the data now $sql = "INSERT INTO senior_dat(fname,lname,email) VALUES (:fname, :lname, :email)"; $stmt = $pdo->prepare($sql); $parms = array( 'fname'=>$fname, 'lname'=>$lname, 'email'=>$email ); if (!$stmt->execute($parms) {
  24. You posted these lines of code once - use them as an example // process the data now $sql = "INSERT INTO senior_dat(fname,lname,email) VALUES (:fname, :lname, :email)"; $stmt = $pdo->prepare($sql); if (!$stmt->execute(['fname'=>$fname, 'lname'=>$lname,'email'=>$email])) Note how the Array is defined inside a set of brackets and then the arguments to the Execute are defined inside of parentheses. Your last post looks nothing like this.
  25. How does the loop you started with the call to proc() get stopped?
×
×
  • 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.