Re: [PHP-DB] Connecting PHP to MySQL on Windows

2011-01-07 Thread Gavin Chalkley
Mike,

A plain HOST file should have the commented part at the top, and only 1
reference to localhost unless you are creating Virtual hosts.

I would suggest removing the ::1 line

BR

Gavin

On Fri, Jan 7, 2011 at 4:18 AM, michael manning
michaelgmann...@gmail.comwrote:

 Hi,

 I swapped out 'localhost for '127.0.0.1' in the url but this had no
 effect.

 I had a look at my hosts file at c:\windows\system32\drivers\etc and this
 contained:

 # Copyright (c) 1993-2006 Microsoft Corp.
 #
 # This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
 #
 # This file contains the mappings of IP addresses to host names. Each
 # entry should be kept on an individual line. The IP address should
 # be placed in the first column followed by the corresponding host name.
 # The IP address and the host name should be separated by at least one
 # space.
 #
 # Additionally, comments (such as these) may be inserted on individual
 # lines or following the machine name denoted by a '#' symbol.
 #
 # For example:
 #
 #  102.54.94.97 rhino.acme.com  # source server
 #   38.25.63.10 x.acme.com  # x client host

 127.0.0.1   localhost
 ::1 localhost

 and so this seems fine as well.

 cheers

 Mike

 On Fri, Jan 7, 2011 at 1:25 PM, Daniel Brown danbr...@php.net wrote:

  On Thu, Jan 6, 2011 at 21:12, michael manning michaelgmann...@gmail.com
 
  wrote:
   Hi Daniel,
   When testing with the CLI, netstat shows:
  [snip!]
 
 What happens when you swap out 'localhost' for '127.0.0.1' in the
  connection routine?  If that works, check to make sure your hosts file
  properly designates 127.0.0.1 as 'localhost' (by editing
  c:\windows\system32\drivers\etc\hosts I believe been a while since
  I've done it on Windows).
 
  --
  /Daniel P. Brown
  Network Infrastructure Manager
  Documentation, Webmaster Teams
  http://www.php.net/
 




-- 
Best regards,

Gavin C


[PHP-DB] PHP.ini file

2011-04-30 Thread Gavin Chalkley
Afternoon all.

I have a dev server using XAMPP, and am wondering if somone could
point how to add a custom php.ini file?

I have the ability to do this on the live server but am unsure how to
make this read on the dev server?

-- 
Best regards,

Gavin C

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



Re: [PHP-DB] PHP.ini file

2011-05-02 Thread Gavin Chalkley
Is there no way of setting unique .ini?

As I am running multi Dev sites from Xampp, of which require different
includes and other settings

On 2 May 2011 18:31, Barry Stear bst...@gmail.com wrote:
 You just need to update the php.ini file that you have making any changes
 necessary. I would suggest making a backup of your existing php.ini file
 first.

 Regards,

 Barry

 On Sat, Apr 30, 2011 at 4:27 AM, Gavin Chalkley gavin.chalk...@gmail.com
 wrote:

 Afternoon all.

 I have a dev server using XAMPP, and am wondering if somone could
 point how to add a custom php.ini file?

 I have the ability to do this on the live server but am unsure how to
 make this read on the dev server?

 --
 Best regards,

 Gavin C

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




 --
 a href=http://www.c28.com/?adid=stiid=19467;
 img src=http://www.c28.com/images/banner_88x31.gif; border=0 width=88
 height=31/a




-- 
Best regards,

Gavin C

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



Re: [PHP-DB] ORDER BY DESC

2011-06-20 Thread Gavin Chalkley
Chris,

Try this:

http://dev.mysql.com/doc/refman/5.0/en/order-by-optimization.html

On 20 June 2011 20:56, Chris Stinemetz chrisstinem...@gmail.com wrote:

 I have the bellow sql query. What is the correct way to add ORDER BY
 posts.post_date DESC

 I would like to add it to the end of my query, but I am just getting a
 blank page or my added query doesn't work echo:

 The posts could not be displayed, please try again later.

 The query is:

//fetch the posts from the database
$posts_sql = SELECT
posts.post_store,
posts.post_content,
posts.post_date,
posts.post_by,
users.user_id,
users.user_name
FROM
posts
LEFT JOIN
users
ON
posts.post_by =
 users.user_id
WHERE
posts.post_store =  .
 mysql_real_escape_string($_GET['id']);



 Thank you in advance for your help.

 Chris

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




-- 
Best regards,

Gavin C


Re: [PHP-DB] Insert query error

2011-08-06 Thread Gavin Chalkley

Chris,

Why not escape, and extract the data prior to Insert string?

On 06/08/2011 05:41, Chris Stinemetz wrote:

I am getting the following error trying to run the below query. Any
suggestions on what I am doing wrong?

Thank you,

Something went wrong while inserting your store visitCannot add or
update a child row: a foreign key constraint fails (`store`.`posts`,
CONSTRAINT `posts_ibfk_1` FOREIGN KEY (`post_store`) REFERENCES
`stores` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE)

$sql = INSERT INTO
posts(market, type, post_store, post_tptest, post_content, post_by, post_date)
VALUES(' . mysql_real_escape_string($_POST['market']) . ',
' . mysql_real_escape_string($_POST['type']) . ',
' . mysql_real_escape_string($_POST['post_store']) . ',   
  
' . sha1($_POST['post_tptest']) . ',
' . mysql_real_escape_string($_POST['post_content']) . ',
   . $_SESSION['user_id'] . ,
  NOW());



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



Re: [PHP-DB] Learning bound variables ??

2011-08-29 Thread Gavin Chalkley

Dian,

I appreciate what it does and understand the redirect.

What I am more refering to is the manner to which it is written

On 29/08/2011 12:02, dian.armstr...@gmail.com wrote:

It's redirect script on php. Cmiiw
--Original Message--
From: Gavin Chalkley
To: php-db@lists.php.net
Subject: [PHP-DB] Learning bound variables ??
Sent: Aug 29, 2011 5:45 PM

Afternoon all.

I am learning the base php at the moment and have come across scripting
that has the following examples:

|header(Location: .$this-referrer);

Could someone point me in a direction to learn about this osrt of thing?

Or could some explain?

Best regards,

Gavin||
|



Powered by Telkomsel BlackBerry®


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



Re: [PHP-DB] Learning bound variables ??

2011-08-29 Thread Gavin Chalkley

Amit,

Many thanks for the explaination.

Is there a good book, or site to look at to learn this Object oriented 
variable way of working?


Is it a cleaner way to work? Or does it over complicate things?

On 29/08/2011 14:53, Amit Tandon wrote:

Dear Gevin

I believe, u wish to understand about $this-...

Actually this is object oriented way of writing the variable. Here 
this is a key word and refers to the this instance of the object.


In simpler words if 2 different sessions are calling this line, then 
each will pass on the value of reffer variable it has stored.


In non object syntax it would be written as
header(Location: . $referrer)

regds
amit

The difference between fiction and reality? Fiction has to make sense.


On Mon, Aug 29, 2011 at 4:33 PM, Gavin Chalkley 
gavin.chalk...@gmail.com mailto:gavin.chalk...@gmail.com wrote:


Dian,

I appreciate what it does and understand the redirect.

What I am more refering to is the manner to which it is written

On 29/08/2011 12:02, dian.armstr...@gmail.com
mailto:dian.armstr...@gmail.com wrote:

It's redirect script on php. Cmiiw

--Original Message--
From: Gavin Chalkley
To: php-db@lists.php.net mailto:php-db@lists.php.net
Subject: [PHP-DB] Learning bound variables ??
Sent: Aug 29, 2011 5:45 PM

Afternoon all.

I am learning the base php at the moment and have come across
scripting
that has the following examples:

|header(Location: .$this-referrer);

Could someone point me in a direction to learn about this osrt
of thing?

Or could some explain?

Best regards,

Gavin||
|



Powered by Telkomsel BlackBerry®


-- 
PHP Database Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] Mysqli_escape

2011-09-01 Thread Gavin Chalkley

Hey all,

Just a quick question about escaping.

Is it good practise to strip tags and trim prior to escaping? or is this 
just over the top?


Cheers

Gavin C

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



[PHP-DB] Prepared Statements

2011-11-15 Thread Gavin Chalkley

Hi all,

I am struggerling with a prepared statement (may not even be suited)


$stmt = $db-stmt_init();

if($stmt-prepare(SELECT title,live,where FROM content))
{

$stmt-bind_param('sii',$t,$l,$w);

## This bit here

$stmt-execute();
$stmt-bind_result($title, $live, $where);

while($stmt-fetch())
{
echo $title\t -\t $live\t -\t $where;
}

$stmt-close();
}

How can i get the data i want to select into variables in this scenario 
(title and Live and where)?


BR,

Gavin

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



RE: [PHP-DB] PHP Database Problems

2012-05-02 Thread Gavin Chalkley
Ethan,

Some coding you are using would be helpful (as far as i am aware attachments
are not support on the mailing list's)

Gav

-Original Message-
From: Ethan Rosenberg [mailto:eth...@earthlink.net] 
Sent: 02 May 2012 19:54
To: php-db-lists.php.net; php-gene...@lists.php.net
Subject: [PHP-DB] PHP  Database Problems

  have a database

mysql describe Intake3;
++-+--+-+-+---+
| Field  | Type| Null | Key | Default | Extra |
++-+--+-+-+---+
| Site   | varchar(6)  | NO   | PRI | |   |
| MedRec | int(6)  | NO   | PRI | NULL|   |
| Fname  | varchar(15) | YES  | | NULL|   |
| Lname  | varchar(30) | YES  | | NULL|   |
| Phone  | varchar(30) | YES  | | NULL|   |
| Height | int(4)  | YES  | | NULL|   |
| Sex| char(7) | YES  | | NULL|   |
| Hx | text| YES  | | NULL|   |
++-+--+-+-+---+
8 rows in set (0.00 sec)

mysql describe Visit3;
++--+--+-+-++
| Field  | Type | Null | Key | Default | Extra  |
++--+--+-+-++
| Indx   | int(4)   | NO   | PRI | NULL| auto_increment |
| Site   | varchar(6)   | YES  | | NULL||
| MedRec | int(6)   | YES  | | NULL||
| Notes  | text | YES  | | NULL||
| Weight | int(4)   | YES  | | NULL||
| BMI| decimal(3,1) | YES  | | NULL||
| Date   | date | YES  | | NULL||
++--+--+-+-++

and a program to enter and extract data.

I can easily extract data from the database. However, if I try to enter
data, it goes into the incorrect record.  Following are some screenshots.
The program is attached.  [pardon the comical names.  This is a test, and
any resemblance to true names is not intentional]

Let us say that I wish to deal with Medical Record 1:


This it data from Intake3:
Site Medical Record First Name Last Name Phone Height Sex History AA 1
David Dummy 845 365-1456 66 Male c/o obesity. Various treatments w/o success

This is data from Visit3:
Index Site Medical Record Notes Weight BMI Date
2322 AA 1 Second Visit. 170 27.4 2010-01-20
2326 AA 1 Third visit. Small progress, but pt is very happy. 165
26.6 2010-02-01


I then request to enter additional data:

Site Medical Record First Name Last Name Phone Height Sex History
AA 10003 Stupid Fool 325 563-4178 65 Male Has been convinced by his 
friends that he is obese. Normal BMI = 23.
Index Site Medical Record Notes Weight BMI Date

Notice that it is entered into record 10003

The data is First Try

Index Site Medical Record Notes Weight BMI Date
2590 AA 10003 First Try 189 31.4 02 May 2012

Help and advice, please.

Thanks.

Ethan



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



RE: [PHP-DB] [PHP] PHP Database Problems -- Code Snippets - Any more Ideas?

2012-05-04 Thread Gavin Chalkley
Ethan,

You have been given advise and break down on your code.

Have you taken the advise given?

Which part of the code isn't working? Not which chunk, but break it down and
show which part

BR,

Gav

-Original Message-
From: Ethan Rosenberg [mailto:eth...@earthlink.net] 
Sent: 04 May 2012 15:10
To: php-db-lists.php.net; php-gene...@lists.php.net
Subject: [PHP-DB] [PHP] PHP  Database Problems -- Code Snippets - Any more
Ideas?

I am sending this again to see if more ideas for solution of this problem
are available.

Ethan
===
Dear list -

Sorry for the attachment.  Here are code snippets ---

GET THE DATA FROM INTAKE3:

 function handle_data()
 {
global $cxn;
$query = select * from Intake3 where  1;



if(isset($_Request['Sex']) trim($_POST['Sex']) != '' )
{
 if ($_REQUEST['Sex'] === 0)
 {
$sex = 'Male';
 }
 else
 {
$sex = 'Female';
 }
}

 }

 $allowed_fields = array
(  'Site' =$_POST['Site'], 'MedRec' = $_POST['MedRec'], 'Fname' =
$_POST['Fname'], 'Lname' = $_POST['Lname'] ,
  'Phone' = $_POST['Phone'] , 'Sex' = $_POST['Sex']  ,
'Height' = $_POST['Height']  );

 if(empty($allowed_fields))
 {
   echo ouch;
 }

 $query = select * from Intake3  where  1 ;

 foreach ( $allowed_fields as $key = $val )
 {
if ( (($val != '')) )

 {
$query .=  AND ($key  = '$val') ;
 }
$result1 = mysqli_query($cxn, $query);
 }

 $num = mysqli_num_rows($result1);
 if(($num = mysqli_num_rows($result1)) == 0)
 {
?
 br /br /centerbp style=color: red; font-size:14pt; No
Records Retrieved #1/center/b/style/p ?php
 exit();
 }

DISPLAY THE INPUT3 DATA:

  THIS SEEMS TO BE THE ROUTINE THAT IS FAILING 

 centerbSearch Results/b/centerbr /

 centertable border=4 cellpadding=5 
cellspacing=55  rules=all  frame=box
 tr class=\heading\
 thSite/th
 thMedical Record/th
 thFirst Name/th
 thLast Name/th
 thPhone/td
 thHeight/td
 thSex/td
 thHistory/td
 /tr

?php

while ($row1 = mysqli_fetch_array($result1, MYSQLI_BOTH))
{
 print_r($_POST);
global $MDRcheck;
$n1++;
echo br /n1 br /;echo $n1;
 {
if (($n1  2)  ($MDRcheck == $row1[1]))
{
 echo 2==  ;
 echo $MDRcheck;
 echo td $row1[0] /td\n;
 echo td $row1[1] /td\n;
 echo td $row1[2] /td\n;
 echo td $row1[3] /td\n;
 echo td $row1[4] /td\n;
 echo td $row1[5] /td\n;
 echo td $row1[6] /td\n;
 echo td $row1[7] /td\n;
 echo /tr\n;
}
elseif (($n1  2)  ($MDRcheck != $row1[1]))
{
 echo 2!=  ;

 echo $MDRcheck;


 continue;
}
elseif ($n1 == 2)
{

 define( MDR ,  $row1[1]);
 echo br /row1 br;echo $row1[1];
 echo tr\n;

 $_GLOBALS['mdr']= $row1[1];
 $_POST['MedRec'] = $row1[1];
 $MDRold = $_GLOBALS['mdr'];
 echo td $row1[0] /td\n;
 echo td $row1[1] /td\n;
 echo td $row1[2] /td\n;
 echo td $row1[3] /td\n;
 echo td $row1[4] /td\n;
 echo td $row1[5] /td\n;
 echo td $row1[6] /td\n;
 echo td $row1[7] /td\n;
 echo /tr\n;
}

 }
}

?

SELECT AND DISPLAY DATA FROM VISIT3 DATABASE

?php
 $query2 = select * from Visit3 where  1 AND (Site = 'AA')  AND (MedRec
= $_GLOBALS[mdr]);
 $result2 = mysqli_query($cxn, $query2);
 $num = mysqli_num_rows($result2);


 global $finished;
 $finished = 0;


 while($row2 = mysqli_fetch_array($result2, MYSQLI_BOTH))
 {
global $finished;
echo tr\n;
echo td $row2[0] /td\n;
echo td $row2[1] /td\n;
echo td $row2[2] /td\n;
echo td $row2[3] /td\n;
echo td $row2[4] /td\n;
echo td $row2[5] /td\n;
echo td $row2[6] /td\n;
echo /tr\n;

 }

echo /table;

ENTER MORE DATA:

 function More_Data()
 {
$decision = 5;
?

 Do you Wish to Enter More Data?
 form method=post action=
 centerinput type=radio name=decision value=1 /Yes 
input type=radio name=decision value=0 /No/centerbr /
 centerinput type=submit value=Enter more Data //center
 input type=hidden name=next_step value=step10 /
  /form

?php
 } //end 

RE: [PHP-DB] Multiple Database Connection Using Prepard Statements

2012-05-20 Thread Gavin Chalkley
Just remember to close the correct connection whn it is time to :)

-Original Message-
From: Matijn Woudt [mailto:tijn...@gmail.com] 
Sent: 19 May 2012 23:42
To: Ron Piggott
Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] Multiple Database Connection Using Prepard Statements

On Sat, May 19, 2012 at 8:36 PM, Ron Piggott ron.pigg...@actsministries.org 
wrote:

 How do I connect to multiple mySQL databases using Prepared Statements ?

 I have the syntax

 ===
 $dsh = 'mysql:host=localhost;dbname='.$database3;
 $dbh = new PDO($dsh, $username, $password); ===

 I want to connect to $database1 without loosing my $database3 
 connection


$dsh = 'mysql:host=localhost;dbname='.$database3;
$dbh = new PDO($dsh, $username, $password);
$dsh2 = 'mysql:host=localhost;dbname='.$database1;
$dbh2 = new PDO($dsh2, $username2, $password2);

Now you can use $dbh for $database3, and $dbh2 for $database1...

- Matijn

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


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



Re: [PHP-DB] Saving Image in mySQL

2013-03-20 Thread Gavin Chalkley
I am with Karl on this.

Storing an image in the db is very heavy on lpad times.

Upload the image to a folder with name saved with location
On Mar 19, 2013 11:12 PM, Karl DeSaulniers k...@designdrumm.com wrote:

 Hey Ron,
 I don't know how others feel, but I say save yourself a headache and dont
 store the image data, just the url to the image on the server.

 image_url – VARCHAR 100

 Best,
 Karl



 On Mar 19, 2013, at 3:15 PM, Ron Piggott wrote:


 Hi All
 I don’t understand how to save an image to a mySQL table based on the
 following form. I am trying to do this using Prepared Statements.  All the
 fields except the image file itself save in the database.  Right now I have
 $file as the variable when binding the values.  What should it be?  Ron

 ===
 form action=add_my_image.php method=post
 enctype=multipart/form-data
 label for=fileFilename:/label
 input type=file name=filebr
 input type=submit name=submit value=submit
 /form
 ===

 mySQL table structure:
 ===
 reference – INT 10 auto_increment primary
 caption – VARCHAR 250
 image_type – VARCHAR 100
 image_size – INT 10
 image_name – VARCHAR 100
 image – LONGBLOB
 ===

 Prepared Statement:

 ===
 # mySQL query

$query = INSERT INTO `my_images` ( `reference` , `caption` ,
 `image_type` , `image_size` , `image_name` , `image` ) VALUES ( NULL ,
 :caption , :image_type , :image_size , :image_name , :image );;

 # apply query to Prepared Statement

if($stmt = $dbh-prepare( $query )) {

 # bind variables

$stmt-bindValue(':caption', 'Test Caption', PDO::PARAM_STR);
$stmt-bindValue(':image_type'**, $_FILES[file][type],
 PDO::PARAM_STR);
$stmt-bindValue(':image_size'**, $_FILES[file][size],
 PDO::PARAM_INT);
$stmt-bindValue(':image_name'**, $_FILES[file][name],
 PDO::PARAM_STR);
$stmt-bindValue(':image', $file, PDO::PARAM_STR);

 # execute query

if ( $stmt-execute() or die(print_r($stmt-errorInfo()**,
 true)) ) {

 # retrieve auto_increment value

$new_record_reference = $dbh-lastInsertId();

}

}
 ===


 Ron Piggott



 www.TheVerseOfTheDay.info


 Karl DeSaulniers
 Design Drumm
 http://designdrumm.com


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