Search found 904 matches

by hyper
Mon Jan 20, 2020 1:27 pm
Forum: PHP coding => General
Topic: loading a text file from php into a web page
Replies: 1
Views: 51

Re: loading a text file from php into a web page

It depends on what is in the test.php file, if it has quotation marks or php variables, it might screw up the JavaScript, have a look at the error console for errors. You don't need to use quotation marks in PHP when using echo: echo $TOTAL_TEXT; is fine since you are not outputting literals, also n...
by hyper
Wed Jan 15, 2020 11:01 am
Forum: PHP coding => General
Topic: How does the include command work?
Replies: 1
Views: 85

Re: How does the include command work?

Include does just that , it includes a file in exactly that place: file1.php <?php echo 'file1.php'; file2.php <?php echo 'file2.php'; runthis.php <?php include 'file1.php'; include 'file2.php'; PHP creates this to parse: echo 'file1.php'; echo 'file2.php'; Includes are included at the that point, ...
by hyper
Tue Jan 14, 2020 8:45 am
Forum: PHP coding => General
Topic: Assigning an object to a var then overwriting that object with new
Replies: 4
Views: 125

Re: Assigning an object to a var then overwriting that object with new

PHP 5 change log covers PHP 5.0.0 to PHP 5.6.40

As specified, it depends which version you are using and if you intend to update it.
by hyper
Sun Jan 12, 2020 5:29 am
Forum: mySQL & php coding
Topic: PHP/MySQL UPDATE not working for second table
Replies: 1
Views: 67

Re: PHP/MySQL UPDATE not working for second table

There are a few issues with your code, you must never trust user supplied data, MySQLi has a method for preparing queries which help protect your data, I've re-written some of your script to update it, but you would be better using PDO: <?php /*Do not trust user input, it is dangerous, i.e. values s...
by hyper
Sat Jan 11, 2020 10:30 am
Forum: PHP coding => Mail
Topic: PHP rename file after it has been attached with date command
Replies: 4
Views: 96

Re: PHP rename file after it has been attached with date command

my code works now
Pleased to be of help, well done!
by hyper
Sat Jan 11, 2020 1:50 am
Forum: PHP coding => Mail
Topic: PHP rename file after it has been attached with date command
Replies: 4
Views: 96

Re: PHP rename file after it has been attached with date command

If you are using a date stamp in several places, create a variable with it otherwise you run the risk of it changing:

Code: Select all

$date_stamp = date('YmdHis');
file_put_contents(ABSPATH . $date_stamp . ".txt", $output);
by hyper
Fri Jan 10, 2020 12:03 pm
Forum: PHP coding => General
Topic: Assigning an object to a var then overwriting that object with new
Replies: 4
Views: 125

Re: Assigning an object to a var then overwriting that object with new

It will depend on which version of PHP you are using, how the class has been defined and then if you intend to update to a more recent version (which may or may not alter its behaviour). Unfortunately, you will have to test, test and test again to make sure that you are getting the behaviour that yo...
by hyper
Mon Jan 06, 2020 12:28 pm
Forum: PHP coding => General
Topic: Conditional if block not having effect on my code in php
Replies: 1
Views: 96

Re: Conditional if block not having effect on my code in php

The code that you have posted will not execute. Turn on display_errors in your php.ini file while you are developing so that you can see where the PHP errors are occurring. When posting code, use the </> code button and format it: if ($_POST) { date_default_timezone_set('Africa/Lagos'); $date = date...
by hyper
Sat Jan 04, 2020 8:49 am
Forum: PHP coding => General
Topic: php json_encode() produces parse errors
Replies: 5
Views: 161

Re: php json_encode() produces parse errors

What is the difference in the code you used before?
by hyper
Sat Jan 04, 2020 4:07 am
Forum: PHP coding => General
Topic: php json_encode() produces parse errors
Replies: 5
Views: 161

Re: php json_encode() produces parse errors

I have used basically this same code before without this problem.
What is different between the previously used code and this?
php json_encode() produces parse errors
What errors are you getting?
by hyper
Sat Jan 04, 2020 3:48 am
Forum: PHP coding => Images
Topic: Intermittent loading of Php images
Replies: 1
Views: 78

Re: Intermittent loading of Php images

I haven't had issues with such things so can't really help, however, the guy that runs the CutCodeDown forum is really good with configurations if no one else is able to help you.
by hyper
Thu Jan 02, 2020 11:31 am
Forum: PHP coding => General
Topic: associative array keys to indexed array?
Replies: 4
Views: 128

Re: associative array keys to indexed array?

As said in my last post, I don't entirely understand what you are asking, your code is completely out of context and lacks a lot of detail. If $$coSpeciesNamePattern is your main array that you want to get the keys from, then that is what you need to use: $pcommon = array_keys($coSpeciesNamePattern)...
by hyper
Thu Jan 02, 2020 9:25 am
Forum: PHP coding => General
Topic: associative array keys to indexed array?
Replies: 4
Views: 128

Re: associative array keys to indexed array?

I'm not entirely sure that I understand what you are asking, however, thinking laterally, array_keys may be what you are looking for.
by hyper
Thu Jan 02, 2020 9:19 am
Forum: PHP General
Topic: Session Variables Not Working
Replies: 19
Views: 227

Re: Session Variables Not Working

I thought you had a local installation. In that case, you need to contact your provider to enable PHP; that's the first time I've heard of it though??
by hyper
Thu Jan 02, 2020 8:30 am
Forum: PHP General
Topic: Session Variables Not Working
Replies: 19
Views: 227

Re: Session Variables Not Working

What makes you say that the file is executing?

Are you typing:
in your browser address bar?

Apart from that, all that I can see is that you either have a problem with the PHP installation, or you are not saving the file in your web server location.
by hyper
Wed Jan 01, 2020 5:20 pm
Forum: PHP coding => General
Topic: How to replace matching words from an associative array without replacing words within existing links
Replies: 1
Views: 101

Re: How to replace matching words from an associative array without replacing words within existing links

IMO you'll have to split it down to several steps as there are quite complicated rules to apply. From what you have given, a possible process: Start with any multiple keywords first, then you could use explode to spilt into single words and loop through the array for a search / replace, maybe str_re...
by hyper
Wed Jan 01, 2020 4:11 am
Forum: PHP coding => General
Topic: sqlite query not working with php - works in console
Replies: 4
Views: 144

Re: sqlite query not working with php - works in console

It works for me fine: <?php $dbpath = '/home/rick/Desktop/sqliteDatabases/renoAZID.db'; $database = new PDO('sqlite:'.$dbpath,null,null,[ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_EMULATE_PREPARES => FALSE ]); // Since there is no user i...
by hyper
Tue Dec 31, 2019 2:11 pm
Forum: PHP coding => General
Topic: sqlite query not working with php - works in console
Replies: 4
Views: 144

Re: sqlite query not working with php - works in console

Try this:

Code: Select all

SELECT name FROM sqlite_master WHERE type='table'
It's not a good idea to expose your table information to users.
by hyper
Tue Dec 31, 2019 10:48 am
Forum: PHP coding => General
Topic: dynamic creation of drop down box - selected options blank
Replies: 4
Views: 147

Re: dynamic creation of drop down box - selected options blank

Well done, it can be difficult to see the wood for the trees sometimes :)
by hyper
Tue Dec 31, 2019 9:28 am
Forum: PHP coding => General
Topic: dynamic creation of drop down box - selected options blank
Replies: 4
Views: 147

Re: dynamic creation of drop down box - selected options blank

Run this code (your code stripped back): <?php $test[0]="zero.db"; // this array for testing only in lieu of the $files array above $test[1]="one.db"; $test[2]="two.db"; foreach ($test as $file) {?> <option value=><?php echo $file; ?></option> <?php } and have a look at the html source produced (ctr...
by hyper
Tue Dec 31, 2019 9:05 am
Forum: PHP coding => General
Topic: Uncaught Error: Call to a member function fetch_assoc
Replies: 1
Views: 110

Re: Uncaught Error: Call to a member function fetch_assoc

You can use fetch_all in MySQLi, but I would advise using PDO with prepared statements instead, you won't need to change your database, just your queries and connection to the database - it is a pain-free process. I'm not familiar with smarty, and you haven't shown your query string. I don't know if...
by hyper
Mon Dec 30, 2019 1:46 pm
Forum: PHP General
Topic: Session Variables Not Working
Replies: 19
Views: 227

Re: Session Variables Not Working

Why are you running:

Code: Select all

1<br/>
<?
phpinfo();
?>
2<br/>
<?
echo phpinfo();
?>
instead of:

Code: Select all

<?php
phpinfo();
Does your script filename end with .php ?

Is your file saved in the correct location for the server?

If you view source in your browser, can you see the script in red?
by hyper
Mon Dec 30, 2019 9:04 am
Forum: PHP General
Topic: Session Variables Not Working
Replies: 19
Views: 227

Re: Session Variables Not Working

Ok, run the following script and search for session to check that sessions are enabled:

Code: Select all

<?php
phpinfo();
by hyper
Sun Dec 29, 2019 9:51 am
Forum: PHP coding => General
Topic: PHP Change Password Script freezes my file
Replies: 2
Views: 137

Re: PHP Change Password Script freezes my file

You have a couple of issues with your script: Never store user passwords in plain text; if your database is compromised, all passwords will be available as plain text, if one (or more) of your users uses the same password for everything, they could get bitten quite sharply. Use password_hash to stor...