-
Posts
24,612 -
Joined
-
Last visited
-
Days Won
834
Everything posted by Barand
-
... or add a UNIQUE key to the field to make it impossible to add the same one twice
-
You don't even need a loop. You can check the whole array with a single statement if ($input != str_replace($myArray,'', $input) ) { echo "Contains an existing value"; }
-
Code is not working trying to login using SQL SERVER
Barand replied to TStyles's topic in PHP Coding Help
You have only the database name -
Using an aggregation function (SUM(), COUNT() etc) without specifying a GROUP BY column(s) will return a single row containing the aggregate for the whole selection. Values for the other non-aggregated selected columns are indeterminate (although usually from the first record in the set.
-
looks like data is array to me $obj = (object)[ 'name' => 'my name', 'data' => [2,4,6]]; print_r($obj); /* results ******************** stdClass Object ( [name] => my name [data] => Array ( [0] => 2 [1] => 4 [2] => 6 ) ) */
-
$obj = (object)[ 'name' => 'my name', 'data' => [2,4,6]];
-
How/What is the correct way to create a function for MS SQL Queries.
Barand replied to kat35601's topic in PHP Coding Help
Translating the above to sqlsrv dialect WHERE DATEPART(yyyy, datefield) = targetyear AND DATEPART(mm, datefield) = targetmonth -
looping results from query and limit amount per row
Barand replied to jacko_162's topic in PHP Coding Help
Easiest way is to read the results into an array and then use array_chunk() with a chunk size of 5. Output each chunk as a row. -
perhaps +-------------+ | chart | +-------------+ +-------------+ | +---------------+ | series | | | category | +-------------+ | +---------------+ | | | | /|\ | | +-------------+ | +-------------<| value |>--------------+ +-------------+
-
So if your categories are the continents then you could have a chart showing population growth, say, but you could not then have another chart for those continents showing economic growth.
-
According to that model, a chart can have many categories but a category can belong to only one chart.
-
Check database name before running a query in phpMyAdmin
Barand replied to cyberRobot's topic in MySQL Help
The idea is to "USE databasename" to set the correct database name as default -
Check database name before running a query in phpMyAdmin
Barand replied to cyberRobot's topic in MySQL Help
I can think of only three ways Only ever have a single database on your server Execute the statement "USE databasename" before every query. In INSERT, UPDATE and DELETE queries always prefix the table names with dbname (ie dbname.tablename). No damage is done with SELECT queries I suppose a fourth way is be careful what you are doing -
How to eliminate double values in dynamic dropdown on update?
Barand replied to learningprobs's topic in PHP Coding Help
Use "SELECT DISTINCT ... " You seem to have design flaws in the database. If the table contains the id and name then they should be unique. If, on the other hand, it's a table at the "many" end of a one-to-many relationship then the name shouldn't be in the table, just the id. -
see https://en.wikipedia.org/wiki/Phrases_from_The_Hitchhiker%27s_Guide_to_the_Galaxy#Answer_to_the_Ultimate_Question_of_Life.2C_the_Universe.2C_and_Everything_.2842.29
-
back to PDO and get strange error on online host not on wamp
Barand replied to lovephp's topic in PHP Coding Help
You might want to consider altering the logic of the program so that if there are no results to display then you do not even attempt to paginate nothing. -
Something I've already told them in another post (http://forums.phpfreaks.com/topic/301723-error-saving-data-in-mysql-table/). Why do we bother?
-
HTML colours have three colour components, namely red, green and blue. Each of these has a value ranging from 0 to 255. These are expressed as hexadecimal values 00 to FF. #FF0000 = red #00FF00 = green #0000FF = blue equal quantities of each component gives a grey color, for example #888888 gives a mid-grey. In the function, the variables $r, $g and $b are the red, green and blue values. Those look fairly meaningful to me, better than $peter, $paul and $mary.
-
Help to get Json data to a comma delimited file
Barand replied to techboy992's topic in PHP Coding Help
Having got the data into a CSV file you can load it into a MySql table using LOAD DATA INFILE statement -
Help to get Json data to a comma delimited file
Barand replied to techboy992's topic in PHP Coding Help
Not throwing an error does not mean it works. It removes the characters from the text fields also It still leaves commas in the currency field -
Creating multidimensional arrays from SQL table
Barand replied to NotionCommotion's topic in PHP Coding Help
@requinix - It was tricky getting the timing just right -
Creating multidimensional arrays from SQL table
Barand replied to NotionCommotion's topic in PHP Coding Help
try $sql = "SELECT co.id , co.name , car.id , car.model FROM companytest co INNER JOIN cartest car ON co.id = car.make ORDER BY co.id, car.id"; $res = $db->query($sql); $cars = []; $prev = ''; while (list($coid, $coname, $cid, $model) = $res->fetch_row()) { if (!isset($cars[$coid])) { $cars[$coid] = ['id' => $coid, 'name' => $coname, 'cars' =>[] ]; } $cars[$coid]['cars'][] = ['id' => $cid, 'model' => $model]; } the data mysql> select * from companytest; +------+----------------+ | id | name | +------+----------------+ | 1 | Ford | | 3 | General Motors | | 5 | Chrysler | +------+----------------+ 3 rows in set (0.00 sec) mysql> select * from cartest; +------+------+------------+ | id | make | model | +------+------+------------+ | 1 | 1 | Mustang | | 2 | 1 | Fusion | | 3 | 3 | Corvette | | 4 | 3 | Escalade | | 5 | 5 | Charger | | 6 | 5 | Challenger | +------+------+------------+ 6 rows in set (0.00 sec) -
Do you have error reporting turned on? Have you checked the values of mysqli_error? I cannot do it for you.
-
Similarly, the code you just posted, the input to simplexml_load_string() is $result->GetDailyListingSummaryResult->any That should be the XML.
-
First step to debugging is to have error_reporting switched on and also check for mysqli_error values after attempting queries. Where is $resultat defined? If it isn't it should be throwing an "undefined variable" error.