Search found 622 matches

by NigelRen
Sun Feb 26, 2017 11:53 am
Forum: PHP coding => General
Topic: insert array into db
Replies: 8
Views: 937

Re: insert array into db

Your insert already had the data in it - change this $sql = "INSERT INTO ip_data (name, ip) VALUES ( 'Peter Maxx', '193.169.5.16'), ('Ravi Shankar', '193.169.5.17'),"; $sql .= implode(", " , $DataArr); mysqli_query($conn, $sql); to $sql = "INSERT INTO ip_data (name, ip) VALUES "; $sql .= implode(", ...
by NigelRen
Sat Feb 25, 2017 12:27 am
Forum: PHP coding => General
Topic: insert array into db
Replies: 8
Views: 937

Re: insert array into db

It's always useful when dealing with SQL to get some error out of it if one has happened. Have a look at https://www.w3schools.com/php/func_mysqli_error.asp which shows you how to handle errors with mysqli. But that said, what I think is happening is that in... $sql = "INSERT INTO ip_data (name, ip)...
by NigelRen
Fri Feb 24, 2017 12:02 pm
Forum: PHP coding => General
Topic: PHP Stores password as whitespace
Replies: 2
Views: 683

Re: PHP Stores password as whitespace

Using $_POST fields in any SQL statement is a bad idea - look into why and that could help with your problem. (e.g. $_POST[fusername] - isn't quite what your after I think it should be - $_POST['fusername'])
by NigelRen
Tue Feb 21, 2017 12:58 pm
Forum: PHP General
Topic: Secure dynamic query (PDO)
Replies: 7
Views: 1482

Re: Secure dynamic query (PDO)

My concern is that the scope will creep to the point where it becomes unmanageable.... Sub selects - which is a select which can appear in a variety of places (columns, where, group by and having clauses) are a very useful piece of SQL which could cause a lot of confusion. Inserts using selects to p...
by NigelRen
Tue Feb 21, 2017 8:26 am
Forum: PHP General
Topic: Secure dynamic query (PDO)
Replies: 7
Views: 1482

Re: Secure dynamic query (PDO)

I'm not sure about the idea of having different stages of development having the same set of code files - except for the database, surely the idea of having different servers is so that the changes can be kept separate and there is no chance of side effects of changing one of them. Even if it's not ...
by NigelRen
Mon Feb 20, 2017 11:34 pm
Forum: mySQL & php coding
Topic: MySQL PHP Connection via godaddy
Replies: 8
Views: 1384

Re: MySQL PHP Connection via godaddy

To be honest - I have no experience of using GoDaddy so can't even try anything out. But have you looked into posts like https://forums.cpanel.net/threads/how-t ... li.142737/ which may give you some indications?
by NigelRen
Mon Feb 20, 2017 11:18 pm
Forum: PHP General
Topic: PDO Prepared Param - Different Results
Replies: 5
Views: 979

Re: PDO Prepared Param - Different Results

IMHO this is one of the problems of 'dynamic' typed languages - their fine until you reach the boundaries where types are very important. Some of the automatic conversions make it worse by making your mind up about what you really meant it to do. If your value is a field coming in from the user, the...
by NigelRen
Sun Feb 19, 2017 12:46 pm
Forum: PHP General
Topic: UPDATE FORM DATA PULLED FROM SQL, ERROR
Replies: 2
Views: 738

Re: UPDATE FORM DATA PULLED FROM SQL, ERROR

Is this line taking it one stage to far... $blah = $_POST[$y]; Isn't it $y that you want to use, rather than using it as an index into $_POST? Also I think that in the update line - you will need to put the value in quotes ( ' ) otherwise it will try to find some column or function with that name ra...
by NigelRen
Sat Feb 18, 2017 12:53 pm
Forum: PHP Installation
Topic: PHP Scripts Won't run - Win10
Replies: 7
Views: 1228

Re: PHP Scripts Won't run - Win10

Haven't tried it myself (don't usually develop under Windows) but have a read of http://php.net/manual/pl/install.window ... ndline.php. You can run any PHP script from the command line, but the output will also go to the command file and so be lost (bit like running any batch file).
by NigelRen
Sat Feb 18, 2017 7:41 am
Forum: PHP Installation
Topic: PHP Scripts Won't run - Win10
Replies: 7
Views: 1228

Re: PHP Scripts Won't run - Win10

The php scripts are usually run by a process which is listening to a network port. So rather than like Word which is automatically run when you click on a document, php tends to be sent as a request by a web browser. This process is configured to only access scripts etc. from specific directories - ...
by NigelRen
Sat Feb 18, 2017 2:23 am
Forum: PHP coding => General
Topic: syntax error passing string to varchar
Replies: 1
Views: 501

Re: syntax error passing string to varchar

Should it start with a $

Code: Select all

$key1 = "($key1)";
by NigelRen
Thu Feb 16, 2017 1:31 pm
Forum: PHP coding => General
Topic: Rounding up a number
Replies: 1
Views: 503

Re: Rounding up a number

You probably just want to round the value, if you use a negative number for the precision, you can achieve what your after (AFAIK). Have a look at http://php.net/manual/en/function.round.php.
by NigelRen
Wed Feb 15, 2017 12:44 am
Forum: PHP coding => General
Topic: csv file import into database
Replies: 3
Views: 770

Re: csv file import into database

Error checking and reporting is the easiest way to find out what is going wrong and for some reason seems to be the last thing people include :oops: As for why it sometimes work and then stops - if you look at the data files, you may find that there is something in them which will point to a problem...
by NigelRen
Sun Feb 12, 2017 1:07 am
Forum: mySQL & php coding
Topic: MySQL PHP Connection via godaddy
Replies: 8
Views: 1384

Re: MySQL PHP Connection via godaddy

Try seeing what php info gives you...

Code: Select all

<?php
phpinfo();
Should show you which options are available and what is configured.
by NigelRen
Mon Jan 30, 2017 9:25 am
Forum: mySQL & php coding
Topic: howto query sum of different columns with different conditions...
Replies: 2
Views: 830

Re: howto query sum of different columns with different conditions...

Of course with the example of code given - you will need to add the logic of if the player won (whilst playing home) or won (whilst playing away).
by NigelRen
Mon Jan 30, 2017 9:21 am
Forum: mySQL & php coding
Topic: My function wont update mysql entry
Replies: 4
Views: 1151

Re: My function wont update mysql entry

I agree with the 'update your code' sentiment, you should start to work with some of the newer API's as they have a lot of useful and safer features than you currently have available. As for your error - depending of what username is defined as on the database, it may need quotes round it to ensure ...
by NigelRen
Mon Jan 30, 2017 9:17 am
Forum: mySQL & php coding
Topic: change variables automatically with time
Replies: 1
Views: 685

Re: change variables automatically with time

I think it would be better to let this logic sit in the PHP code, simply storing the date on the database. This allows the logic to change without having to change the database and having to work out which records should be valid now which weren't previously (and vice versa). If you still wanted to ...
by NigelRen
Mon Jan 30, 2017 8:54 am
Forum: PHP coding => General
Topic: SQL to Array
Replies: 5
Views: 1170

Re: SQL to Array

A shorter query which should do the job is SELECT PS.player_name, ( SELECT COUNT(player) FROM player_death PD WHERE PD.PLAYER = PS.PLAYER_ID ) AS DEATHS, ( SELECT COUNT(KILLER) FROM player_kill PK WHERE PK.killer = PS.player_id ) AS KILLS FROM player_stats PS WHERE PS.player_name IS NOT NULL; I've o...
by NigelRen
Wed Dec 07, 2016 1:24 am
Forum: PHP coding => General
Topic: Mysql won't start. the start button in xampp is disabled
Replies: 1
Views: 1056

Re: Mysql won't start. the start button in xampp is disabled

It's easier to break down the problem - firstly if you have phpmyadmin installed, can you connect and see your database? This ensures that the database itself is running and not the issue.
If that works - check phpinfo - is the module loaded?
by NigelRen
Wed Nov 30, 2016 2:17 am
Forum: mySQL & php coding
Topic: Database Structure - Need Guidance
Replies: 1
Views: 1215

Re: Database Structure - Need Guidance

With you Youtube video details, just add the user name to the table and make the primary key as user name AND youtube video ID. Just a note - one thing that is more common is to use a user ID rather than user name as a primary key. This would be some generated ID (could be an auto increment value) o...
by NigelRen
Tue Nov 15, 2016 1:15 pm
Forum: PHP coding => General
Topic: Report Generation error
Replies: 1
Views: 706

Re: Report Generation error

Do you have an index on the date field on the database?
by NigelRen
Fri Nov 11, 2016 11:45 pm
Forum: PHP coding => General
Topic: Title: Session is partly lost sometimes (hard to reproduce)
Replies: 1
Views: 570

Re: Title: Session is partly lost sometimes (hard to reproduce)

Difficult to tell - but are you storing a connection or other complex information in the session data? There is also the case of are you sure that the definition of this class is always available when trying to reload the data. IMHO it's not really the place for anything other than data (or objects ...
by NigelRen
Fri Nov 11, 2016 12:57 pm
Forum: PHP Scripts
Topic: syntax error, unexpected 'class' (T_CLASS), expecting ',' or ')' in ...
Replies: 1
Views: 918

Re: syntax error, unexpected 'class' (T_CLASS), expecting ',' or ')' in ...

The problem can be seen easier when using a PHP enabled editor (I use Eclipse) and it shows that the problem starts earlier on... The '\' is a way of escaping the next character and was escaping the last ' of the following. So change the \ to \\ as in define ('MYSQL', 'D:\\wamp\\www\\LoginTest\\'); ...
by NigelRen
Tue Nov 08, 2016 4:03 am
Forum: PHP coding => General
Topic: Fatal error: Uncaught Error: Call to undefined function oci_connect()
Replies: 6
Views: 1572

Re: Fatal error: Uncaught Error: Call to undefined function oci_connect()

PHP versions 5 and 7 have their differences, if this will affect you is something only you can answer - BUT I would recommend trying to use version 7 if you can now. I know this is an extra thing to set-up/learn etc. but you could always install a virtual machine to run PHP on, I use it for both Win...