[PHP-DB] MySQLi

2014-09-13 Thread Karl DeSaulniers
Hello All,
Hope this message finds you well. Quick question about MySQLi and PHP.
I have a website that was built back in 2012 that is still on PHP 5.2 and MySQL 
and I am wanting to update it to PHP 5.7 with MySQLi without headaches.
I am dreading this like a spoonful of molasses. Is there any sugar remedy for 
this medicine 
or do I just grow a pair and take it?

Any MySQL = MySQLi converters out there?
Any PHP5.2 = PHP 5.7 cheat sheets?

If I update my server to PHP 5.7 is everything going to break? Or stupid 
question of course it is?
lol

TIA,
Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com





Re: [PHP-DB] MySQLi

2014-09-13 Thread Lester Caine
On 13/09/14 11:40, Karl DeSaulniers wrote:
 Hope this message finds you well. Quick question about MySQLi and PHP.
 I have a website that was built back in 2012 that is still on PHP 5.2 and 
 MySQL 
 and I am wanting to update it to PHP 5.7 with MySQLi without headaches.
 I am dreading this like a spoonful of molasses. Is there any sugar remedy for 
 this medicine 
 or do I just grow a pair and take it?

Well a few problems 5ere ...
PHP5.2 had already been shelved at end of 2010, but I know why it was
probably used 2 years later. I'm STILL running 5.2 on servers as the
time needed to convert those sites is just not available and can't be
justified cost wise :(

 Any MySQL = MySQLi converters out there?
 Any PHP5.2 = PHP 5.7 cheat sheets?
 
 If I update my server to PHP 5.7 is everything going to break? Or stupid 
 question of course it is?
PHP5.7 will not be around any time soon, PHP5.6 has just been released.
But converting from 5.2 all the way to 5.6 is not something that is easy
to do. I'm still only moving 5.2 to 5.4 at presnt.

http://php.net/manual/en/migration53.php and
http://php.net/manual/en/migration54.php is the starting point, but
things depricated in 5.3 were removed in 5.4 so if you are using any of
those methods then they need removing. You can switch the later PHP
servers to ignore e_strict warning/errors, but this is the major problem
area. and really the only way to move forward is clear all of those
problems before moving forward. Unless you caa ensure your server will
always be switched bak to a compatible mode of working.

And all that before even looking at MySQL ... I've never used it, so
hopefully someone else will cover that side.

-- 
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] MySQLi

2014-09-13 Thread Karl DeSaulniers
On Sep 13, 2014, at 7:40 AM, Lester Caine les...@lsces.co.uk wrote:

 On 13/09/14 11:40, Karl DeSaulniers wrote:
 Hope this message finds you well. Quick question about MySQLi and PHP.
 I have a website that was built back in 2012 that is still on PHP 5.2 and 
 MySQL 
 and I am wanting to update it to PHP 5.7 with MySQLi without headaches.
 I am dreading this like a spoonful of molasses. Is there any sugar remedy 
 for this medicine 
 or do I just grow a pair and take it?
 
 Well a few problems 5ere ...
 PHP5.2 had already been shelved at end of 2010, but I know why it was
 probably used 2 years later. I'm STILL running 5.2 on servers as the
 time needed to convert those sites is just not available and can't be
 justified cost wise :(
 
 Any MySQL = MySQLi converters out there?
 Any PHP5.2 = PHP 5.7 cheat sheets?
 
 If I update my server to PHP 5.7 is everything going to break? Or stupid 
 question of course it is?
 PHP5.7 will not be around any time soon, PHP5.6 has just been released.
 But converting from 5.2 all the way to 5.6 is not something that is easy
 to do. I'm still only moving 5.2 to 5.4 at presnt.
 
 http://php.net/manual/en/migration53.php and
 http://php.net/manual/en/migration54.php is the starting point, but
 things depricated in 5.3 were removed in 5.4 so if you are using any of
 those methods then they need removing. You can switch the later PHP
 servers to ignore e_strict warning/errors, but this is the major problem
 area. and really the only way to move forward is clear all of those
 problems before moving forward. Unless you caa ensure your server will
 always be switched bak to a compatible mode of working.
 
 And all that before even looking at MySQL ... I've never used it, so
 hopefully someone else will cover that side.
 
 -- 
 Lester Caine - G8HFL

Ah, I see. Now Glob Design's comment makes sense. 
Thanks Lester.

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] MySQLi

2014-09-13 Thread Aziz Saleh
On Sat, Sep 13, 2014 at 8:55 PM, Karl DeSaulniers k...@designdrumm.com
wrote:

 On Sep 13, 2014, at 7:40 AM, Lester Caine les...@lsces.co.uk wrote:

  On 13/09/14 11:40, Karl DeSaulniers wrote:
  Hope this message finds you well. Quick question about MySQLi and PHP.
  I have a website that was built back in 2012 that is still on PHP 5.2
 and MySQL
  and I am wanting to update it to PHP 5.7 with MySQLi without headaches.
  I am dreading this like a spoonful of molasses. Is there any sugar
 remedy for this medicine
  or do I just grow a pair and take it?
 
  Well a few problems 5ere ...
  PHP5.2 had already been shelved at end of 2010, but I know why it was
  probably used 2 years later. I'm STILL running 5.2 on servers as the
  time needed to convert those sites is just not available and can't be
  justified cost wise :(
 
  Any MySQL = MySQLi converters out there?
  Any PHP5.2 = PHP 5.7 cheat sheets?
 
  If I update my server to PHP 5.7 is everything going to break? Or
 stupid question of course it is?
  PHP5.7 will not be around any time soon, PHP5.6 has just been released.
  But converting from 5.2 all the way to 5.6 is not something that is easy
  to do. I'm still only moving 5.2 to 5.4 at presnt.
 
  http://php.net/manual/en/migration53.php and
  http://php.net/manual/en/migration54.php is the starting point, but
  things depricated in 5.3 were removed in 5.4 so if you are using any of
  those methods then they need removing. You can switch the later PHP
  servers to ignore e_strict warning/errors, but this is the major problem
  area. and really the only way to move forward is clear all of those
  problems before moving forward. Unless you caa ensure your server will
  always be switched bak to a compatible mode of working.
 
  And all that before even looking at MySQL ... I've never used it, so
  hopefully someone else will cover that side.
 
  --
  Lester Caine - G8HFL

 Ah, I see. Now Glob Design's comment makes sense.
 Thanks Lester.

 Best,

 Karl DeSaulniers
 Design Drumm
 http://designdrumm.com


 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


I am not sure about any MySQL - MySQLI wrappers, but I did built a MySQL
- PDO Wrapper a while back that you can use if you have PDO_MySQL enabled:

https://github.com/azizsaleh/mysql


Re: [PHP-DB] MySQLi

2014-09-13 Thread Karl DeSaulniers
Awesome, thanks for the link. I know even less about PDO then I do regular 
MySQL however.
I am hoping MySQLi isn't too far off a shoot. Just need to sit down with it all 
and figure out a path.

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com



On Sep 13, 2014, at 10:52 PM, Aziz Saleh azizsa...@gmail.com wrote:
 
 I am not sure about any MySQL - MySQLI wrappers, but I did built a MySQL - 
 PDO Wrapper a while back that you can use if you have PDO_MySQL enabled:
 
 https://github.com/azizsaleh/mysql



[PHP-DB] Duplicate Writes

2014-09-13 Thread Ethan Rosenberg

Dear List -

I seem to be getting dual writes causing a dual insert into the database, and I 
cannot figure out why.

Database

mysql describe Inventory;
+-+-+--+-+-+---+
| Field   | Type| Null | Key | Default | Extra |
+-+-+--+-+-+---+
| UPC | char(12)| NO   | PRI | |   |
| quant   | int(5)  | NO   | | NULL|   |
| manuf   | varchar(20) | YES  | | NULL|   |
| item| varchar(50) | YES  | | NULL|   |
| orderpt | tinyint(4)  | NO   | | NULL|   |
| ordrpt_flag | tinyint(3)  | YES  | | NULL|   |
| stock   | int(3)  | YES  | | NULL|   |
| price   | float   | YES  | | NULL|   |
| tax_flag| tinyint(3)  | YES  | | NULL|   |
+-+-+--+-+-+---+
9 rows in set (0.37 sec)

mysql describe Purchases;
+---+-+--+-+-++
| Field | Type| Null | Key | Default | Extra  |
+---+-+--+-+-++
| indx  | smallint(6) | NO   | PRI | NULL| auto_increment |
| manf  | varchar(20) | YES  | | NULL||
| itm   | varchar(50) | YES  | | NULL||
| prc   | float   | YES  | | NULL||
+---+-+--+-+-++
4 rows in set (0.00 sec)


PHP code - snipped

error_reporting(E_ALL | E_NOTICE);
ini_set('display_errors','1');

html
?php


$fh1 = fopen(/var/www/orders.txt, a+);
$fh2 = fopen(/var/www/receipt.txt, a+);
$fh3 = fopen(/var/www/purchase.txt, a+);
$sql2 = update Inventory set quant = quant - 1 where UPC = $upc ;

$result2 = mysqli_query($cxn, $sql2);

$row2 = mysqli_fetch_row($result2);

$sql3 = select quant, orderpt,  ordrpt_flag, manuf, item, stock,price,tax_flag  from Inventory 
where UPC = $upc;


$result3 = mysqli_query($cxn, $sql3);

?
div align=center
table border=4 cellpadding=5 cellspacing=55 rules=all frame=box
tr class='heading'
thManufacturer/th
thItem/th
thPrice/th
/tr 

?php
$row3 = mysqli_fetch_row($result3);

echo 'br /';
$Quant   = $row3[0];
$Orderpt = $row3[1];
$Ordrpt_flag = $row3[2];
$Manuf =   $row3[3];
$Item  =   $row3[4];
$Stock =   $row3[5];
$Price =   $row3[6];
$Tax   =   $row3[7];

$numbyt=fprintf($fh2, %s\t %.2f\t\n %s\t %s\n,$row3[3] , $row3[6], $row3[4], 
$row3[7]);


$numbyt=fprintf($fh3, %s,%s,%s, %.2f\n,NULL,$row3[3], $row3[4], $row3[6]);



if($row3[0]  $row3[1] )
echo centerbspan style='color: red; font-size:14pt'; Order more $row3[3]  $row3[4] Now/bbr 
/ /span/center;


$sql4 = update Inventory set ordrpt_flag = 1 where UPC = $upc;

$result4 = mysqli_query($cxn, $sql4);

$numbyt=fprintf($fh1, %d %d %d %s %s %d\n, $Quant, $Orderpt, $Ordrpt_flag, 
$Manuf, $Item, $Stock);
?   

tr

td ?php echo $row3[3]; ? /td
td ?php echo $row3[4]; ? /td
td ?php echo $row3[6]; ? /td
/tr
/table  
?php

$sql5 = load data infile '/var/www/purchase.txt' into table 
. Purchases FIELDS TERMINATED BY ',' lines terminated by '\n' ; //There are 
dual writes to the //table

$result5 = mysqli_query($cxn, $sql5);
$sql26 = SELECT SQL_CALC_FOUND_ROWS itm FROM Purchases ;

$result26 = mysqli_query($cxn, $sql26);
$sql27 = SELECT FOUND_ROWS();

$result27 =  mysqli_query($cxn, $sql27);
$row27 = mysqli_fetch_row($result27);

$sql25 = select * from Purchases;
$result25 = mysqli_query($cxn, $sql25);
?   

div align=center
table border=4 cellpadding=5 cellspacing=55 rules=all frame=box
tr class='heading'
thIndex/th
thManufacturer/th
thItem/th
thPrice/th
/tr 

?php

for($i = 0; $i $row27[0]; $i++)
{
$row25 = mysqli_fetch_row($result25)
?
tr
td ?php echo $row25[0]; ? /td
td ?php echo $row25[1]; ? /td
td ?php echo $row25[2]; ? /td
td ?php echo $row25[3]; ? /td
/tr
?php
}
?   
/table  


TIA

Ethan   




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php