Search found 90 matches

by simonbrahan
Sun Feb 21, 2021 8:41 am
Forum: PHP coding => General
Topic: Help with login sending to admin panel after validation not working
Replies: 2
Views: 48

Re: Help with login sending to admin panel after validation not working

You can't redirect after starting to output markup, since the redirect is a header and these must come before the body of the response. You should extract your logic out of the middle of your html into a section at the top of your script so it runs before you output anything. This should have thrown...
by simonbrahan
Sun Feb 21, 2021 6:19 am
Forum: PEAR and PECL
Topic: Problem installing mysql_xdevapi on MacOS
Replies: 2
Views: 70

Re: Problem installing mysql_xdevapi on MacOS

Have you tried searching your system for the file any.h?
by simonbrahan
Thu Feb 18, 2021 8:37 am
Forum: PHP coding => General
Topic: Simple Query Question
Replies: 1
Views: 42

Re: Simple Query Question

Try checking to see if your query produced an error. $result = mysqli_query($conn, $sql); // Add this line echo mysqli_error($conn); This function call will print out the last error produced by your query, if any. The mysqli extension can be quite unfriendly here; it can take some digging to see whe...
by simonbrahan
Wed Feb 17, 2021 1:29 am
Forum: PHP Scripts
Topic: mpdf cann't load on real host at $mpdf = new \Mpdf\Mpdf();
Replies: 1
Views: 63

Re: mpdf cann't load on real host at $mpdf = new \Mpdf\Mpdf();

You need to turn on errors so you can see what's actually failing. The first section in my article will show you how to do that. That will point you in the right direction, or allow you to show us some more information and let us help you.
by simonbrahan
Tue Feb 16, 2021 7:01 am
Forum: PHP coding => General
Topic: Check specific MySQL value and print/delete recursively
Replies: 2
Views: 82

Re: Check specific MySQL value and print/delete recursively

PHP runs entirely on the server; it can't tell the browser to clear old content like you want. You'd be better doing this in javascript; the only problem there would be representing your data source but that's an easier problem to solve.
by simonbrahan
Sun Feb 14, 2021 6:38 am
Forum: PHP Scripts
Topic: HTTPS with php session in different page
Replies: 3
Views: 349

Re: HTTPS with php session in different page

Are both pages being loaded over https? This can cause problems depending on your PHP configuration.
by simonbrahan
Sat Feb 13, 2021 7:22 am
Forum: PHP coding => General
Topic: PHP mysql with jquery mobile only get last record
Replies: 2
Views: 164

Re: PHP mysql with jquery mobile only get last record

$('#existingListview').empty(); I'm not 100% sure what you're trying to do, but this line will empty your list before adding its record. This means only the last record is left. When doing things like this, I find a good approach is to focus on one part at a time; first you get your data and make s...
by simonbrahan
Thu Feb 11, 2021 4:42 am
Forum: PHP Scripts
Topic: Write a function.
Replies: 3
Views: 195

Re: Write a function.

Your other two questions were specific enough to just need a single trick to solve; this one is a lot more open ended though. If you're just getting started you might want to look at something simpler.
by simonbrahan
Thu Feb 11, 2021 2:45 am
Forum: HTML Basics
Topic: CSS Styles for HTML element
Replies: 2
Views: 203

Re: CSS Styles for HTML element

That's pretty much it. You can use javascript to mess with styles as well, but all you're doing there is manipulating style attributes.
by simonbrahan
Thu Feb 11, 2021 12:40 am
Forum: JavaScript
Topic: Links in JS
Replies: 1
Views: 191

Re: Links in JS

Is there any reason you can't just use proper <A> link elements? These will work much more predictably for users with screen readers or out of date devices.
by simonbrahan
Thu Feb 11, 2021 12:01 am
Forum: mySQL & php coding
Topic: I need to create a query to the database
Replies: 2
Views: 154

Re: I need to create a query to the database

The children list is the unusual part of this query. The MySQL function GROUP_CONCAT can help you here. GROUP_CONCAT will concatentate a column's values by your query's GROUP_BY clause, giving you the result you want. To incorporate this part into your overall result, you need to treat it as a separ...
by simonbrahan
Wed Feb 10, 2021 3:01 am
Forum: PHP Scripts
Topic: Search Category.
Replies: 2
Views: 150

Re: Search Category.

This is a recursive problem; your structure can contain itself, so your code has to occasionally treat a small chunk of the data as a whole structure again. You code must do the following: Look at each category in turn. If the ID matches, return the name there. If the category has children, search t...
by simonbrahan
Tue Feb 09, 2021 5:52 am
Forum: PHP coding => General
Topic: How to migrate this code to php 7
Replies: 3
Views: 216

Re: How to migrate this code to php 7

You need to update your database connection to use mysqli or PDO; PDO is usually recommended.
by simonbrahan
Sun Feb 07, 2021 10:22 am
Forum: Your Scripts
Topic: How to install and use PhpSanitization
Replies: 2
Views: 220

Re: How to install and use PhpSanitization

The documentation you've put together is nice. However, a lot of this code is just wrapping built in PHP functions; those bits are kinda useless. You also attempt to provide escaping functionality for database queries; that's dangerous. PHP's database libraries have built in methods for preparing qu...
by simonbrahan
Sun Feb 07, 2021 10:14 am
Forum: PHP coding => General
Topic: Call another php page on web server
Replies: 6
Views: 501

Re: Call another php page on web server

Is there any reason you can't run the other script and *then* return the success message? Is it far too slow for example?

It is possible to have PHP start other scripts and then respond before they complete, but it's complicated and requires other software.
by simonbrahan
Sun Feb 07, 2021 10:11 am
Forum: PHP coding => Images
Topic: Move on scroll.
Replies: 2
Views: 230

Re: Move on scroll.

PHP runs on the server rather than in the browser; you can't do what you want with PHP.

You can do it with Javascript and CSS though; this tutorial show something similar with rotation.
by simonbrahan
Sun Feb 07, 2021 10:09 am
Forum: PHP Installation
Topic: Installing php 8 standalone on rhel just for command line
Replies: 1
Views: 186

Re: Installing php 8 standalone on rhel just for command line

Just use:

Code: Select all

sudo dnf install php php-cli
That will install the interpreter and the CLI, but won't give you the apache / nginx stuff.
by simonbrahan
Sun Feb 07, 2021 10:06 am
Forum: PHP General
Topic: Opening a "terminal window" from php
Replies: 1
Views: 173

Re: Opening a "terminal window" from php

PHP runs on your web server; any animation you display - your progress bar in this case - has to run on the user's web browser. This makes your requirement pretty complicated. You need an endpoint on your server which the user can call which means "start the process". Call this "start.php". "start.p...
by simonbrahan
Wed Feb 03, 2021 2:42 am
Forum: PHP coding => General
Topic: Call another php page on web server
Replies: 6
Views: 501

Re: Call another php page on web server

What does the other page (eg, load101.php) do?
by simonbrahan
Tue Feb 02, 2021 4:27 am
Forum: PHP coding => General
Topic: Exception problem
Replies: 5
Views: 306

Re: Exception problem

With regards to "what kind of exception could be thrown?", that depends on the implementation of the db class being used. For example a correctly configured PDO instance would throw errors if the SQL syntax was invalid, which is possible if the input variables were wrong. It would also throw an exce...
by simonbrahan
Tue Feb 02, 2021 12:37 am
Forum: PHP coding => General
Topic: Exception problem
Replies: 5
Views: 306

Re: Exception problem

As hyper said; trying to understand this function would be a waste of your time...

Exceptions aren't supposed to be used like that - you don't return them, you throw them. Database queries aren't supposed to be run like that - there's no escaping to ensure the query is safe.
by simonbrahan
Fri Jan 29, 2021 12:19 am
Forum: PHP coding => General
Topic: How to convert JSON data inside PHP variable into readable format in table
Replies: 1
Views: 159

Re: How to convert JSON data inside PHP variable into readable format in table

The function json_decode can convert the JSON into a PHP object or array. You can then loop over this structure to print out the data in any way you see fit. Without seeing you data we can't be sure what will be required, but this is a simple example: <?php // This will be different for your request...
by simonbrahan
Wed Jan 27, 2021 1:11 am
Forum: PHP coding => General
Topic: How to sort a mult-dimensional array?
Replies: 4
Views: 254

Re: How to sort a mult-dimensional array?

The array you've pasted isn't valid PHP, and isn't the output of any PHP debug function I know. It looks kinda like you've got an array of single arrays, containing objects, but if I'm wrong then any further explanation I give you won't work. What do you get if you use: var_dump($services); to outpu...
by simonbrahan
Tue Jan 26, 2021 11:04 am
Forum: PHP coding => General
Topic: How to sort a mult-dimensional array?
Replies: 4
Views: 254

Re: How to sort a mult-dimensional array?

You want the built in function usort . This function accepts a function you define, and uses that function to compare each item in your array when sorting. Your array notation is a bit wild so I can't tell you precisely how to use it in your case; if you struggle, reply with a `var_dump` of your arr...