Search found 622 matches

by NigelRen
Sat Apr 15, 2017 9:43 am
Forum: PHP Scripts
Topic: arrays Windows v.s Linux
Replies: 2
Views: 544

Re: arrays Windows v.s Linux

You might find that the mysql functions have been removed ( deprecated since PHP 5.5 ) so it would probably need to be updated anyway to either MySQLi or PDO.
by NigelRen
Mon Apr 10, 2017 11:15 pm
Forum: mySQL & php coding
Topic: Select from Combobox to update MySql
Replies: 1
Views: 465

Re: Select from Combobox to update MySql

Sounds like you want to use the value attribute of the option element. So your code should generate something like (copied from https://www.w3schools.com/tags/att_option_value.asp) <select name="cars"> <option value="volvo">Volvo XC90</option> <option value="saab">Saab 95</option> <option value="mer...
by NigelRen
Mon Apr 03, 2017 11:44 pm
Forum: PHP General
Topic: code in Win does not work on Linux!?
Replies: 7
Views: 1099

Re: code in Win does not work on Linux!?

Don't know if this helps, but one huge difference between Windows and Linux is that Linux is case sensitive in file names. So there are problems with files called Database.php, database.php, DataBase.php as Linux will see them all as different files.
by NigelRen
Mon Apr 03, 2017 1:05 pm
Forum: PHP coding => General
Topic: How to make a choice in php (no html please)
Replies: 15
Views: 1486

Re: How to make a choice in php (no html please)

I get something like ( file saved as test.php )...

Code: Select all

nigel@Laravel:~$ php test.php 
adakshd
adakshd
ajdakjd
ajdakjd
^C
nigel@Laravel:~$ 
by NigelRen
Sun Apr 02, 2017 5:51 am
Forum: PHP coding => General
Topic: How to make a choice in php (no html please)
Replies: 15
Views: 1486

Re: How to make a choice in php (no html please)

Strange - have you tried...

Code: Select all

<?php
while (FALSE !== ($line = fgets(STDIN))) {
   echo $line;
}
?>
Can you post a screen capture of what you get? (Or some redirect the output to a file)
by NigelRen
Sat Apr 01, 2017 10:44 pm
Forum: PHP General
Topic: Question about variables.
Replies: 4
Views: 621

Re: Question about variables.

As the last bit of hyper's answer says - don't worry about it. There is sometimes confusion caused by the way that different versions of PHP have changed the way that variables can be dealt with. Type hinting in function declarations has been slowly getting better (IMHO) to the ability to define wha...
by NigelRen
Sat Apr 01, 2017 12:00 am
Forum: PHP coding => General
Topic: Cannot return from function
Replies: 2
Views: 465

Re: Cannot return from function

With your function, you are preparing the SQL statement, but not fetching the results. So have a look at how to do this and as hyper points out, these values then need to be returned from your function.
by NigelRen
Fri Mar 31, 2017 11:56 pm
Forum: PHP coding => General
Topic: How to make a choice in php (no html please)
Replies: 15
Views: 1486

Re: How to make a choice in php (no html please)

Hmmmm... I've tried it on Linux(ubuntu php 7.0.15) and Windows (10 php 7.1.3) and it works on both of them. Which version of php are you running and what platform?
by NigelRen
Fri Mar 31, 2017 12:08 pm
Forum: PHP coding => General
Topic: How to make a choice in php (no html please)
Replies: 15
Views: 1486

Re: How to make a choice in php (no html please)

Sorry for asking what your trying to do! Sometimes there may be alternatives to what your trying to achieve which may help or be of interest. But as you don't seem to care about what other people think or even able to do a simple search for what your after then have a look at http://www.php.net/manu...
by NigelRen
Thu Mar 30, 2017 11:39 pm
Forum: PHP coding => General
Topic: How to make a choice in php (no html please)
Replies: 15
Views: 1486

Re: How to make a choice in php (no html please)

Why would you want something like this? If you could explain what your trying to achieve it may be easier than trying to help with some strange solution. If you want something that people can use on a command line, then have a look at the 'PHP CLI' as this allows you to run something interactively, ...
by NigelRen
Thu Mar 30, 2017 11:34 pm
Forum: PHP coding => General
Topic: How do I prevent interpretation of $ in "quoted" strings as variable?
Replies: 2
Views: 468

Re: How do I prevent interpretation of $ in "quoted" strings as variable?

To be honest - I would take the hit now and change the database tables/columns to not have a $ sign in. This is not standard and is something that as you've already experienced, can cause all sorts of problems!
by NigelRen
Thu Mar 30, 2017 11:25 pm
Forum: mySQL & php coding
Topic: Why page navigation not working in this code?
Replies: 1
Views: 390

Re: Why page navigation not working in this code?

Does you code... if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; }; $start_from = ($page-1) * 12; $sql = "SELECT * FROM tbl_users where status='process' ORDER BY albumid DESC LIMIT $start_from, 12"; //$rs_result = mysql_query ($sql,$con); $rs_result= mysqli_query($con,$sql); Fet...
by NigelRen
Mon Mar 13, 2017 4:08 am
Forum: PHP coding => General
Topic: extract image file name from large string
Replies: 7
Views: 756

Re: extract image file name from large string

Problem is that you have two filenames in that string(fxdfsmall_gn44od0r.jpg and fxdfsmall.jpg), do you know which one is the correct one? If the same pattern is repeated in each record, you could do as you say and simply extract that string between those two positions. Perhaps do something simply t...
by NigelRen
Fri Mar 10, 2017 11:17 am
Forum: PHP Scripts
Topic: Don't put your fingers where they don't belong.....
Replies: 2
Views: 567

Re: Don't put your fingers where they don't belong.....

Do you have access to something where you can execute a SQL query (e.g. PHPMyAdmin)? If so - you could just run a query...

Code: Select all

UPDATE tb_product SET wholesale_price=wholesale_price  * 0,83333333333333333333333333333333
This would update all prices by the amount you want.
by NigelRen
Fri Mar 10, 2017 9:37 am
Forum: PHP coding => General
Topic: How to Extend WP Plugin MySQL connection array to Multiple??
Replies: 1
Views: 376

Re: How to Extend WP Plugin MySQL connection array to Multiple??

I really don't know how this can be done as your talking about - but there is an alternative... using federated tables. This means that in the default database, you can link to tables on other databases. Have a look at https://dev.mysql.com/doc/refman/5.5/en/federated-create-connection.html which ex...
by NigelRen
Fri Mar 10, 2017 9:31 am
Forum: PHP coding => General
Topic: includes in sub directories of password protected directories
Replies: 7
Views: 822

Re: includes in sub directories of password protected directories

Rather than use the URL of the include file, can you put the actual file name in instead. Should be something like xyz/header.php.
by NigelRen
Thu Mar 09, 2017 4:46 am
Forum: PHP coding => General
Topic: PDO with multiple queries
Replies: 3
Views: 514

Re: PDO with multiple queries

If you use DELETE using a WHERE EXISTS clause, this can make the deleting as simple as possible. It's also worth (if possible) using INSERT.... SELECT type statements to create your data, this allows you to reduce the number of statements and database roundtrips that you have to do. [Edit: this is m...
by NigelRen
Wed Mar 08, 2017 12:33 am
Forum: PHP coding => General
Topic: Simple but driving me nuts
Replies: 6
Views: 647

Re: Simple but driving me nuts

I know this isn't a direct answer to your question, but something that may be worth spending some time setting up is debugging. I use Eclipse to develop PHP (and others) and use XDebug to debug on a 'remote' server. It allows me to examine variables and step through code. I used http://bogdan-albei....
by NigelRen
Wed Mar 08, 2017 12:02 am
Forum: PHP coding => General
Topic: Help with array with no sessions
Replies: 4
Views: 510

Re: Help with array with no sessions

If you want a value to be across all users and pages you will have to store this value in some form of persistent store. This could be a database or a cache (AOC, Memcache). So for example - just have a table with last visit on and the next person retrieves it and updates it. (Not going to go into r...
by NigelRen
Tue Mar 07, 2017 12:51 am
Forum: PHP coding => General
Topic: Strange results using references - or is it?
Replies: 0
Views: 341

Strange results using references - or is it?

I'm working with something where I use references to allow me to modify arrays - and the reference on a field seems to 'stick'. The code I've cut down to show this is... <?php $tableName = "BinType"; $fields = [ [ "name" => "binTypeID" ], [ "name" => "description" ] ]; foreach ( $fields as $field ) ...
by NigelRen
Sat Mar 04, 2017 2:10 am
Forum: PHP General
Topic: Duplicate key.. but not duplicate!
Replies: 2
Views: 483

Re: Duplicate key.. but not duplicate!

Please don't post twice, it make it difficult to have one conversation about what is going on and could end up having several solutions which contradict each other.
by NigelRen
Sat Mar 04, 2017 2:08 am
Forum: PHP coding => General
Topic: Inserting to database, says duplicate!
Replies: 1
Views: 372

Re: Inserting to database, says duplicate!

Is that field being populated on the database? Just that the line..

Code: Select all

$Uname = $_Post['UserName'];
should probably be

Code: Select all

$Uname = $_POST['UserName'];
by NigelRen
Fri Mar 03, 2017 7:41 am
Forum: PHP Scripts
Topic: Early booking reservation system
Replies: 2
Views: 508

Re: Early booking reservation system

I'm not sure if your solution really captures the requirement. I would have thought that the array 'earlybooking' would be more based on the number of days rather than a date. So (for example) if you book 10 days before you get 10%, 20 days would be 15% etc. This would mean that you could look at th...
by NigelRen
Thu Mar 02, 2017 1:27 am
Forum: mySQL & php coding
Topic: Problems with logging in
Replies: 3
Views: 529

Re: Problems with logging in

The immediate issue may be as a result of the environment, but in the long term it's important to be able to pick up database errors and do something with them. At the moment you are just saying 'ignore any errors' which isn't helpful in debugging and doesn't provide the information which could help...
by NigelRen
Mon Feb 27, 2017 6:19 am
Forum: PHP coding => General
Topic: Getting the selected option in $_POST
Replies: 2
Views: 392

Re: Getting the selected option in $_POST

You can always store the original selected value in session data if needed, stop having to look it up again. As for not trusting user data - that is an important thing to remember! We had penetration testing of our site and the 'user' had a browser extension which allowed them to change the values o...