Re: [PHP-DB] One query, different tables?

2013-08-09 Thread Niel Archer
 Hello.
 I am newbie in this and need som basic help.
 
 I have a form witch checkbox'es with different serialnumbers.
 The serialnumbers reflect different products and every product category
 have their own tables.

This sounds like a database design question more than a PHP one.

 
 I can transfer items from store to truck but can't transfer them back to
 store.
 I have 4 stores and like to transfer products between this.
 
 I like to to it like this:
 store_one - truck_document - store_two
 
 But how can I transfer both Dynamite and Exan in one query to their
 respective tables? (One table is named exan and the other dynamite.)
 
 Thank you very much for your help.
 
 I have been searching google but can't find anything about this question.
 
 Karl

--
Niel Archer
niel.archer (at) blueyonder.co.uk


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



Re: [PHP-DB] PDO Exceptions

2013-04-25 Thread Niel Archer
 Greetings,
 
 I am new to this list. I have a question about which functions need to be 
 included in a try block. 
 
 Of new PDO, prepare, bindParam, execute, fetch, and query, it 
 seems that bindParam is the only one that throws an exception. So is this the 
 only that needs to be put into a try block?
 
 Thanks,
 
 -KJW
 Proverbs 3:5-6

Are you aware that there is a setting to control whether PDO objects throw
exceptions, warnings, or nothing? By default it does nothing except set
the error code and message.

See http://uk3.php.net/manual/en/pdo.error-handling.php

--
Niel Archer
niel.archer (at) blueyonder.co.uk


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



Re: [PHP-DB] Activating the mysql_clear_password plugin

2012-09-27 Thread Niel Archer
 Hi everyone,
 
 I need to use the mysql_clear_password plugin.
 I'm using the CentOS php 5.3.3 and manually recompiled the mysql  
 mysqli extensions with the Oracle MySQL 5.5 libraries.
 
 According to the MySQL documentation ( 
 http://dev.mysql.com/doc/refman/5.5/en/cleartext-authentication-plugin.html), 
 I need to either set the LIBMYSQL_ENABLE_CLEARTEXT_PLUGIN or set the 
 MYSQL_ENABLE_CLEARTEXT_PLUGIN option to the mysql client.
 
 I tried to set the LIBMYSQL_ENABLE_CLEARTEXT_PLUGIN via a SetEnv in 
 Apache with no results.

The SetEnv directive sets variables for Apache's internal environment.the
 I believe the MySQL docs are refering to the Operating System's
environment, which would set this globally for the MyQL server. This is
probably not what you want to do as you appear to be trying to do this
per connection.

You could try using mysqli_options(), but I do not know if that supports
this setting yet. The PHP documentation does not mention it, and I am
unable to test it myself at the moment.

 Could anyone help me setting the MYSQL_ENABLE_CLEARTEXT_PLUGIN option to 
 the mysql client ?
 
 Regards,
 
 Pierre-Gildas MILLON
 pg.mil...@gmail.com
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

--
Niel Archer
niel.archer (at) blueyonder.co.uk


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



Re: [PHP-DB] Activating the mysql_clear_password plugin

2012-09-27 Thread Niel Archer
Hi
 
 You could try using mysqli_options(), but I do not know if that supports
 this setting yet. The PHP documentation does not mention it, and I am
 unable to test it myself at the moment.

Just occured to me, even if the setting is not directly supported yet, you
can create a separate configuration file for this setting the client to
use the plugin (enable-cleartext-plugin) then:

mysqli_options(MYSQLI_READ_DEFAULT_FILE,'myother.cnf');

to use those settings on the connection.


--
Niel Archer
niel.archer (at) blueyonder.co.uk


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



Re: [PHP-DB] Storing multiple items in one MySQL field?

2012-01-18 Thread Niel Archer
/no-image-logo.png';
   }
   
   $row['cart_url'] = WEB_ROOT.cart.php?action=addp=.$pdId.;
   
   return $row;
 }
 
 TIA
 
 Karl DeSaulniers
 Design Drumm
 http://designdrumm.com
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

--
Niel Archer
niel.archer (at) blueyonder.co.uk


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



Re: [PHP-DB] Receiving Error- Error: user account already exists..

2012-01-10 Thread Niel Archer
 I keep receiving the following error..( Error: user account already exists..
 ) although I don't have any data in my table. Any help would be appreciated.
 
 The code follows:
 
  
 
  
 
 ?php 
 
 session_start();
 
  
 
  
 
 include ('dbc.php'); 
 
  
 
  
 
  
 
 if (isset($_POST['Submit']) =='Register')

As Jim already pointed out, if $_POST['Submit'] is set to ANY value this
check will be true. I think you want something like :

if (isset($_POST['Submit'])  $_POST['Submit'] =='Register')

 {
if (strlen($_POST['email'])  5)
{
 die (Incorrect email. Please enter valid email address..);
 }

if (strcmp(isset($_POST['pass1']),isset($_POST['pass2'])) ||
 empty($_POST['pass1']) )
 { 
 //die (Password does not match);
 die(ERROR: Password does not match or empty..);
 }
 
 if (strcmp(md5($_POST['user_code']),$_SESSION['ckey']))
 { 
  die(Invalid code entered.
 Please enter the correct code as shown in the Image);
   } 
 
 $rs_duplicates = mysql_query(select id from users where
 user_email='$_POST[email]');

You should test $rs_duplicates !== false to be sure you have a valid
resource.

Have you tried retrieving the supposed row(s) and var_dump-ing them to
see what it thinks they are? My guess is, you're getting an error
message, which is why there is a row to be counted. You can't use an
array inside a double-quoted string like that, change it to be wrapped
in braces like:

 $rs_duplicates = mysql_query(select id from users where user_email='
{$_POST[email]}');


--
Niel Archer
niel.archer (at) blueyonder.co.uk


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



Re: [PHP-DB] problem in connecting to mysql from php

2011-06-14 Thread Niel Archer

 Hello everyone,
 
 I am in the process of learning php and I was trying to connect to a mysql
 database on my own computer(localhost). I have done the following as
 prerequisites:
 
 copied the dll files in system32
 removed the semicolon(;) from extension=php_mysqli.dll

You should NOT need to move the .dll at all. There is a
setting in the ini which tells PHP where to look for extensions and that
should have pointed to the original location. Hence, removing the
semicolon should be the only part necessary.

 In spite of doing the above when I try to run the following :
 
 ?php
 $db = new MySQLi('localhost', 'root', 'Password123', 'test');
 $sql = 'SELECT * FROM a123';
 $result = $db-query($sql);
 
 while($row = $result-fetch_object()) {
 echo 'div' . $row-name . '/div';
 }
 
 $db-close();
 ?
 
 I get the error: *Fatal error*: Class 'MySQLi' not found in *C:\Program
 Files\Apache Software Foundation\Apache2.2\htdocs\a.php* on line *2
 
 *Please guide me as to how can I get rid of this error?
 
 Regards,
 Kushal



--
Niel Archer
niel.archer (at) blueyonder.co.uk


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



Re: [PHP-DB] mysql_query

2011-06-06 Thread Niel Archer
 Hello all,
 
 Not sure what I am doing wrong.
 
 I have a simple form that populate the variables in a mysql query. I
 know the selected values are making it to the form porcessing script
 because I can echo them on the processing script as indicated below.
 
 You Selected Cell_Sect = 1_1
 You Selected Date = 03/10/11 18:15
 You Selected Market = MCI
 
 For some reason the above is all I am getting when I submit my form.
 
 I beleive it has somthing to do with my results query below.
 
 $result = mysql_query(select * FROM evdo WHERE Market like '%$term'
 and Cell_Sect = '$cat' and Date = '$subcat' LIMIT 10);
 
 Beow is my whole script for processing the form in case it maybe something 
 else.
 
 Thanks,
 
 Chris
 
 
 !doctype html public -//w3c//dtd html 3.2//en
 
 html
 ?php
 
 // database access parameters
 $dbservertype='mysql';
 $servername= left out for privacy;
 // username and password to log onto db server
 $dbusername='';
 $dbpassword='';
 // name of database
 $dbname='pcmd';
 
 connecttodb($servername,$dbname,$dbusername,$dbpassword);
 function connecttodb($servername,$dbname,$dbuser,$dbpassword)
 {
 global $link;
 $link=mysql_connect ($servername,$dbuser,$dbpassword);
 if(!$link){
 die('Could not conect: ' . mysql_error());
 }
 echo 'YOU ARE CONNECTED TO PCMD DATABASE';
 
 mysql_select_db($dbname,$link) or die (could not open db.mysql_error());
}  - What's this doing here
  End of connecting to database 
 ?
 !!DOCTYPE HTML PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'
 'http://www.w3.org/TR/xhtml1-transitional.dtd'
 head
 titleDemo Multiple drop down list box for PCMD data/title
 style type=text/css 
   TABLE {
  border: 1px solid #98bf21;
  border-collapse:collapse;
   }
 
   TH {
  border: 1px solid #98bf21;
  padding-bottom: 4px;
  padding-left: 7px:
  padding-right: 7px;
  padding-top: 5px;
  font-size: 1.2em;
  background-color:limegreen;
  color: white;
  text-align: left;
   }
 
   TD {
  border: 1px solid #98bf21;
  padding-bottom: 2px;
  padding-left: 7px:
  padding-right: 7px;
  padding-top: 3px;
  font-size: 1.0em;
   }
 
   TR.alt TD {
   background-color: #eaf2d3;
 
   }
 
 /style
 meta name=GENERATOR content=Arachnophilia 4.0
 meta name=FORMATTER content=Arachnophilia 4.0
 /head
 
 body
 ?php
 $cat=$_POST['cat'];
 $subcat=$_POST['subcat'];
 $term=$_POST['term'];
 
 $result = mysql_query(select * FROM evdo WHERE Market like '%$term'
 and Cell_Sect = '$cat' and Date = '$subcat' LIMIT 10);
 
 
 $firstRow=1;
 $rowNum = 0;
 echo table;
 while($row = mysql_fetch_assoc($result)) {
if($firstRow == 1) {
   echo tr;
 
   foreach($row as $key = $value) {
   echo th . $key . /th;
   }
   echo /trtr;
   $firstRow=0;
   $rowNum++;
}
else {
   if(  ($rowNum++ % 2) == 1) {
  echo tr class=\alt\;
   } else {
  echo tr;
   }
}
foreach($row as $key = $value ) {
echo td . $value . /td  ;
}
echo /tr;
 }
 echo /table;
 
 echo You Selected Cell_Sect = $cat brYou Selected Date =
 $subcatbrYou Selected Market = $term;
 
 
 ?
 
 /body
 
 /html
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

After your mysql_select_db() there is a closing brace without matching
open. This will be causing an error in that php block.

--
Niel Archer
niel.archer (at) blueyonder.co.uk


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



Re: [PHP-DB] Can't find sqlite_open

2011-01-08 Thread Niel Archer
 Hello,
 I have a script that is calling sqlite_open, however, sqlite_open can't be 
 found on my systems. I'm running RHEL5 and I get the following relevant 
 output from php -i:
 
 PDO support = enabled
 PDO drivers = odbc, sqlite
 
 pdo_sqlite
 
 PDO Driver for SQLite 3.x = enabled
 PECL Module version = 1.0.1 $Id: pdo_sqlite.c,v 1.10.2.6 2006/01/01 
 12:50:12 sniper Exp $
 SQLite Library = 3.3.6
 
 From searching around, it seems like there is a PDO version, which looks to 
 be enabled here, and a older version, which would provide sqlite_open. Is 
 that correct?

sqlite_open is not a PDO statement. It belongs to the PECL SQLite
extension. This extension is quite old and is superseded by the SQLite3
extension and/or PDO.


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

--
Niel Archer
niel.archer (at) blueyonder.co.uk



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



Re: [PHP-DB] Re: Word Activity Application

2011-01-03 Thread Niel Archer
 
 The FOREACH below is giving me the error:
 Invalid argument supplied for foreach()

Not surprising as the $match_words will contain a boolean result from
shuffle. Shuffle works directly on the variable it is given and returns
true or false, depending on success. rtfm ;-)

 Does anyone understand what I have done to cause this error?
 
 #query for words
 
 $query = 
 SELECT `reference` , `word` , `explanation` 
 FROM `Bible_dictionary` 
 WHERE `live` =1
 ORDER BY RAND( ) 
 LIMIT 5
 ;
 $words_match_up_result=mysql_query($query);
 $records_found=mysql_numrows($words_match_up_result);
 
 echo $records_found . br; # output is 5
 
 #create array from mySQL query
 
 $words = array();
 $explanations = array();
 
 $i=1;
 while ( $i = $records_found ) {
 
 $words[$i] = stripslashes( mysql_result($words_match_up_result,($i 
 -1),word) );
 $explanations[$i] = stripslashes( mysql_result($words_match_up_result,($i 
 -1),explanation) );
 
 ++$i;
 }
 
 #shuffle arrays
 
 $match_words = shuffle ( $words );
 $match_explanations = shuffle ( $explanations );

change to:
$match_words = $words;
shuffle($match_words);
$match_explanations = $explanations;
shuffle($match_explanations);

However if these need to stay in sync this will not work. i.e if a
explanation's index needs to match the corresponding word's index, then
you'll have to do this another way. But as I understand your need here,
this isn't a problem?

 #display words on the screen
 
 foreach($match_words as $word) {
 
 echo $word . br /\r\n;
 
 }
 
 The Verse of the Day
 “Encouragement from God’s Word”
 http://www.TheVerseOfTheDay.info
 
 
 From: Ron Piggott 
 Sent: Sunday, January 02, 2011 5:54 PM
 To: php-db@lists.php.net 
 Subject: Word Activity Application
 
 
 I am working on a word activity --- matching words and their definitions.  
 
 I want to display 5 words on the left hand side and the 5 definitions on the 
 right hand side.  But I want the definitions displayed in a different order 
 than the words so the user submits their answer.  
 
 Should I use PHP to display the definitions in random order?  OR Is there a 
 way do this in mySQL that would mix and match results from different rows?  
 This is the query gives me the 5 results
 
 SELECT `reference` , `word` , `explanation` 
 FROM `Bible_dictionary` 
 WHERE `live` =1
 ORDER BY RAND( ) 
 LIMIT 5 
 
 Ron
 
 The Verse of the Day
 “Encouragement from God’s Word”
 http://www.TheVerseOfTheDay.info

--
Niel Archer
niel.archer (at) blueyonder.co.uk



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



Re: [PHP-DB] Re: [PHP] Strange Query Error...

2010-11-27 Thread Niel Archer
 On Nov 27, 2010, at 10:08 AM, Daniel P. Brown wrote:
 
  one primary question: are you using the mysql_*
  family, mysqli_* family, or another method of interfacing with MySQL?
 
 mysql_
 
 $results = mysql_query($query) or die(mysql_error());
 
 Don
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
Could you show the actual code, not just the query. The way you are
setting up the query could be affecting it. i.e. using single quotes when
assigning to a variable would not work with your query.

--
Niel Archer
niel.archer (at) blueyonder.co.uk



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



Re: [PHP-DB] If condition in query

2010-11-18 Thread Niel Archer
 Dear list -
 
 Thank you for all your excellent help.
 
 I wish to search a table.  In this case, I have five(5) columns: 
 site, Record, BMI, Weight and Height.
 I wish to be able to search on one or more of the columns.  If I use 
 a query like:
 
 $ste = $_POST['site'];
 $req = $_POST['Record'];
 $wgt = $_POST['Weight'];
 $hgt = $_POST['Height'];
 $bmi = $_POST['BMI'];
 
 $sql1 =  select * from  intake2 where site = '$ste'   Weight = 
 '$wgt'   Record = '$req'   '$hgt' = Height   '$bmi' = BMI ;
 $result = mysqli_query($cxn, $sql1);
 
 and do not use all the  variables, no data is returned.  I use to 
 extract the data from the query.
 
 while($row = mysqli_fetch_array($result[0]))
 
  {
  $site2 = $row[0];
  $record2 = $row[1];
  $bmi2 = $row[2];
  $wgt2 = $row[3];
  $hgt2 = $row[4];
  printf(%s\t%d\t%3.1f\t%d\t%dbr /, $site2, $record2, 
 $bmi2, $wgt2, $hgt2);
  }
 
 
 If I put an extra test in the query to exclude blank values;eg, 
 (if(isset ($bmi)   '$bmi' = BMI ), $result defaults to a boolean 
 and mysqli_fetch_array($result) fails.  I wish to be able to search 
 on one or more, but not necessarily all, of the parameters and be 
 able to output the results.
 
 Advice and help please.
 
 Thanks in advance.
 
 Ethan

First you need to protect your input from injection and other attacks.
http://en.wikipedia.org/wiki/SQL_injection

for the problem you ask, I'd suggest building the query in php rather
than SQL A simple example would be:

$where ' ';
if (isset($ste)) {
$where .=  site = '$ste';
}
if (isset($wgt)) {
$where .= , Weight =  '$wgt';
}

$sql .=  WHERE $where;


--
Niel Archer
niel.archer (at) blueyonder.co.uk


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



Re: [PHP-DB] query help

2010-11-17 Thread Niel Archer
 Hello PHP Gurus,
 
 I need your help on an insert query.
 
 I wanted to know if there is way to insert an array of values into a DB. An
 eg would explain this better :
 
 If I have 2 tables in a DB, 1) users has 3 columns 2) hobbies = 5 columns
 
 I was thinking of having a single function which will perform the insert on
 any  insert which happens on the entire website.
 
 Eg : This function can be called with 2 parameters, the first parameter the
 table name, and the second parameter is an array of values which will be
 inserted into the table.
 eg : Users has these columns [1]ID [2] Name [3]Location
 so the function call would be something like *
 insert_into_tbale(users,array[user_values])*
 **
 Does this make sense ? Is this a good method to follow ?
 
 Thanks in advance !
 
 Vinay Kannan.

You don't give any info about the database engine, but assuming you're
using MySQL  take a look at
http://dev.mysql.com/doc/refman/5.0/en/insert.html
Specifically you can use your idea to build an INSERT/VALUE version of
the syntax

INSERT INTO table (col1, col2, .colN.)  VALUES (col1Value1, col2value1,
colNvalue1),  (col1Value2, col2value2, colNvalue2),  ...


--
Niel Archer
niel.archer (at) blueyonder.co.uk


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



Re: [PHP-DB] Parsing Tab Delimited file

2010-10-24 Thread Niel Archer
 Dear list -
 
 Thanks for all your help.
 
 I have a tab delimited file which I wish to import into a data 
 base.  In MySQL I can use the LOAD DATA command.  As far as I know, 
 that command cannot be used in PHP as a mysqli_query.  As I 
 understand, I have to parse the file and use the INSERT command.

It can be done, IF the MySQL server allows you to do it.. Check the
servers configuration.

 How do I do it?  Code samples, please.
 
 Thanks.
 
 Ethan
 
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

--
Niel Archer
niel.archer (at) blueyonder.co.uk



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



Re: [PHP-DB] Stuck in apostrophe hell

2010-08-02 Thread Niel Archer
 Before I send the following SQL to MySQL from PHP I print it to screen. 
 PHP chokes on it, but I can paste the exact same query from the screen 
 directly to MySQL and it works just fine. For example:
 
 Here's the relevant PHP code:
 ==
 $sql_insert_registration = sprintf(INSERT INTO
   Registrations (
 Class_ID,
 prid,
 Registrant,
 Company,
 Phone,
 Email
   )
 VALUES (
 $_POST[Class_ID],
 $_POST[prid],
 '%s',.
 parseNull($_POST['Company']).,
 '$_POST[Phone]',
 '$_POST[Email]'
 ), mysql_real_escape_string($_POST['Registrant']));
 
 echo pre.$_POST[Registrant]./pre;
 echo pre.mysql_real_escape_string($_POST[Registrant])./pre;
 echo pre.$sql_insert_registration./pre;
 
 if (!mysql_query($sql_insert_registration, $con)) { 
   die('Error: ' . mysql_error()); 
 
 ==
 
 
 Here's the output:
 ===
 
 INSERT INTO
   Registrations (
 Class_ID,
 prid,
 Registrant,
 Company,
 Phone,
 Email
   )
 VALUES (
 355,
 257,
 'Brian O\'Brien',NULL,
 '612-456-5678',
 'paul_s_john...@mnb.uscourts.gov'
 )
 Error: You have an error in your SQL syntax; check the manual that 
 corresponds to your MySQL server version for the right syntax to use near 
 'Brien', 'Class registration confirmation', ' This email ' at line 16
 ==
 
 
 Also very oddly if the name O'Brien is input into the HTML form with two 
 apostrophes side by side (O''Brien) then MySQL will take it (but then of 
 course we have the problem of two apostrophes side by side inserted into 
 the MySQL table). For example:
 
 ===
 
 INSERT INTO
   Registrations (
 Class_ID,
 prid,
 Registrant,
 Company,
 Phone,
 Email
   )
 VALUES (
 355,
 257,
 'Brian O\'\'Brien',NULL,
 '612-456-5678',
 'paul_s_john...@mnb.uscourts.gov'
 )
 You have been signed up for the class,
 and a confirmation email has been sent to you.
 =
 
 Very strange.
 
 I've checked various PHP variables and cannot figure out. It works fines 
 from another PHP server that's using the same MySQL database.
 
 Thanks,
 
 Paul

Probably needs a double backslash for O'Brien. One to escape the
apostrophe and one to escape the backslash escaping the apostrophe. ;-)
This would be because you're not using mysql_real_escape_string() on the
third parameter. Try this (not tested):

$sql_insert_registration = sprintf(INSERT INTO
  Registrations (
Class_ID,
prid,
Registrant,
Company,
Phone,
Email
  )
VALUES (%s, %s, '%s', '%s', '%s', '%s'), 
$_POST[Class_ID],
$_POST[prid],
mysql_real_escape_string(parseNull($_POST['Company'])),
mysql_real_escape_string($_POST[Phone]),
mysql_real_escape_string($_POST[Email]),
mysql_real_escape_string($_POST['Registrant']));


--
Niel Archer
niel.archer (at) blueyonder.co.uk



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



Re: [PHP-DB] Broken query

2010-07-11 Thread Niel Archer
 
 I am trying to write a query to select a trivia question, but I don't want
 the trivia question category to be the same two days in a row so I added a
 second SELECT syntax to find out what category was used yesterday.  This
 works when I test it live, but doesn't work when it is part of a cron
 job.  How do I get the value of `Bible_trivia_category_reference` from the
 second SELECT query to be used in the first?  What change is needed?  Ron
 
 SELECT * FROM `verse_of_the_day_Bible_trivia` WHERE `assigned_date` =
 '-00-00' AND `seasonal_use` = $bible_trivia_application AND `live` =1
 AND NOT `Bible_trivia_category_reference` = ( SELECT
 `Bible_trivia_category_reference` FROM `verse_of_the_day_Bible_trivia`
 WHERE `assigned_date` = '$last_mailing_date' LIMIT 1 ) ORDER BY RAND()
 LIMIT 1

Try changing: AND NOT `Bible_trivia_category_reference` = ( SELECT ...
to AND `Bible_trivia_category_reference` != ( SELECT ...

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

--
Niel Archer
niel.archer (at) blueyonder.co.uk



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



Re: [PHP-DB] deleting rows with composite primary key

2010-05-18 Thread Niel Archer
 Is there a different syntax to the mysql delete statement when the WHERE
 clause points only to half of the primary key?
 
 The structure is as follows:
 CREATE TABLE IF NOT EXISTS ` table1` (
   `id1` int(10) unsigned NOT NULL,
   `id2` int(10) unsigned NOT NULL,
   PRIMARY KEY  (`id1`,`id2`),
   KEY `id2` (`id2`)
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 
 Query is
 $query = DELETE * FROM table1 WHERE id1 = '$recID';;

Integer values do not need to be quoted. You should be able to drop the
semi-colon from the query too.  See if that helps

 Error is a 1064 syntax error.
 
 Any help is appreciated.
 
 Eli
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

--
Niel Archer
niel.archer (at) blueyonder.co.uk



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



Re: [PHP-DB] deleting rows with composite primary key

2010-05-18 Thread Niel Archer
  Is there a different syntax to the mysql delete statement when the WHERE
  clause points only to half of the primary key?
  
  The structure is as follows:
  CREATE TABLE IF NOT EXISTS ` table1` (
`id1` int(10) unsigned NOT NULL,
`id2` int(10) unsigned NOT NULL,
PRIMARY KEY  (`id1`,`id2`),
KEY `id2` (`id2`)
  ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  
  Query is
  $query = DELETE * FROM table1 WHERE id1 = '$recID';;
 
 Integer values do not need to be quoted. You should be able to drop the
 semi-colon from the query too.  See if that helps
 
  Error is a 1064 syntax error.

And try var_dump()ing the complete query to make sure it looks as you
would expect.


  Any help is appreciated.
  
  Eli
  
  
  -- 
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 --
 Niel Archer
 niel.archer (at) blueyonder.co.uk
 
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

--
Niel Archer
niel.archer (at) blueyonder.co.uk



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



Re: [PHP-DB] deleting rows with composite primary key

2010-05-18 Thread Niel Archer
 On Tue, May 18, 2010 at 2:51 PM, Niel Archer n...@chance.now wrote:
   Is there a different syntax to the mysql delete statement when the 
   WHERE
   clause points only to half of the primary key?
  
   The structure is as follows:
   CREATE TABLE IF NOT EXISTS ` table1` (
     `id1` int(10) unsigned NOT NULL,
     `id2` int(10) unsigned NOT NULL,
     PRIMARY KEY  (`id1`,`id2`),
     KEY `id2` (`id2`)
   ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  
   Query is
   $query = DELETE * FROM table1 WHERE id1 = '$recID';;
 
  Integer values do not need to be quoted. You should be able to drop the
  semi-colon from the query too.  See if that helps
 
   Error is a 1064 syntax error.
 
  And try var_dump()ing the complete query to make sure it looks as you
  would expect.
 
 
   Any help is appreciated.
  
   Eli
  
  
   --
   PHP Database Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
 
  --
  Niel Archer
  niel.archer (at) blueyonder.co.uk
 
 
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
  --
  Niel Archer
  niel.archer (at) blueyonder.co.uk
 
 
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 The syntax should be
 
 DELETE FROM table1 WHERE id1 = '$recID';;
 
 No need for the *

DOH! How did I miss that? Must be time for bed!

 -- 
 
 Bastien
 
 Cat, the other other white meat
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

--
Niel Archer
niel.archer (at) blueyonder.co.uk



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



Re: [PHP-DB] PDO + The Role of PHP + SQLite - Am I missing something?

2010-05-11 Thread Niel Archer
. Use the SQLite3 extension; which is
installed by default with PHP 5.3.0.
As noted on the installation instructions for the extension:

Note: This extension was briefly a PECL extension but that version is
only recommended for experimental use.  

So avoid it like the plague and stick with the main extension ;-)
 
 Where do I get involved to help improve the situation?
 
 All the best,
 Lawrance.
 
 Any intelligent fool can make things bigger and more complex...
 It takes a touch of genius - and a lot of courage to move in the
 opposite direction. - Albert Einstein
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

--
Niel Archer
niel.archer (at) blueyonder.co.uk



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



Re: [PHP-DB] PDOException: could not find driver (postgres)

2010-04-22 Thread Niel Archer
 What could be causing this please? Going direct, using pg_connect, is
 not a problem.

Seems like a simple missing driver problem.  Make sure you have the PDO
postgres driver enabled in your php.ini, it does not use the same driver
as the Postgres extension.

 The code in question looks like
 $pdo = new PDO('pgsql:host=localhost;port=5432;dbname=mydb', 'dbuser',
 'dbpass');
 (I think - I've yet to be able to debug it down to a single line)



--
Niel Archer
niel.archer (at) blueyonder.co.uk



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



Re: [PHP-DB] include_path in appache.conf

2010-04-05 Thread Niel Archer
Try asking on the general list. This is not Db related at all, so your
chances of getting answers here are pretty slim.

 This may be an apache question but I'd like to find the php answer first 
 if one exists.
 
 I have several virtual hosts on a dedicated server. 
 In a IFmodule mod_php5c container in an httpd.conf  include file I have 
 the following to create a unique include path for each virtual host:
 
 IfModule mod_php5.c
   php_value include_path .:/home/virtual/site#/path/to/include
   php_admin_flag safe_mode off
 /IfModule
 
 For one of the virtual hosts I've set up a dev site in a subdomain at 
 dev.site#.com for development.
 In the root directory of this development site I have an .htacces file 
 to create another unique include_path solely for this development subdomain.
 
 php_value include_path  .:/home/virtual/site#/path/to/dev/includes
 
 Also in the httpd.conf I have
 Directory /home/virtual/site#/path/to/dev/root/
 Allow from all
 AllowOverride All
 Order allow,deny
 /Directory
 
 
 The configuration is CentOS 5.3, Apache/2.2.3, PHP 5.1.6
 
 I recently upgraded the OS from FC6 and the PHP version and I have not 
 been able to get the include_path to change for this dev.subdomain.  
 Even after restarting apache it PHPinfo tells me it is reading the 
 server php.ini and the virtual host include path for the httpd.conf but 
 it is ignoring the .htaccess file. 
 
 I've even tried putting the php.ini with specific settings in the 
 /home/virtual/site#/root directory to no avail.
 
 Any ideas how to make this work or even a better set up?
 
 Thanks in advance.
 
 
 
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

--
Niel Archer
niel.archer (at) blueyonder.co.uk



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



Re: [PHP-DB] PDO include table name prefixes in FETCH_ASSOC

2010-03-24 Thread Niel Archer
 Many of my MySQL tables have columns with the same name.  I want to have 
 PDO include table names in named result sets.  For example:
 
$sth = $dbh-prepare(SELECT * FROM table0, table1);
$result = $sth-fetchAll(PDO::FETCH_ASSOC);
 
 
 I want $result to be organized like:
 
echo $result[table0.column0];
echo $result[table0.column1];
echo $result[table1.column0];
echo $result[table1.column1];
 
 
 Or, alternatively:
 
echo $result[table0][column0];
echo $result[table0][column1];
echo $result[table1][column0];
echo $result[table1][column1];
 
 
 Any ideas?  Thanks!

Sounds like you want to UNION two SELECTs
http://dev.mysql.com/doc/refman/5.0/en/union.html

(SELECT col1, col2, col4 FROM table1 WHERE ... ORDER BY ...)
UNION
(SELECT col1, col2, col4 FROM table2 WHERE ... ORDER BY ...)


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

--
Niel Archer
niel.archer (at) blueyonder.co.uk



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



Re: [PHP-DB] Help for a beginner

2009-12-23 Thread Niel Archer
Hi

 Hi everyone, first thank you for ALL help and the understanding that I am new 
 to PHP and MySQL. This is a long email and for that I apologize but I am 
 trying to provide as much detail as possible. If this is the wrong list to 
 ask for help, kindly direct me to the proper authority.
 
 I am trying to learn and I have built the following environment.
 
 Windows Server 2008 Standard 32bit service Pack 2 with IIS7
 mysql-essential-5.1.41-win32
 php-5.3.1-nts-Win32-VC9-x86.msi
 phpMyAdmin-3.2.4-english.zip
 
 
 I followed the steps as detailed below (I already had IIS7 and CGI installed)
 
 
 1. Install CGI  PHP
http://www.trainsignaltraining.com/iis-7-install-fastcgi-php/2008-09-04/
 
 2. Install MySQL
http://www.trainsignaltraining.com/install-mysql-on-iis7/2008-09-10/

 3. Install PHPMyAdmin

 http://www.trainsignaltraining.com/install-phpmyadmin-on-iis7-and-server-2008/2008-09-16/

This is a bit vague on details. In particular, when installing PHP did
you add the required extensions for MySQL, etc at step 6?
Create a test page containing nothing but this:

?php
phpinfo();
?

Open the page in your browser and verify that mysql, gd, and mbstring
are included.  This will verify that:
1) you added them to your php.ini
and
2) This is the INI file actually being used by the server and not some
random other.

 After I completed the installations
 1. If I navigate to the PHP directory and type php -info it spews a ton of 
 data at me
AND
I created info.php which contains: ?php phpinfo(); ?
When I browse this, it correctly produces a page with all the info about 
 my PHP server. Although I do not understand much of it I believe this 
 confirms PHP is working correctly with IIS
 
 2. I open the MySQL CLI and perform the commands outlined in Step 23 at this 
 page
http://www.bicubica.com/apache-php-mysql/index.php
This returns the expected results, confirming MySQL is working
 
 3. PHP is configured to work with php_mysql.dll as per the steps in the 
 trainsignal links above so I begin!
 I go to the phpmyadmin page, enter root and my password and after a long time 
 I get a FastCGI error. I am not ready to believe it because, in classic MS 
 form, it has several VERY different potential causes, and I have covered all 
 of those. Plus the error code is 0x which is like saying nothing... I 
 start thinking maybe it is not connecting to the mYSQL server right, the 
 instructions re: pma and the password made no sense to me so I fiddle with 
 that with no change.
 
 
I  write the mysql_test.php page in step 5 of 
 http://www.bicubica.com/apache-php-mysql/index.php
This fails with: A connection attempt failed because the connected party 
 did not properly respond after a period of time, or established connection 
 failed because connected host has failed to respond.
 
Because the PHP failed I try with ASP...
%
set conn=Server.CreateObject(ADODB.Connection)
conn.ConnectionString=Driver={mySQL};Server=localhost;Database=test;User 
 Id=root;Password=youwish
conn.open
Response.write(Connected)
conn.close
%
 
This returns:
Microsoft OLE DB Provider for ODBC Drivers error '80004005' 
[Microsoft][ODBC Driver Manager] Data source name not found and no 
 default driver specified 
/test.asp, line 4
 
 I believe I have established MySQL is working, but for some reason it appears 
 that it cannot be reached This IS on the same server so firewall should not 
 be an issue, PLUS I confirmed the installer did create a hole. I turn off the 
 MS firewall to be safe, no change I try a repair of MySQL, I uninstall, 
 reboot and reinstall with no change.
 
 NOTE: at several points I have tried iisreset and/or rebooting the system 
 with no change.
 
 I start to research the matter and my mind is now unglued. I found something 
 referencing using mcrypt with PHPMyAdmin to speed it up and wondered if maybe 
 the long delay before the FastCGI error could be resolved so I tracked down 
 the dll, put it in my ext directory and changed my php.ini to reflect this -- 
 file found at http://files.edin.dk/php/win32/mcrypt/
 
 I found quite a bit about using libmysql.dll but there was no such file in my 
 install, I pulled down the .zip package and that also did not contain it, I 
 eventually found it in a 5.2.x archive but that does not seem to have helped. 
 I have tried enabling: only mysql, mysql AND mysqli, and only mysqli. None of 
 this seems to have done anything to change my situation.
 
 Again, I apologize for the lengthy message, I hope I have accurately 
 described my issue in the right amount of detail.
 
 Thank You!
 Adam Sonzogni
 
 
 
 

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

--
Niel Archer
niel.archer (at) blueyonder.co.uk



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



Re: [PHP-DB] Does PHP5 support querying an MS Access MDE file?

2009-11-03 Thread Niel Archer
 2009/11/3 Timothy Legg php_l...@timothylegg.com:
  2009/11/2 Timothy Legg php_l...@timothylegg.com:
  Hello,
 
  I have PHP Version 5.2.6-1+lenny3
 
  I have been having difficulty using odbc_connect with an MS Access MDE
  database. Â I do have php5-mysql and php5-odbc installed on this server.
 
  Due to the rather poor search results regarding the topic of querying
  MDE
  files with PHP, I am becoming increasingly concerned that this file type
  is not supported.
 
  Is it possible to query an MDE file via PHP5 or should I try different
  approach to querying the database from our linux server? Â I am
  interested
  in your thoughts.
 
  Thanks for your help.
 
  Tim Legg
 
 
  If you have the MS Access ODBC driver installed, then have you tried
  accessing the MDE as an MDB?
 
 
  Yes, I have.  The username and password are arbitrarily set since the
  management hasn't provided that data for me yet.  But I am not far enough
  along to have run into a user rights issue.  I get a warning and also an
  error upon interpreting the page.  I have checked the path to the database
  file, and it is correct.  I also checked file ownership and readability
  permissions, too.  So maybe the name of the driver is wrong; it does look
  a little verbose to me, but it did come straight from the php.net online
  documentation.
 
  Error messages and source is below.  Sorry, I modified the domain name in
  the path for privacy.
 
  Warning: odbc_connect() [function.odbc-connect]: SQL error:
  [unixODBC][Driver Manager]Data source name not found, and no default
  driver specified, SQL state IM002 in SQLConnect in
  /var/www/www.example.com/ht-secure/database_entry/test.php on line 9
 
 
  ?php
  $mdbFilename = /root/tims_db.mde;
  $user = root;
  $password = 1248163264;
 
  $connection = odbc_connect(Driver={Microsoft Access Driver
  (*.mdb)};Dbq=$mdbFilename, $user, $password);
 
  ?
 
  Thanks for looking this over,
 
  Tim Legg
 
 
 
  --
  -
  Richard Quadling
  Standing on the shoulders of some very clever giants!
  EE : http://www.experts-exchange.com/M_248814.html
  Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
  ZOPA : http://uk.zopa.com/member/RQuadling
 
 
 
 
 
 You've got odbc, but probably not a driver for MS Access.
 
 You need both.
 
 I can't seem to find a unix driver for MSAccess.
 
 Converting to a different DB would help (mysql, sqlite).

I had a similar problem. I had to access (pardon the pun) a very old MS
Access db. Being on x64 windows ODBC is not an option, so in the end I
used OpenOffice.org with a java driver to open it and copy data to MySQL.

 -- 
 -
 Richard Quadling
 Standing on the shoulders of some very clever giants!
 EE : http://www.experts-exchange.com/M_248814.html
 Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
 ZOPA : http://uk.zopa.com/member/RQuadling
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

--
Niel Archer
niel.archer (at) blueyonder.co.uk



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



Re: [PHP-DB] Very old question: Mysql and old authentication

2009-10-30 Thread Niel Archer
 Recently we update our Local Server to this:
 
 Apache Version : 2.2.11   
 PHP Version : 5.3.0   
 MySQL Version : 5.1.36   
 
 All works fine locally, but when we want to connect to a Remote Mysql Server 
 5.0.45 just can't, we got the mysqlnd cannot connect to MySQL 4.1+ using old 
 authentication msg
 
 The solution as i see is to use the OLD_PASSWORD trick, but in this case we 
 can't do that because the Server is a Shared server and yada yada yada.. 
 change some in the Remote Mysql Server is not an option
 
 I think Php must provide a solution for this but we can't found it
 
 We use SqlYog 6.05 to connect to Mysql Server's. Why it works with NEW and 
 OLD algorithm and Php don't ?
 
 Any help on this please ?

The is an entry concerning this in 5.3.0 Backward Incompatible Changes
http://php.net/manual/en/migration53.incompatible.php

   The new mysqlnd library necessitates the use of MySQL 4.1's newer
  41-byte password format. Continued use of the old 16-byte passwords
   will cause mysql_connect() and similar functions to emit the error,
   mysqlnd cannot connect to MySQL 4.1+ using old authentication.


The account you are trying to connect with is using an old password hash

Your options are limited, either
1) Compile PHP to use the libmysql library instead of mysqlnd
2) Have the password updated to use the newer hash.

Note The second option will prevent older clients connecting, including
the mysql extension (but not mysqli) if it is not using the mysqlnd
driver.


More information can be found in the MySQL manual on upgrading from v4.0
to v4.1
http://dev.mysql.com/doc/refman/4.1/en/upgrading-from-previous-series.html
http://dev.mysql.com/doc/refman/4.1/en/old-client.html

--
Niel Archer
niel.archer (at) blueyonder.co.uk



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



Re: [PHP-DB] scheduler

2009-09-23 Thread Niel Archer
 Hi,
 
 I am developing a web application in PHP, the db is mysql.
 
 I want to develop something like a batch file, which would run everyday,
 query mysql and throw the output to another table which would then perform
 some additional functions.
 
 Is something like this possible?? i am working on windows thats why said a
 batch,but not rigid about the batch, it cud even be Java.

Not only possible but very simple. Just write the php as normal and use
Windows' Scheduler to run it with something like:

C:\php\php.exe C:\path\to\script.php

I have several scripts like this scheduled to do basic maintenance work
or carry out automated tasks.

 Thanks,
 Vinay

--
Niel Archer
niel.archer (at) blueyonder.co.uk



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



Re: [PHP-DB] losing MySQL resource

2009-09-19 Thread Niel Archer
 I'm maintaining a session.  I successfully connect to a database ($DBConnect
 = mysql_connect()).  I save the connection resource in a session variable
 ($_SESSION['connection'] = $DBConnect) ... to use in subsequent queries.  It
 remains valid while the user is on the current page.
 print_r($_SESSION['connection']) yields 'Resource id #3', for instance.
 
 User browses to a new page ... in the same session.  $_SESSION['$DBConnect']
 no longer references a valid mysql resource.
 print_r($_SESSION['connection']) yields '0'.
 
 Other ordinary values saved in $_SESSION variables remain valid.
 
 Is there something special about a mysql resource?

Not about the resource itself, no. PHP closes connections to a Db when a
script ends, unless the connection is persistent, so while the resource
IS saved, the connection to which it refers no longer exists.

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

--
Niel Archer
niel.archer (at) blueyonder.co.uk



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



Re: [PHP-DB] Invalid library (maybe not a PHP library) : Error while loading pdo-ext.

2009-08-31 Thread Niel Archer
Hi

you would do better to raise these issues on the internals lists, either
intern...@lists.php.net or internals-...@lists.php.net

--
Niel Archer
niel.archer (at) blueyonder.co.uk



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



Re: [PHP-DB] newbie: how to return one iteration *per unique date (DAY!)* in a timestamp column?

2009-08-02 Thread Niel Archer
 
  You need to do this on the mysql side, not in php - php can't  
  summarize the data before processing it, so you need to use  
  something like the date() function in mysql on your timestamp column.
 
  http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date
 
  without knowing your original query it's hard to give an example, but:
 
  select distinct date(timestamp_column) from table;
 
 Thanks Chris,
 
 I am getting closer, but so far it is not iterating only once per  
 unique 'date part of the datetime expression', it is returning all the  
 rows in the table, including those with the very same date but  
 different time in the value of the 'solarLandingDateTime' column.   
 There is not alot of discussion in the mysql docs that I saw about how  
 to work with DISTINCT.  I need to grab data out of the 3 columns:  
 solarLandingIP, solarLandingDir, solarLandingDateTime  (this part of  
 my SELECT is working).
 
 This is what I have:
 
 $foundTrackingRows=mysql_query(SELECT DISTINCT  
 DATE(solarLandingDateTime) solarLandingIP, solarLandingDir,  
 solarLandingDateTime FROM .$whichTable. ORDER BY  
 solarLandingDateTime DESC LIMIT $Maxrecs2Show) or die(query failed:  
  .mysql_error());
 
 -Govinda


There is no comma between DATE(solarLandingDateTime) and  solarLandingIP
which means the DATE column will use the alias 'solarLandingIP'. Is this
your intention? Or is the  solarLandingIP another column from the table. 
If the latter, you may want to do something like this:

 $foundTrackingRows=mysql_query(SELECT DISTINCT
DATE(solarLandingDateTime) AS solarLandingDate,
solarLandingIP, solarLandingDir, solarLandingDateTime
FROM .$whichTable.
 ORDER BY solarLandingDateTime DESC
LIMIT $Maxrecs2Show) or die(query failed:  . mysql_error()); 

If you are aliasing a column it is better to use the optional AS keyword
to avoid confusion.
MySQL's DATE function returns dates formatted as '-MM-DD' so DATE_FORMAT
is not needed here.

--
Niel Archer
niel.archer (at) blueyonder.co.uk



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



Re: [PHP-DB] newbie: how to return one iteration *per unique date (DAY!)* in a timestamp column?

2009-08-02 Thread Niel Archer
  
   You need to do this on the mysql side, not in php - php can't  
   summarize the data before processing it, so you need to use  
   something like the date() function in mysql on your timestamp column.
  
   http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date
  
   without knowing your original query it's hard to give an example, but:
  
   select distinct date(timestamp_column) from table;
  
  Thanks Chris,
  
  I am getting closer, but so far it is not iterating only once per  
  unique 'date part of the datetime expression', it is returning all the  
  rows in the table, including those with the very same date but  
  different time in the value of the 'solarLandingDateTime' column.   
  There is not alot of discussion in the mysql docs that I saw about how  
  to work with DISTINCT.  I need to grab data out of the 3 columns:  
  solarLandingIP, solarLandingDir, solarLandingDateTime  (this part of  
  my SELECT is working).
  
  This is what I have:
  
  $foundTrackingRows=mysql_query(SELECT DISTINCT  
  DATE(solarLandingDateTime) solarLandingIP, solarLandingDir,  
  solarLandingDateTime FROM .$whichTable. ORDER BY  
  solarLandingDateTime DESC LIMIT $Maxrecs2Show) or die(query failed:  
   .mysql_error());
  
  -Govinda
 
 
 There is no comma between DATE(solarLandingDateTime) and  solarLandingIP
 which means the DATE column will use the alias 'solarLandingIP'. Is this
 your intention? Or is the  solarLandingIP another column from the table. 
 If the latter, you may want to do something like this:
 
  $foundTrackingRows=mysql_query(SELECT DISTINCT
 DATE(solarLandingDateTime) AS solarLandingDate,
 solarLandingIP, solarLandingDir, solarLandingDateTime
 FROM .$whichTable.
  ORDER BY solarLandingDateTime DESC
 LIMIT $Maxrecs2Show) or die(query failed:  . mysql_error()); 

Oops, forgot to mention that with the alias you can change the ORDER BY
clause to use the aliased column data:
ORDER BY solarLandingDate DESC
this will only use the returned data instead of the entire column.

 If you are aliasing a column it is better to use the optional AS keyword
 to avoid confusion.
 MySQL's DATE function returns dates formatted as '-MM-DD' so DATE_FORMAT
 is not needed here.

 --
 Niel Archer
 niel.archer (at) blueyonder.co.uk
 
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

--
Niel Archer
niel.archer (at) blueyonder.co.uk



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



Re: [PHP-DB] newbie: how to return one iteration *per unique date (DAY!)* in a timestamp column?

2009-08-02 Thread Niel Archer
 The distinct can only work as you want it to work when you only select the
 date column and only the date part (not the time part).
 Unfortunately I'm more an oracle DBA where the date functions are more clear
 to me so can not help with exact syntax.
 
 I think what you should be doing is returning the entire set of records (all
 required columns) in sorted by date order and loop through all of them. keep
 track of the last date processed and if it is the same as the current
 record, process nothing and go get the next record.
 
 
 BUT  I am not quite sure what you are trying to achieve so my advise may
 be completely flawed.
 
 Jack
 2009/8/3 Govinda govinda.webdnat...@gmail.com

Doh, should have realised this before, but it's after  4 AM here.

Jack is absolutely correct here, you are getting all the rows back
because that is what the query asks for.  Try this as your first step

SELECT DISTINCT DATE(solarLandingDateTime) AS solarLandingDate
FROM  . $whichTable .   ORDER BY solarLandingDateTime DESC
LIMIT $Maxrecs2Show) or die(query failed:  . mysql_error());

This should get your unique rows by date. The previous queries used ALL
of the column names to form a unique row, and that made all the rows
DISTINCT.

Give us an idea of your table structure, if possible post the CREATE
statement for it. 


   Oops, forgot to mention that with the alias you can change the ORDER BY
  clause to use the aliased column data:
  ORDER BY solarLandingDate DESC
  this will only use the returned data instead of the entire column.
 
  If you are aliasing a column it is better to use the optional AS keyword
  to avoid confusion.
  MySQL's DATE function returns dates formatted as '-MM-DD' so
  DATE_FORMAT
  is not needed here.
 
 
  Niel, Bastien,
 
  thanks for your efforts to lead me to understanding this!
 
  I tried everything you both suggested.
  Ideally I would have some clear docs that outline the syntax for me, for
  such an example as I need..  and I would be able to check my code myself.
  Meanwhile, In every case, I just get every record in the table back as a
  result.
 
  So then I thought, try and make even a *simple* DISTINCT work, and then
  move on to the date thing... so I try this:
 
  //$foundTrackingRows=mysql_query(SELECT DISTINCT solarLandingDir,
  solarLandingIP, solarLandingDir, solarLandingDateTime FROM .$whichTable.
  ORDER BY solarLandingDateTime DESC LIMIT $Maxrecs2Show) or die(query
  failed:  .mysql_error());
 
  In all the records in this table, there are only 3 possible values in the
  'solarLandingDir' column (TINYTEXT):
  diysolar
  solar_hm
  (null)
 
  but I still get all the records back, with each distinct 'solarLandingDir'
  column value represented several times.
 
  So something really basic is missing in my understanding/code.
  Can you see what it is?
 
  -Govinda
 
 
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
 -- 
 Jack van Zanen
 
 -
 This e-mail and any attachments may contain confidential material for the
 sole use of the intended recipient. If you are not the intended recipient,
 please be aware that any disclosure, copying, distribution or use of this
 e-mail or any attachment is prohibited. If you have received this e-mail in
 error, please contact the sender and delete all copies.
 Thank you for your cooperation

--
Niel Archer
niel.archer (at) blueyonder.co.uk



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



Re: [PHP-DB] Single Quotes in Form Inputs

2009-07-27 Thread Niel Archer
 I prefer PHP Data Objects http://in3.php.net/manual/en/book.pdo.php to
 addslashes and mysql_real_escape_string

I prefer PDO myself.  However, it is not necessarily safer.  When using
prepared statements the parameters are automatically escaped similar to
mysql(i)_real_escape_string, if my reading of the documentation is
correct. But as far as I can tell no escaping is performed on PDO::query
or PDO::exec other than what you do yourself, so you have the same risks
that need to be addressed.
 

--
Niel Archer
niel.archer (at) blueyonder.co.uk



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



Re: [PHP-DB] simple INSERT statement with placeholders failing. I don't understand why.

2009-07-13 Thread Niel Archer
 this:
 
 $q=mysqli_query($db_billing,'INSERT INTO billing (clientFname,  
 clientLname) VALUES (?,?)', array($defaultsFormVars[clientFname],  
 $defaultsFormVars[clientLname]));
 
 is giving
 Warning: mysqli::query() expects parameter 2 to be long, array given  
 in /home/meee/public_html/somedir/test.php on line 71
 
 a long?!  We need values for 2 text/BLOB columns..  an array seems  
 appropriate to me.  It was with PEAR DB.   WHy is it asking for a long?
 
 it was working fine with PEAR DB before I turned that off to try and  
 learn better what was under PEAR.
 I found
 http://dev.mysql.com/doc/refman/5.1/en/insert.html
 but there is no example of using placeholders there, so I can't  
 determine how to alter this example (which I learned from a book that  
 just breezes through with only the one quick PEAR DB example.)
 
 If someone can even just point me to the right docs for this, I'd be  
 grateful.
 thanks!

http://uk.php.net/manual/en/mysqli.query.php

(Almost) all php functions are documented on the web site. So it would
be the best place to start looking.


You are mixing up several different methodologies in the example you
show.

More generally for MySQLi start here:

http://uk.php.net/manual/en/book.mysqli.php

It has links to the appropriate function references for the MySQL
Improved interface.

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

--
Niel Archer
niel.archer (at) blueyonder.co.uk



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



Re: [PHP-DB] Re: [PHP] A prepared statements question

2009-07-12 Thread Niel Archer
 
 [Redirected to PHP-DB: php...@lists.php.net]
 
 
 On Sun, Jul 12, 2009 at 00:31, Jason Carsonja...@jasoncarson.ca wrote:
  Hello everyone,
 
  I am having a problem getting my prepared statements working. Here is my
  setup...
 
     index.php - authenticate.php - admin.php
 
  1)index.php has a login form on it so when someone enters their username
  the form redirects to another page I call authenticate.php.
 
  2)In the authenticate.php file I want to use prepared statements to
  interact with the MySQL database. I want to compare the username submitted
  from the form with the username in the database.
 
  3)If the login username was legitimate then you are forwarded to admin.php
 
  Its step 2 I am having problems with. Here is what I have but I don't
  think it makes any sense and it doesn't work.
 
 
  $link = mysqli_connect($hostname, $dbusername, $password, $database);
  $stmt = mysqli_prepare($link, SELECT * FROM administrators WHERE
  adminusers=?);
  mysqli_stmt_bind_param($stmt, 's', $username);
  $result = mysqli_stmt_execute($stmt);
 
  $count=mysqli_num_rows($result);
 
  if($count==1){
  header(location:admin.php);
  } else {
  echo Failure;
  }
 
  Any help is appreciated.

The main problem is you are not testing your results.  With that code
you do not even know if you have a connection or not.  I'd say there is
a good chance you do not have error reporting enabled or you would have
picked up the error straight away.

mysqli_stmt_execute returns a boolean indicating success or failure. 
You are trying to use it as a result set, which will not work.  Replace:

$count=mysqli_num_rows($result);

with:

mysqli_stmt_store_result($stmt);
$count = mysqli_stmt_num_rows($stmt);

 
 -- 
 /Daniel P. Brown
 daniel.br...@parasane.net || danbr...@php.net
 http://www.parasane.net/ || http://www.pilotpig.net/
 Check out our great hosting and dedicated server deals at
 http://twitter.com/pilotpig
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

--
Niel Archer



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



Re: [PHP-DB] mysql_insert_id() and JOIN

2009-07-12 Thread Niel Archer
 Sorry my question... but why I must use JOIN if I can use SELECT * FROM
 table1 AND table2 AND table3 WHERE table1.id=table2.id=table3 not?
 thanks

You can not use that syntax on MySQL (at least  not on v5.0 or v5.1, I
do not know about earlier versions).


// Emiliano Boragina _
// Diseño  Comunicación //

--
Niel Archer
niel.archer (at) blueyonder.co.uk



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



Re: [PHP-DB] mysql_insert_id() and JOIN

2009-07-11 Thread Niel Archer
 Hi again…
 
 I dont understand how to use this two…
 
 I read php.net and other sites, but dont understand...

http://dev.mysql.com/doc/
Available in the major languages, pick your filter and start reading.
Having documentation in your own language may help a lot towards
understanding.

 I have this four tables: table1, 2, 3 and 4
 
 So the SELECT is like this?:
 
 ?
 
 $query_select = SELECT * FROM table1 FULL JOIN table2 FULL JOIN table3 FULL
 JOIN table4 ON table1.id=table2.id=table3.id=table4.id ORDER BY id ASC”;
 
 mysql_query($query_select);
 
 ?
 
 This is with FULL JOIN... How identificate the left table if I want to use
 LEFT JOIN?

The left table is the table to the left of the join. So:

SELECT id FROM table1 LEFT JOIN table2...

table1 is the left table and table2 is the right table (if you were to
use a RIGHT JOIN).

 
 How is the UPDATE?
 
 And the INSERT I dont understand yet how is it?

UPDATEs and INSERTs follow the same procedure.

When you INSERT an entry into the main table, you then use the function
mysql_insert_id() which will give you the value of the last 'id' column
generated, which you can then use to insert data into the secondary
tables.

 
 I’m not to do a link between tables in PHPMyAdmin?
 
  
 
 Thank you very... VERY... much!
 

If you are using MySQL 4.1 or later you should use the mysqli extension
and not the older mysql one. UNLESS you are relying on the older style
passwords, which is a BAD idea.

--
Niel Archer



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



Re: [PHP-DB] mysqli error

2009-07-01 Thread Niel Archer
 Whenever I run the following code, I get the error: Commands out of sync;
 you can't run this command now as I try to execute my prepared Update
 statement.
 
 ?php
 $fpiDataAddr = fopen('outputAddr.txt','r') or die(can not open In File );
 
 //Connect to mySQL server
 $mysqli = new mysqli('localhost', 'user', 'pswd', 'db');
 if ($mysqli-connect_error) { die('Could not connect:
 '.$mysqli-connect_error); }
 else{ echo Connected successfully\n; }
 
 $seqno = 0;
 $k = 'Kev';
 
 $sql1 = 'SELECT UNIQUE_NUM, AM_CITY FROM db.kb_addr WHERE UNIQUE_NUM = ?';
 $sth1 = $mysqli-prepare($sql1);
 
 $sql2 = 'UPDATE db.kb_addr SET AM_CITY = ? WHERE UNIQUE_NUM = ?';
 $sth2 = $mysqli-prepare($sql2);
 
 while($inrec = fgetcsv($fpiDataAddr,0,',','')){
 
 if($seqno == 0){
 $x= count($inrec);
 $arrFields = array();
 for ($y = 0; $y  $x; $y++) {
 $arrFields[$inrec[$y]] = $y; //creates associative array that
 associates fields with the index in $inrec
 }
 
 echo Array of Field Names From Header Record in Input data is \n;
 print_r($arrFields);
 $seqno++;
 continue;}
 
 $key = 0+$inrec[$arrFields['Unique #']];
 
 //Select Statement
 $sth1-bind_param('i',$key);
 $sth1-execute();
 $sth1-bind_result($un,$ac);
 $sth1-fetch();
 
 //Update Statement
 $sth2-bind_param('si',$k,$key);
 echo after bind: .$sth2-error.\nThe object error is:
 $mysqli-error\n;
 $sth2-execute();
 echo after execute:  .$sth2-error.\nThe object error is:
 $mysqli-error\n;
 
 if($seqno  1000) break;
 $seqno++;
 }
 
 fclose($fpiDataAddr) or die(can not close file);
 
 //disconnect
 $sth1-close();
 $sth2-close();
 $mysqli-close();
 ?
 
 
 
 However, if I close $sth1 (the select statement) before executing $sth2 (the
 update statement), it works, but since I just closed $sth1, I have to
 prepare it again. This is pretty inefficient considering the large data set
 that I'm working with and the fact that I have to prepare and close my
 select statement every single time I loop through. Is there any way that I
 can run these statements error-free without having to close the select
 statement ($sth1) every single time I want to execute my update statement
 ($sth2)?

You do not initialise your statement object.  I would guess this is a
large part of the problem, although I'm not that familiar with prepared
statements in MySQLi.

 See the documentation for mysqli::stmt_init[1]  and the example for
mysqli_stmt::prepare[2] in the php documentation.

[1] http://docs.php.net/manual/en/mysqli.stmt-init.php
[2] http://docs.php.net/manual/en/mysqli-stmt.prepare.php


 Thanks,
   Kevin

--
Niel Archer
niel.archer (at) blueyonder.co.uk



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



Re: [PHP-DB] Not Valid URL

2009-02-23 Thread Niel Archer
 Hi,
 
 I stuck with something like this. I have two file test.html with  only 
 'a href=../index.phpaaa/a' and main.php with
 '?php

 echo file_get_contents('test.html').'br';
 echo 'a href=../index.phpaaa/a';
 
 ?'
 The problem is tak this two links are different.
 First is http://localhost/game/php/%5C%22../index.php%5C%22
 Second is http://localhost/game/index.php
 
 Paste from FireFox:
 aaa http://localhost/game/php/%5C%22../index.php%5C%22
 aaa http://localhost/game/index.php
 
 I copy file to remote serwer at work and school and both are the same. 
 Problem is somewhere in my computer. I think in my php configuration, 
 but I don't know where to look.
 Would appreciate it greatly if anyone can help.
 
 Regards,
 Kamil Walas

Check the file containing the first link again.   '%5c%22' is the
characters '\'.  Seems you have escaped the double quotes in a single
quoted string


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

--
Niel Archer



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



Re: [PHP-DB] Bulk Insert from text file

2008-09-25 Thread Niel Archer
Hi

   Could any 1 please help on how to insert using phpMyAdmin??

I haven't used phpMyAdmin in years, but here's how I'd do it in SQL with
my favourite tool (SQLyog)

LOAD DATA LOCAL INFILE 'C:\file_name.txt'
 INTO TABLE tbl_name
  FIELDS TERMINATED BY '\t'
  LINES TERMINATED BY '\n'
 IGNORE 1 LINES
 (col_name1, col_name2, col_name3);

Some things to note.
1) the LOCAL keyword is for a file on YOUR computer.  Remove it if the
file is located on the server.  Many shared hosting packages do not
allow you to use LOCAL.

2) IGNORE 1 LINES assumes your file has column names or similar in the
first line, and ignores them. Remove if the file does not have any, or
increase the number if more than one non-data line at the start.

3) The two TERMINATED clauses define the line as being newline
terminated and fields separated by tabs.  Change these accordingly.  You
may need to add an extra backslash  to escape the backslash for
phpMyAdmin, I do not remember how that works with phpMyAdmin.

--
Niel Archer



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



Re: [PHP-DB] solution reqd for summation of vertical columns in PHP

2008-09-14 Thread Niel Archer
 
 On Sep 13, 2008, at 10:05 PM, Vaibhav Informatics wrote:
 
  Please let me know if there is a simple method to total up the  
  column values
  in Mysql database tables using php as in excel.
 
 I believe what you are looking for is count(fieldname)

COUNT returns the number of rows.  I think they're after SUM

SELECT SUM(price) WHERE available = 1;

would total the values in the returned row's price column

--
Niel Archer



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



Re: [PHP-DB] If( Query)

2008-09-07 Thread Niel Archer
Hi

 I have the following function:
 
 function 
 add_item($item_name,$item_desc,$item_price,$item_man_id,$item_cat_id,$item_pix)
 {
 connect();
 if($item_pix == )
 {
 $sql = INSERT INTO items 
 (item_name,item_desc,item_price,item_man_id,item_cat_id) VALUES 
 ('$item_name','$item_desc','$item_price','$item_man_id','$item_cat_id');
 }
 else {
 $sql = INSERT INTO items 
 (item_name,item_desc,item_price,item_pix,item_man_id,item_cat_id) VALUES 
 ('$item_name','$item_desc','$item_price','$item_pix','$item_man_id','$item_cat_id');
 }
 mysql_query($sql);
 return;
 }
 
 I am using the if statement because i want it so that if no picture is 
 uploaded the entry is blank and the mysql database has a default entry 
 of na.gif which is a picture coming soon picture.
 
 It works fine when i run in localy on MAMP, but if i run it on my web 
 server it doesnt add the row.

You should be checking the mysql_query call for success and output the
error if it fails.  Something like:

   mysql_query($sql) or die('Insert failed: ' . mysql_error());

You'll now why it's failing then.  Make sure you have error reporting
enabled.

 Is this a compatability error? or is there a better way to write this?
 


--
Niel Archer



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



Re: [PHP-DB] Help to improve MySQL query

2008-08-09 Thread Niel Archer
 Hi

You do not say how you identify the last call (there is no date/time
field for example), so a complete answer is not really possible

Do not use NOT LIKE 'Completed', it's an inefficient way of doing !=
'Completed'
--
Niel Archer



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



Re: [PHP-DB] Select...

2008-01-15 Thread Niel Archer
Hi

First off, please create your own thread, do not reply to someone else's
and change the subject.

 I'm having kind of trouble to get done this: Select data from a table,
 except those data already in a second table. Actually,  if there is a rowid
 in table2, I wont get it from table1, rowid is the key that relates both
 tables.
 
 I just can't express this with a SQL statement!! idequipomed is the key that
 relates both tables!!
 So, if idequipomed is already in Table2, I shouldn't get it from Table1.
 Any suggestions?

You need to do a join between the two tables using the common column to
make the connection. This  should get you started

SELECT * FROM Table1 RIGHT JOIN Table2 USING (idequipomed) WHERE 
Table1.idequipomed
IS NULL


--
Niel Archer

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



Re: [PHP-DB] Variables Forms

2007-10-17 Thread Niel Archer
Hi Ron

br / is perfectly legitimate in an e-mail header field like Subject:.
All headers may contain any combination of ASCII characters except CR
and LF which are used to terminate the field (See RFC8222 section 2.2).

There is also defined a means to fold lines which involves using the
CR+LF+white-space combination to indicate multiple line entries.  Is it
possible your e-mail header fields are doing this and your access to the
headers does not take this possibility into account?  Without your POP
handling code it's impossible to say whether this is your problem or not.

--
Niel Archer

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



Re: [PHP-DB] php maximum characters in text field

2007-10-17 Thread Niel Archer
Hi

 Does anyone know how to look for a Curly quote or typographer's quotation 
 mark.

Do you mean the equivalent of the left and right double quote entities
in HTML (or 66's and 99's as we called them at school)?


--
Niel Archer

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



Re: [PHP-DB] Inserting databasecontent within the same form

2007-09-27 Thread Niel Archer
Hi Ruprecht,

  SELECT Kunden.*, City.name, City.vorwahl FROM Kunden LEFT JOIN City
  USING (zipcode)
 
 I'm understanding you this is a way for designing the sql-statement.

Yes.

 My customer want that they have inserted the city after typing in the
 zipcode in the zipfield. The city should be searched in a database and
 inserted in the field city automaticly.

 I think the only way is to do that with some ajax-code combined with a
 short phpscript.
 
 Actually I have these codes, but the automatic inserting fails, I don't
 know why.

code snipped

Dynamically changing the fields, I'm afraid I can't help. You would be
better trying a list dedicated to ajax.


--
Niel Archer

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



Re: [PHP-DB] Data not fetching in the textfield.

2007-09-26 Thread Niel Archer
Your variable value is not being inserted because you have used single
quotes for the echo, not double quotes as the nabble example does. 
Special characters and variables are only interpreted in double quotes,
they are treated literally in single quotes.

--
Niel Archer

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



Re: [PHP-DB] Inserting databasecontent within the same form

2007-09-26 Thread Niel Archer
 How can I overtake the fieldvalues of city and the first part of the
 phonenumber. It should read out the value of the zipfield and check them
 with the content of the table ort. If there is found a recordset with
 the same plz the formfields city and the the field vorwahl should get
 the values of the fields of the recordset.

I'm having troubling understanding exactly what you want  and I don't
have time to decipher all the code in the hope it will tell me.  My best
guess is you want to use the zipcode from one table, to automatically
add the city name into a form from another table.  If that is so, you
can do it with your query using a join.

SELECT Kunden.*, City.name, City.vorwahl FROM Kunden LEFT JOIN City
USING (zipcode)

This assumes that `zipcode` exists in both tables and is unique in the
City table.  You should also process the City.name and City.vorwahl
results for NULL results where `zipcode` does not exist in the City
table.

--
Niel Archer

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



Re: [PHP-DB] Pages not fully loading

2007-09-24 Thread Niel Archer
 Further testing shows that the script fails just before the mail() line, 
 though after a variable number of refreshes it goes through and 
 downloads all OK.  Can anyone think why there should be this occasional 
 interaction between the mail() command line and the php script.

Without seeing the code, No!

--
Niel Archer

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



Re: [PHP-DB] showing warnings

2007-09-11 Thread Niel Archer
   
 mysql explain SELECT Tune_Name,Tune_Type FROM Mobile_Tunes;
 +--+--+---+--+-+--+--+---+
 | table| type | possible_keys | key  | key_len | ref  | rows |
  Extra |
 +--+--+---+--+-+--+--+---+
 | Mobile_Tunes | ALL  | NULL  | NULL |NULL | NULL |4 |
|
 +--+--+---+--+-+--+--+---+
 1 row in set (0.00 sec)
   mysql

This shows you have NO indexes on the table.  Assuming that 'Tune_Name'
contains unique entries for each row, I'd suggest you do the following
as a minimum:

ALTER TABLE Mobile_Tunes ADD PRIMARY KEY (Tune_Name);


--
Niel Archer

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



Re: [PHP-DB] showing warnings

2007-09-11 Thread Niel Archer
  This shows you have NO indexes on the table.  Assuming that 'Tune_Name'
  contains unique entries for each row, I'd suggest you do the following
  as a minimum:
 
  ALTER TABLE Mobile_Tunes ADD PRIMARY KEY (Tune_Name);
 
 How's that going to help if he's getting all records from the table?

 Depends what you mean by help.
 Improve performance of the query, not at all, but that wasn't the
original question.  
In a previous post he said he'd added indexes which his EXPLAIN output
clearly shows is not the case.  That is simply an example of how to add
a PRIMARY KEY after creating the table.  However, it will stop duplicate
entries from being entered and prepare the way for when he's NOT
selecting all rows, so is not entirely wasted.

 Also there's no way a database is going to use an index if there are
 only 4 rows in the table.

True, but if it was only ever going to have 4 entries in it I doubt he'd
be using a Db at all.  I'm assuming this is just a sample.

--
Niel Archer

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



Re: [PHP-DB] __CYGWIN32__

2007-08-06 Thread Niel Archer
Hi

  This is the wrong place to be asking really.  This list is for using
PHP with databases, not installing PHP even if it's with a database.

  While I'm far from being a Linux Guru, I can't think of any reason
that you should get any references to CygWin, which is a Windows package
to allow a Unix-Like environment.

  You need a list like the developers one, where they're more
knowledgeable with building PHP/MySQL


--
Niel Archer

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



Re: [PHP-DB] Re: record pointer

2007-07-06 Thread Niel Archer
Hi

 mysql select id,cat from table where cat=(select cat from table where id=51);
 +-+--+
 |  id | cat  |
 +-+--+
 |  40 | FLK  |
 |  41 | FLK  |
 |  42 | FLK  |
 |  44 | FLK  |
 |  45 | FLK  |
 |  46 | FLK  |
 |  47 | FLK  |
 |  48 | FLK  |
 |  49 | FLK  |
 |  50 | FLK  |
 |  51 | FLK  |
 |  52 | FLK  |
 |  53 | FLK  |
 |  54 | FLK  |
 |  55 | FLK  |
 |  56 | FLK  |
 |  57 | FLK  |
 |  58 | FLK  |
 |  59 | FLK  |
 |  60 | FLK  |
 +-+--+
 20 rows in set (0.02 sec)

 now I can select the whole cat when I enter an ID that is fine! but the query 
 should 
 stop at id=$id or in other words in the end it should POINT to id=$id
 in the above example the last record would be the record with id=51
 do I need another SELECT here?

If I understand that correctly, you only need to add the extra condition
to the WHERE clause of the main query.  So:

SELECT id, name, cat FROM table 
WHERE cat = (SELECT cat FROM table WHERE id = $ID) AND id = $ID;

This should display all rows, before and including the row with the same
'cat' as 'id' has. For your example of $ID = 51 it should display:

+-+--+
|  id | cat  |
+-+--+
|  40 | FLK  |
|  41 | FLK  |
|  42 | FLK  |
|  44 | FLK  |
|  45 | FLK  |
|  46 | FLK  |
|  47 | FLK  |
|  48 | FLK  |
|  49 | FLK  |
|  50 | FLK  |
|  51 | FLK  |
+-+--+


Niel

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



Re: [PHP-DB] Re: record pointer

2007-07-05 Thread Niel Archer
Hi

   O.K. the id column is primary key and it is auto_incerment .I think my 
 explanation was not clear enough :
  
  this is my query : SELECT * FROM table WHERE ID=$ID
  this will find the record with the specified ID and I will be able to see 
 it,  now I want to be able to scroll up and down to all the records that 
 belong to the same cat(egory)!

Assuming that is correct now, use a sub-query:

SELECT id, name FROM table 
WHERE cat = (SELECT CAT FROM table WHERE id=$ID);

Niel

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



Re: [PHP-DB] Catchable fatal error: Object of class stdClass could not be converted to string in filename on line line

2007-06-25 Thread Niel Archer
Hi 
Seeing as no-one else has replied to this, I'll make a comment.  First
off let me state I don't use PDO so I am not familiar with it.

It would appear to me that your problem line is NOT the problem. It is
only where the error is reported from.  That line is a call to an object
method, so the problem is in that method. As you haven't supplied the
code for that method, no one is able to help.

 A point of note is that my $dbh is being created in my class constructor
 as a private. The method that is calling the prepare and execute
 statements is a public. I don't thing I'm trying to do anything new or
 exotic, I don't think I'm trying to convert the object to a string, just
 execute the query statement

Probably not relevant, although it likely would be better to assign by
reference.

$prep_users = $this-dbh-prepare($sql_users);

The main problem is we don't know what your $dbh is. We can guess it's a
database handle, but that really doesn't tell us anything useful, like
how it is constructed, and what the method  you try calling is trying to
do

We need to see the code for the method:

$prep_users-execute();

as that is where the error is occurring, and possibly the constructor and
prepare methods also.


Niel

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



Re: [PHP-DB] how to delete

2007-06-19 Thread Niel Archer
Hi

There is no DESTROYIMAGE() function. May be you mean imagedestroy(). If
so this does NOT erase files, it destroys in memory images created using
the Image functions.

  To erase files use the unlink function. For detail look here 
http://uk3.php.net/unlink

Niel

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



Re: [PHP-DB] Problem with rss-feed generation

2007-06-15 Thread Niel Archer
Hi

the first line is badly formed

xml version=1.0 encoding=ISO-8859-1

Should be:

?xml version=1.0 encoding=ISO-8859-1 ?


Niel

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



Re: [PHP-DB] Problem with rss-feed generation

2007-06-15 Thread Niel Archer
Hi

 ok by beginning the php-code with ?php I fixed the problem.
 Unfortunately my RSSowl tell me that there must be other errors in the
 xml-formating. And I don't got a detailed information what RSSowl
 dislike in the xml-file.

Try opening it in a browser. Opera, for example, tells you what error it
encounters.  That's how I identified your initial error.

Niel

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



Re: [PHP-DB] Problem with rss-feed generation

2007-06-15 Thread Niel Archer
Hi

 Du you know a good tutorial for XML and RSS, possible relating with PHP.

Not a tutorial, no.  I got my information from the specification
documents.

You should consider changing your method.  Instead of creating the
RSS/XMl file manually, try using one of the PHP extensions that will
generate XML for you, like the PEAR XML_Query2XML package which converts
SQL SELECT results into valid XML data. Or PECL's xmlwriter.


Niel

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



Re: [PHP-DB] tell me syntax

2007-06-12 Thread Niel Archer

http://dev.mysql.com/doc/refman/5.1/en/grant.html

Niel

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



Re: [PHP-DB] tell mysql error

2007-06-08 Thread Niel Archer
Hi

Sounds like you do not have the required privileges with your user
account..  I suggest you spend some time reading the MySQL documentation
on privileges.

Are you using the root account? Have you created other user accounts and
given them the required privileges?



Niel

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



Re: [PHP-DB] tell mysql error

2007-06-05 Thread Niel Archer
Hi

   mysql -h localhost -u root -p 123456

 should be:

   mysql -h localhost -u root -p123456

notice no space after -p or it asks for the password.


Niel

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



Re: [PHP-DB] 20K photos

2007-04-29 Thread Niel Archer
Hi

  Imagine that you want to put some 2 historical photos On display in 
 your website , you use PHP and MySQL.
   Preparing a photo album with 200 photos is no problem but for 2 photos! 
 would you do it in the same way? 

Yes, but I don't necessarily see the need for a db.

If you have additional information on the pictures to store, then yes,
use a db. Otherwise all the info you need is available from the files.

For small numbers I wouldn't store the filenames in the db. For 20K, I
would.

Decide on how many images per page, then use SELECT with LIMIT to pull
out a page's worth of files and show the page.  Back/Next tell the page
what offset to use for the LIMIT clause.


Niel

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



Re: [PHP-DB] problems with functions/included files/mysql resource

2007-03-27 Thread Niel Archer
Hi,
 
 In the function to connect to and select the database, I make the mysql-link 
 resource a global value.

It sounds like you've misunderstood 'global' variable.  The global
statement needs to go inside the function where you want to use the
variable, not where you assign it.  This tells that function to access
that variable from the global scope.  You will need to have this
variable available at the global scope.  Creating it inside another
function will not do, you must return that from the function to the
global scope too

e.g.

?php

  $db = new mysql;

 ... some code ...


function UseDb()
{
global $db;

... some more code ...
}

?

Niel

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



Re: [PHP-DB] sunrise / sunsite / correcting for summer time

2007-03-25 Thread Niel Archer
Hi, 
  see the docs for the date() function.  'I' returns 0 or 1 indicating
Daylight Saving Time. However, it does this based on the settings for
your installation.  i.e. if your webserver is running on a host
configured to U.S. time zone, it'll give U.S. DST results.

  Note that, any method will only remain accurate until the goal posts
are moved next.  The U.S. for example changed their DST dates last year
(end date moved back).  Australia and other countries have also recently
changed.  In these cases, either your code or the language need to be
updated after such changes.
.
Niel

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



Re: [PHP-DB] Inheritance question

2007-03-19 Thread Niel Archer
Hi

 For example (see below), lets say I would like to use public $one  
 property in a new class / method (such as class b)?   What is the  
 best way to accomplish this?  Any help and or suggestions are welcome.
 
 class a {
   public $one;
 
 public function someMethod() {
   $this-one = '1';
   }
 }
 
 class b {
   public $two
 
 function someOtherMethod() {
   $this-two = '2';
   }
 }

At least two ways you could go about it.  Most straight forward would
 be to inherit, like this:

class a {
public $one;

public function someMethod() {
$this-one = '1';
}
}

class b extends a{
public $two

function someOtherMethod() {
$this-two = '2';
}
}

$object = new b;

$object-someMethod();
$object-someOtherMethod();

print $object-one, $object-two;


In addition to that, if you actually need to use an instance of a
separately to b, you can pass the instance of a into b as a parameter.
Definition for 'b' would need to be something like:

class b {
public $a;
public $two

function __Constructor($dummy) {
$this.a = $dummy;
)

function someOtherMethod() {
$this-two = '2';
}
}

$object1 = new a;
$object2 = new b($object1);

$object1-someMethod();
$object2-someOtherMethod();

print $object2-a-one, $object2-two;

There are more than likely other ways to go about this.  Check the
documentation for further examples of how to use classes in PHP.

Niel

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



Re: [PHP-DB] Urgent! Installing PHP 4 on 64-bit machines

2007-03-07 Thread Niel Archer
Hi

I've only had MySQL 4.1 running on 64 bit windows and PHP 5.x, without
any real problems when used locally.  However, there seemed to be a
problem using the MySQL server via TCP/IP, hence the upgrade to native
64 bit version (v5.0), which was not desired at the time but seemed to
be the only fix we could find.


Niel

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



Re: [PHP-DB] Urgent! Installing PHP 4 on 64-bit machines

2007-03-06 Thread Niel Archer
Hi 

 I need urgent help. Have anyone successfully installed PHP 4  MySQL 4.0 on 
 64-bit Windows?

Frankly, why would you want to?  Neither are written for 64 bit.  The
only versions I could find for 64 bit were the 5.x versions in both. 
Which is what I run on my personal computer.

Niel

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



Re: [PHP-DB] csv problem.. read csv from var

2007-02-16 Thread Niel Archer
Hi

sorry, I misunderstood your problem, it was not too clear to me as the
code you list shouldn't produce the output you supplied.

try this:

$array = explode(',', $csv);

print br=  . $array[0] . \n;
print br=  . $array[1] . \n;

for ($i = 2; $i  count($array); ++$i) {
 $txt.= br /= . $array[$i] . \n;
}

print $txt;


Niel

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



Re: [PHP-DB] csv problem.. read csv from var

2007-02-15 Thread Niel Archer
hi

 the problem i have is.. how about the csv is a var
 DATA===
 $csv=
 A507257,3/2/2007,\Hematologi Lengkap,Cholesterol Total,LDL
 Cholesterol,Trigliserida,HDL Cholesterol,Asam Urat,Gula Darah Puasa,Gula
 Darah 2 Jam PP,Kreatinin,Ureum,Bilirubin Total,Alkali
 Fosfatase,SGOT,SGPT,Urine Lengkap,Feses Rutin,Darah Samar Faeces,VDRL,Anti -
 HBs,Total PSA,HBsAg,Anti - HCV Total\;
 
 what should i do to make the ouput like above.

Use 

  $arry = explode(',', $csv);

to separate the variable into an array, then process it using foreach as
before

Niel

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



Re: [PHP-DB] Trying to add primary key to existing database.

2007-02-04 Thread Niel Archer
Hi.

  I don't know cPanel, but I expect it can run SQL directly, most panels
can.  Use the ALTER TABLE ADD {INDEX|KEY} syntax to add indexes/primary
keys.  You can use multiple columns, which together form a unique value
to create your primary key.

Niel

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



Re: [PHP-DB] What effects MySQL connection's character set

2007-01-31 Thread Niel Archer
Hi all

  Finally identified the problem. Was pretty obvious in retrospect.

  The mysqli class (Improved MySQL extension OO style) defaults to
latin1 as a character set, regardless of what PHP is using.  Simple
solution is to use the set_charset method (mysqli_set_charset for non OO) on
the object, which will change the connection parameter.

Niel

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



Re: [PHP-DB] What effects MySQL connection's character set

2007-01-30 Thread Niel Archer
Hi

   Thanks for this. That page didn't actually help, but one of the follow
 ups did.  Apparently, despite being setup as UTF-8 throughout the Db,
 tables, and columns.  The returned data still can default to Latin1.
   I've forced my test server to return UTF-8 (I hope) and am trying it
 out today. Fingers crossed!

  That turned out to be overly optimistic.  Even Though the server is
using UTF-8 throughout, it still defaults to latin1 on connections.  So
I used the SET NAMES utf8. It still will not work as I expect.  I used
the following code to test it.

$Db = new mysqli($Host, $User, $Pass, $Db);

$Db-query(SET NAMES utf8);
$result = $Db-query(SHOW VARIABLES LIKE 'character\_set\_%');

$count = $result-num_rows;
while ($count):
$dummy = $result-fetch_assoc();
print $dummy['Variable_name'] .  =  . $dummy['Value'] . \n;
--$count;
endwhile;

print \ncharacter_set_name:  . $Db-character_set_name() . \n;

Which results in the following output:

character_set_client = utf8
character_set_connection = utf8
character_set_database = utf8
character_set_results = utf8
character_set_server = utf8
character_set_system = utf8

character_set_name: latin1

  I can't find any documentation on PHP's character encoding, beyond the
default_charset directive.  Several of the functions/extensions have
documentation, but not PHP itself.
  I suspect the problem is with php itself or the mysqli extension,
which was my original thought and reason for my post.

  Anyone have any ideas?


Niel

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



Re: [PHP-DB] How to tell if a field type is auto_increment

2007-01-30 Thread Niel Archer
Hi John,

I'd suggest searching within the Extra field instead of testing for the
value explicitly, as this field can theoretically hold several extra
pieces of information.

Niel

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



Re: [PHP-DB] How to tell if a field type is auto_increment

2007-01-29 Thread Niel Archer
Hi

Try using:
 SHOW COLUMNS FROM db.table LIKE 'field_name%'

and from the returned row, check the 'Extra' column for 'auto_increment'

Niel

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



Re: [PHP-DB] can u help me in PHP

2007-01-28 Thread Niel Archer
Hi

 I read ur reply on newsreader abou mysqli and if i can use it in PHP4
 
 My question is where can i find a link to download the mysqli extension
 separately without changing to PHP5

  The MySQLi extension is available before PHP v5, but I couldn't tell
exactly which version it was introduced with.  I'm pretty certain it's
part of 4.1.
  However, this doesn't mean it is enabled.  If I recall correctly, on a
windows platform it is available as a dll, but needs to be enabled in the
php.ini.  With other platforms, I think it needs to be compiled in with
an additional switch.

Niel

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



Re: [PHP-DB] Am I missing something?

2007-01-27 Thread Niel Archer
Hi

 Alright, I did that. I now get :
  INSERT INTO domains ( picture, thumbnail ) values( '', '')
 
 and no data entered.

Then for some reason your variables are empty.  Make sure they have data
on entry to the function.  If they don't keep backtracking until you
find where it's lost.

Niel

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



[PHP-DB] What effects MySQL connection's character set

2007-01-26 Thread Niel Archer
Hi all

How is the character set of returned data effected?  I have a DB using
UTF-8 encoding., PHP is set to use UTF-8 internally. However the MySQL
connection returns Latin1 data.  How can I get it to return UTF-8 data
instead.

TIA

Niel

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



Re: [PHP-DB] Formatting MySQL Queries

2007-01-24 Thread Niel Archer
Hi

SELECT * FROM table INTO OUTFILE 'file_name'
  FIELDS TERMINATED BY '\t'
  LINES TERMINATED BY '\n'


Niel

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



Re: [PHP-DB] CURL and process not finishing

2007-01-09 Thread Niel Archer
Hi

 leaving me with the question: what does
 max_execution_time relate to?  is it more like a maximum time without 
 activity.

max_execution_time is the time php gets to execute code.  From the
documentation: The maximum execution time is not affected by system
calls, stream operations etc. Please see the set_time_limit() function
for more details.


Niel

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



Re: [PHP-DB] mysql rereading result set (fetch_assoc)

2007-01-09 Thread Niel Archer
Hi

 Hi, I would ask which way is more efficient and save time? Save each row to
 array or mysql_data_seek(0) ? 


  That totally depends on which resources are more valuable to you.
  The array will likely use more memory but be faster to process. 
  While mysql_data_seek(0) would probably use no additional memory but
be slower. It also might require you to duplicate code.

Niel

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



Re: [PHP-DB] Syntax Error

2007-01-07 Thread Niel Archer
Hi

 is the syntax error reported for the php or the SQL?  Better yet,
supply the actual error message, so we can see for ourselves

Niel

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



Re: [PHP-DB] CURL and process not finishing

2007-01-06 Thread Niel Archer
Hi

 Are you running this as CLI or from your web-server?  If the latter, use
phpinfo() and check the max_execution_time isn't causing you problems.

Niel

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



Re: [PHP-DB] search result error message

2006-12-21 Thread Niel Archer
Hi,

there's no 'logic' error at all that I can see.  It's more a design
error as it doesn't do the job the way that you describe it at all. 
  What actually happens is that the starting HTML (heading and table
start)  is output before the database is even contacted, so there's no
way for you to take the table back if you don't receive any relevant
hits.

try something more like this:

?php
// database information
   $host = 'xxx';  
   $user = 'xxx';
   $password = 'xxx';
   $dbName = 'xxx';

mysql_connect(localhost,$user,$password);
@mysql_select_db($dbName ) or die( Sorry But There Seems To Be A Problem
Connecting To The Database);

$query=SELECT * FROM shop;
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();

if ($num) {
?
h2Your favorites search result/h2divYou are here:  index.htm Home  
Your favorites/div
div class=internalContentArea sgtable 
div class=tableHeadSub-category search result/div 

div
table width='100%' id='table1' 
cellspacing=0theadtr
th scope=colShop name/th

/tr/theadtbody
?php

$i=0;
while ($i  $num) {

$shopname=mysql_result($result,$i,shopname);
echo 
tr
td$shopname/td
/tr;
$i++;
}

?/tbody/table index.htm  Back to search div 
/div

} else {

echo 
div
  div class='alert'The search criteria you entered did not generate any
result,  index.htm please try again ./div
/div;

}

You'll probably need to polish this some, because I quickly cut/pasted
it before I go down the pub.

Niel

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



Re: [PHP-DB] Limited number of database results

2006-12-13 Thread Niel Archer
Hi

use a LIMIT clause in your SQL.  Something like:

$query=SELECT * FROM  WHERE hello = '$hello' LIMIT  . ($page - 1) *
$rows . , $rows;

then you only need specify the logic to set the page, row and
limitations


Niel

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



Re: [PHP-DB] Invoking database php file with hyperlink

2006-12-12 Thread Niel Archer
Hi

button/hyperlink, no difference.  It's the page that is target that does
the work

Niel

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



Re: [PHP-DB] CSV import to mySql

2006-12-05 Thread Niel Archer
Hi

Your example data does have an invalid field count  The first row has has
7 fields, the other 6. 

So if you took them from your actual data that's your problem

Niel

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



Re: [PHP-DB] Any hints lantin1 utf-8

2006-11-24 Thread Niel Archer
Hi

If you're storing non-latin character in a latin-1 table you are bound
to get this problem.  phpMyAdmin is simply showing you what you put
there as far as it is concerned.

You should switch to using an alternative encoding for the character set. 
UTF-8 would likely be best for you.  Back up all the data before making
the change, or it WILL be corrupted.

If you primarily use non-latin character sets, I'd recommend making
UTF-8 the default database character set

Niel

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



Re: [PHP-DB] Any hints lantin1 utf-8

2006-11-24 Thread Niel Archer
Hi 

I don't use phpMyAdmin myself and I can't remember if it supports UTF-8
encoding

Whichever extension that your PHP is using is likely doing a conversion. 
this is something that the MySQL libraries handle.
  You can use this to extract the data from the tables and save it.

As a test, dump a table's data into a file (have mysqldump, or
phpMyAdmin create insert statements for the data).  Create a table with
UTF-8 encoding and attempt to process that file into it (copy/paste into
phpMyAdmin if it's not to big)

If that works, then you can go ahead and back up all your tables this
way, and enter it into your new UTF-8 ones

Without knowing more about your configuration (local/remote, versions,
etc.) I can't suggest much else.


Niel

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



[PHP-DB] Moving phpNuke to phpBB

2006-11-22 Thread Niel Archer
Hi

  I'm helping out someone move from PHPNuke to phpBB.  Only the forums
and users need to be moved.

  Nuke's Db structure for the forums seems to mimic phpBB's closely,
which is no great surprise.
  Any advice or information would be greatly appreciated.  For example,
anyone know a way to convert the stored passwords?  Nuke uses a 40 char
hash, while phpBB only 32.

Niel

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



Re: [PHP-DB] Special Character

2006-11-16 Thread Niel Archer
Hi

Is it really a hyphen, or is it an en- or em-dash.  The latter two could
mess up in in some character sets.

Niel

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



Re: [PHP-DB] Special Character

2006-11-16 Thread Niel Archer
Hi David

What you describe sounds like Word is auto replacing hyphens with either
en- or em-dashes.  This is a configurable option in Word that often
defaults to on.  Try using double quotes, If they get switched to 66's
and 99's style quotes, then that is likely the problem.  I no longer use
MS Office for these and other reasons, so cannot tell you how to switch
off this formatting.  But it can be switched off, somewhere within it. 

The only other option I can think of would be to change your Db
character set to one that can accept these extended characters. That
might also mean changing some of Window's/Word's behaviour (to be using
UTF-8 for example).

Niel

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



Re: [PHP-DB] Special Character

2006-11-16 Thread Niel Archer
Hi David

off the top of my head, the best I can suggest is using PHP's MB
functions (lookup mb_string) to allow recognition and then convert them
to hyphens.

Niel

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



Re: [PHP-DB] Special Character

2006-11-16 Thread Niel Archer
Hi

Doh... that's 'mbstring'

Niel

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



Re: [PHP-DB] Installation Problem

2006-11-15 Thread Niel Archer
Hi

If you're on a windows platform, this will be because MySQL support is
built in on v4.1 but not on 5.x.  As the others have suggested,
uncomment the php_mysql.dll entry in the modules to add it.

Niel

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



Re: [PHP-DB] MySQL SQL Query Help

2006-11-13 Thread Niel Archer
Hi 

Try:

SELECT fkid, MAX(foo), bar FROM table GROUP BY fkid ORDER BY bar DESC

Niel

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



Re: [PHP-DB] Verifying syntax executed correctly

2006-10-17 Thread Niel Archer
Hi

All of the MySQL functions you used, return FALSE on failure.

Niel

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



Re: [PHP-DB] mysql databases

2006-10-13 Thread Niel Archer
Hi Bob

Your question isn't very clear.  Do you want to remove the oldest entry,
newest, or is there some other criteria to diceide?

Niel

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



Re: [PHP-DB] mysql databases

2006-10-13 Thread Niel Archer
Hi

 He means that he wants to use REPLACE and take out the old entry and update
 it with a new one. Although, you would probably use UPDATE instead.

Hmmm... Thought this was DB list, not mind-readers.
I would also *guess* that would be the intention, but his example seems
to remove the newest entry, not the oldest, hence I stopped guessing and
asked.


Niel

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



  1   2   >