Search found 359 matches

by freshnet
Sun Feb 05, 2017 6:48 am
Forum: PHP coding => General
Topic: Is there any PHP function similar to "FORECAST.ETS()" in Excel ?
Replies: 1
Views: 385

Re: Is there any PHP function similar to "FORECAST.ETS()" in Excel ?

Forecast uses exponential smoothing, which is not built into PHP. You may be able to find an alternative function as a snippet, but I'm not aware of one.
by freshnet
Wed Feb 01, 2017 1:00 pm
Forum: mySQL & php coding
Topic: My Problem with dropdownlist in mysql,php
Replies: 11
Views: 1595

Re: My Problem with dropdownlist in mysql,php

Also just noticed you have

Code: Select all

mysql_insert_id
instead of

Code: Select all

mysqli_insert_id
by freshnet
Wed Feb 01, 2017 12:58 pm
Forum: mySQL & php coding
Topic: My Problem with dropdownlist in mysql,php
Replies: 11
Views: 1595

Re: My Problem with dropdownlist in mysql,php

Ok as I said, I don't know too much about SPs. Your get roles SP could just be a query right? I don't see any reason to write a procedure to just run a single select query. As for the other SP, here is how I do these things. First I make the required fields required in html, and also check the PHP f...
by freshnet
Tue Jan 31, 2017 8:15 am
Forum: PHP coding => General
Topic: Image Upload failure since website migrated
Replies: 9
Views: 1042

Re: Image Upload failure since website migrated

Are you looking for a person, or a hosting provider, or an application to help you write PHP code? If you want to hire someone to write your code, I suggest you try something like www.upwork.com.
by freshnet
Mon Jan 30, 2017 5:39 pm
Forum: PHP coding => General
Topic: SQL to Array
Replies: 5
Views: 638

Re: SQL to Array

I agree this is better, I'd forgotten about correlated subqueries!
by freshnet
Fri Jan 27, 2017 6:27 pm
Forum: PHP coding => General
Topic: Image Upload failure since website migrated
Replies: 9
Views: 1042

Re: Image Upload failure since website migrated

Yikes. You really need to upgrade PHP. 5.2 has not been supported since 2011 http://php.net/eol.php . If your hosting provider supports a newer version you should strongly consider upgrading. There are other things that could be different than just the version that might prevent your code from worki...
by freshnet
Fri Jan 27, 2017 6:22 pm
Forum: mySQL & php coding
Topic: My Problem with dropdownlist in mysql,php
Replies: 11
Views: 1595

Re: My Problem with dropdownlist in mysql,php

I'm not an SP expert, but aren't you calling your SP without any parameters?
by freshnet
Thu Jan 26, 2017 8:00 pm
Forum: mySQL & php coding
Topic: I'm unable to insert a record/entry using PDO. Could any one help?
Replies: 2
Views: 514

Re: I'm unable to insert a record/entry using PDO. Could any one help?

Your code looks fine to me, can you give an example of what values each variable has and what you see on screen? You can find information on data types here https://dev.mysql.com/doc/refman/5.7/en/data-types.html
by freshnet
Thu Jan 26, 2017 7:52 pm
Forum: mySQL & php coding
Topic: Notice: Undefined offset: 0 in session
Replies: 1
Views: 382

Re: Notice: Undefined offset: 0 in session

[0] will not work with $_SESSION unless it's explicitly set. In your code it's not set, so you get an undefined offset. You can only reference an element of the $_SESSION global array by the same key you gave it.

Code: Select all

echo $_SESSION['username'];
by freshnet
Thu Jan 26, 2017 7:49 pm
Forum: mySQL & php coding
Topic: My function wont update mysql entry
Replies: 4
Views: 662

Re: My function wont update mysql entry

If your $user variable is a string, you need single quotes around it. Having said that, the mysql extension is deprecated. You should upgrade to mysqli minimum, ideally use PDO which will allow you (if you feel it's necessary) to catch exceptions.
by freshnet
Thu Jan 26, 2017 7:42 pm
Forum: mySQL & php coding
Topic: My Problem with dropdownlist in mysql,php
Replies: 11
Views: 1595

Re: My Problem with dropdownlist in mysql,php

Ah didn't spot that, thanks for posting your solution!
by freshnet
Thu Jan 26, 2017 7:40 pm
Forum: PHP coding => General
Topic: help with a bible search script
Replies: 5
Views: 616

Re: help with a bible search script

You are coming across as a little hostile. This is a forum for people to get (free) assistance with coding, please be grateful for that. If you have a specific question, please provide the code or algorithm that you have so far, and where you're running into problems. If you can't do that, you're un...
by freshnet
Thu Jan 26, 2017 11:02 am
Forum: PHP coding => General
Topic: SQL to Array
Replies: 5
Views: 638

Re: SQL to Array

I'm not sure what you're asking exactly in terms of the array, but yes you can easily do something like $playerDataArray['id'] = x; //run a query to get the deaths $playerDataArray['deaths'] = x; //run a query to get the kills $playerDataArray['kills'] = x; As an alternative, have you considered usi...
by freshnet
Thu Jan 26, 2017 10:49 am
Forum: PHP coding => General
Topic: Change ORDER BY when a row's value has 0?
Replies: 2
Views: 467

Re: Change ORDER BY when a row's value has 0?

Just create a virtual column and order by that. Something like this should work. Alternatively, why not just order by rank then recentactdate for everyone? Right now those rows will just be in random order within ranks. SELECT rank , CASE WHEN rank = 0 THEN RecentActDate ELSE NULL END rank2 FROM acc...
by freshnet
Thu Jan 26, 2017 10:44 am
Forum: PHP coding => General
Topic: Image Upload failure since website migrated
Replies: 9
Views: 1042

Re: Image Upload failure since website migrated

What makes you think the PHP version has changed? If you create a file with the below code and execute it, is the version what you expect? <?php echo phpinfo(); ?> What shows in the error logs for the image upload? Finally, if the PHP version has changed, what makes you think this is causing the pro...
by freshnet
Thu Jan 26, 2017 9:50 am
Forum: PHP coding => General
Topic: Request help with form posting. I can only post part of a form.
Replies: 6
Views: 891

Re: Request help with form posting. I can only post part of a form.

The post part of your code is fine. The PDO part however is incorrect. First, you are mixing prepared and non-prepared query code. Second, you are trying to execute a query using a string variable as an object. Neither of these will work. You also have some other errors such as comparing your 'if' s...
by freshnet
Thu Jan 19, 2017 5:18 am
Forum: mySQL & php coding
Topic: Can I request guidance with PDO Database?
Replies: 6
Views: 854

Re: Can I request guidance with PDO Database?

One more thing I noticed - if you're going to use variables directly in your queries (which I don't recommend), you need to put them in single quotes. An easier solution (in my opinion) is to use binds, because then you don't have to remember the quotes. This is what you should have "$sql=UPDATE php...
by freshnet
Mon Jan 16, 2017 3:16 pm
Forum: mySQL & php coding
Topic: Create and Maintain a single/reusable connection to database with PDO
Replies: 3
Views: 542

Re: Create and Maintain a single/reusable connection to database with PDO

Just curious, why have you got prepare emulation disabled? The only reason I can think of to do that is if you have to run the same query lots of times within the same script.
by freshnet
Mon Jan 16, 2017 10:04 am
Forum: mySQL & php coding
Topic: Can I request guidance with PDO Database?
Replies: 6
Views: 854

Re: Can I request guidance with PDO Database?

Actually, that looks more like the page isn't serving php at all, since it's displaying your complete code. test it with

Code: Select all

<?php

phpinfo();
If that doesn't work, the problem is php and not PDO at all.
by freshnet
Sun Jan 15, 2017 8:00 pm
Forum: mySQL & php coding
Topic: How do I Update in PDO please.
Replies: 4
Views: 608

Re: How do I Update in PDO please.

PDO::FETCH_OBJ returns an object. Based on your code you want an associative array, so PDO::FETCH_ASSOC. Since this is an array you will need echo $row['EMail'] to get the data. I agree that the w3schools pdo tutorial is not very useful. It took me a couple of years of playing about and reading docs...
by freshnet
Sun Jan 15, 2017 7:35 pm
Forum: mySQL & php coding
Topic: Create and Maintain a single/reusable connection to database with PDO
Replies: 3
Views: 542

Re: Create and Maintain a single/reusable connection to database with PDO

Put the connection variables inside the function. IMO this code is unnecessarily complicated though. Here is what I use. class pdo_query { function __construct()//construct ensures connection is automatically made { require './connect.php';//this is where the variables are set that contain the conne...
by freshnet
Sun Jan 15, 2017 7:25 pm
Forum: mySQL & php coding
Topic: Login to a mysql db
Replies: 2
Views: 471

Re: Login to a mysql db

The mysql extension is deprecated, you should use PDO or mysqli instead. http://php.net/manual/en/function.mysql-connect.php
by freshnet
Sun Jan 15, 2017 7:24 pm
Forum: mySQL & php coding
Topic: My Problem with dropdownlist in mysql,php
Replies: 11
Views: 1595

Re: My Problem with dropdownlist in mysql,php

You can use a variable before it's defined in PHP, however it will generate a notice. The code will still work.
by freshnet
Sun Jan 15, 2017 7:21 pm
Forum: mySQL & php coding
Topic: Can I request guidance with PDO Database?
Replies: 6
Views: 854

Re: Can I request guidance with PDO Database?

Your code is fine, so obviously there is something else going on. Silly question, but is the same localhost reachable from the new file? In terms of PDO, it is best practice to use a try / catch block because otherwise users could end up seeing exceptions that reveal information about your system. S...
by freshnet
Fri Apr 15, 2016 4:29 pm
Forum: PHP coding => General
Topic: "IF" to do nothing if Page ID = x
Replies: 2
Views: 554

Re: "IF" to do nothing if Page ID = x

Ok so it sounds like this is all WP. That is_page is a special WP function and not a PHP function, which is why I was asking about the code for it. That code looks fine (and it works), but it is only going to look for images in the same folder as itself (hence the '.' for the folder variable at the ...