Re: [PHP-DB] Help with If else if

2012-03-18 Thread Tamara Temple

On Tue, 13 Mar 2012 17:33:43 +0530, Gu®u nagendra802...@gmail.com sent:

Hi,

Please help me with this code. I have 2 different fields in mysql table.
What I want is if the field is empty don't show the image. Please look at
the code below.


?php


  if($search-plugin-ListViewValue()==)
  {

   echo 'a href='.$search-facebook-ListViewValue().'img
src=images/facebook.gif width=22 height=23//a/a';
  }
  if($search-facebook-ListViewValue()==)
  {

  echo 'a href='.$search-plugin-ListViewValue().'img
src=images/twitter.gif width=22 height=23//a/a';
  }


  else if($search-plugin-ListViewValue()== 
$search-facebook-ListViewValue()==)
{

echo ;
}

else
  {

  echo 'a href='.$search-plugin-ListViewValue().'img
src=images/twitter.gif width=22 height=23//a/a'.'a
href='.$search-facebook-ListViewValue().'img
src=images/facebook.gif width=22 height=23//a/a';

  }


  ?


--
*Best,
*
*Gu®u*



I think we really need to see a lot more than this before we can help.  
What is the output that is generated? What is $search and how is it  
set prior to entering this bit of code? As it stands, I can see no  
reference to MySQL tables in this, nor any idea what values you're  
expecting and not seeing. If you don't already, please set  
error_reporting to the most detailed, and turn on display_errors in  
your output. Before each of the if's echo a var_dump of the values  
you're testing so we can see their exact values.




--
Tamara Temple
   aka tamouse__

May you never see a stranger's face in the mirror


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



Re: [PHP-DB] Help with If else if

2012-03-18 Thread Tamara Temple

On Tue, 13 Mar 2012 21:23:57 +0530, Gu®u nagendra802...@gmail.com sent:


No Michael, your code is also not working. What you have understood is
correct. let me explain it to others too.

If variable twitter and facebook are empty don't echo anything,

if variable twitter has a value and facebook is empty echo out only twitter,

if variable twitter has no value and facebook has a value echo out facebook
only,

and finally if both has values echo out both.

Basically I want to echo out only if there is some value in the database.
But in my case both the images are echoing out.


For probably the bazillionth time, PUT REPLIES ON THE BOTTOM






On Tue, Mar 13, 2012 at 8:54 PM, Michael Stowe m...@mikestowe.com wrote:


From looking at your code, the issue is that your if statements are
checking for the same criteria as your else statements, meaning that if the
string is empty () the if statements will be triggered, and since the if
statements are true, the elseif statement will not be.  Or if the string
isn't empty, neither the if or the elseif statements will be triggered,
causing the else statement to be activated.  Either way, the images would
be printed out. *
*
*
*
*Did you mean to do this?*

?php
if($search-plugin-ListViewValue() ==  
$search-facebook-ListViewValue() == ) {
// Neither one has a value
} elseif ($search-plugin-ListViewValue() !=  
$search-facebook-ListViewValue() != ) {
// Both have a Value
echo 'a href=' . $search-plugin-ListViewValue() . 'img
src=images/twitter.gif width=22 height=23//a/a' . 'a
href=' . $search-facebook-ListViewValue() . 'img
src=images/facebook.gif width=22 height=23//a/a';
} elseif ($search-plugin-ListViewValue() != ) {
// Twitter has a value
} else {
// Facebook has a value (only possible option left)
echo 'a href=' . $search-facebook-ListViewValue() . 'img
src=images/facebook.gif width=22 height=23//a/a';
}
?



Hope that helps,
Mike



On Tue, Mar 13, 2012 at 9:44 AM, Matijn Woudt tijn...@gmail.com wrote:


On Tue, Mar 13, 2012 at 3:06 PM, Gu®u nagendra802...@gmail.com wrote:
 The issue is both the images are echoing and no if else statement is
 working.


First of all, please bottom post on this (and probably any) mailing list.

You should perhaps provide what the contents of
$search-plugin-ListViewValue()== and
$search-facebook-ListViewValue()== is.
Though, if I understood you correctly, it would be as simple as:
$facebookEnabled = $search-facebook-ListViewValue()!=;
$twitterEnabled = $search-plugin-ListViewValue()!=;
if($facebookEnabled)
 {

 echo 'a href='.$search-facebook-ListViewValue().'img
src=images/facebook.gif width=22 height=23//a/a';
}
 if($twitterEnabled)
 {

echo 'a href='.$search-plugin-ListViewValue().'img
src=images/twitter.gif width=22 height=23//a/a';
}

- Matijn

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





--
---

My command is this: Love each other as I
have loved you. John 15:12

---





--
*Best,
*
*Gu®u*



Recapitulating your pseudocode above, you don't need anything so complex:

if twitter is set:
   emit twitter image
if facebook is set:
   emit facebook image

The two seem completely independent of each other. Thus:

?php
$twitter = $search-plugin-ListViewValue();
if (!empty($twitter)) {
   echo 'a href='.$twitter.'img src=images/twitter.gif  
width=22 height=23//a';

}
$fb = $search-facebook-ListViewValue();
if (!empty($fb)) {
   echo 'a href='.$fb.'img src=images/facebook.gif width=22  
height=23//a';

}
?

The above will give a twitter image+link if the twitter link is set,  
and a facebook image+link if facebook is set. You don't need to do  
anything special if both are set, or if neither is set, as they are  
completely independent of each other.


--
Tamara Temple
   aka tamouse__

May you never see a stranger's face in the mirror


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



[PHP-DB] Help with If else if

2012-03-13 Thread Gu®u
Hi,

Please help me with this code. I have 2 different fields in mysql table.
What I want is if the field is empty don't show the image. Please look at
the code below.


?php


  if($search-plugin-ListViewValue()==)
  {

   echo 'a href='.$search-facebook-ListViewValue().'img
src=images/facebook.gif width=22 height=23//a/a';
  }
  if($search-facebook-ListViewValue()==)
  {

  echo 'a href='.$search-plugin-ListViewValue().'img
src=images/twitter.gif width=22 height=23//a/a';
  }


  else if($search-plugin-ListViewValue()== 
$search-facebook-ListViewValue()==)
{

echo ;
}

else
  {

  echo 'a href='.$search-plugin-ListViewValue().'img
src=images/twitter.gif width=22 height=23//a/a'.'a
href='.$search-facebook-ListViewValue().'img
src=images/facebook.gif width=22 height=23//a/a';

  }


  ?


-- 
*Best,
*
*Gu®u*


Re: [PHP-DB] Help with If else if

2012-03-13 Thread Matijn Woudt
On Tue, Mar 13, 2012 at 1:03 PM, Gu®u nagendra802...@gmail.com wrote:
 Hi,

 Please help me with this code. I have 2 different fields in mysql table.
 What I want is if the field is empty don't show the image. Please look at
 the code below.

I have looked at it.

Maybe you should tell what is wrong, what it outputs currently, and
what it should output. Or perhaps, which errors you get if any?

- Matijn

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



Re: [PHP-DB] Help with If else if

2012-03-13 Thread Gu®u
The issue is both the images are echoing and no if else statement is
working.

On Tue, Mar 13, 2012 at 7:22 PM, Matijn Woudt tijn...@gmail.com wrote:

 On Tue, Mar 13, 2012 at 1:03 PM, Gu®u nagendra802...@gmail.com wrote:
  Hi,
 
  Please help me with this code. I have 2 different fields in mysql table.
  What I want is if the field is empty don't show the image. Please look at
  the code below.

 I have looked at it.

 Maybe you should tell what is wrong, what it outputs currently, and
 what it should output. Or perhaps, which errors you get if any?

 - Matijn




-- 
*Best,
*
*Gu®u*


Re: [PHP-DB] Help with If else if

2012-03-13 Thread Matijn Woudt
On Tue, Mar 13, 2012 at 3:06 PM, Gu®u nagendra802...@gmail.com wrote:
 The issue is both the images are echoing and no if else statement is
 working.


First of all, please bottom post on this (and probably any) mailing list.

You should perhaps provide what the contents of
$search-plugin-ListViewValue()== and
$search-facebook-ListViewValue()== is.
Though, if I understood you correctly, it would be as simple as:
$facebookEnabled = $search-facebook-ListViewValue()!=;
$twitterEnabled = $search-plugin-ListViewValue()!=;
if($facebookEnabled)
 {

  echo 'a href='.$search-facebook-ListViewValue().'img
src=images/facebook.gif width=22 height=23//a/a';
 }
 if($twitterEnabled)
 {

 echo 'a href='.$search-plugin-ListViewValue().'img
src=images/twitter.gif width=22 height=23//a/a';
 }

- Matijn

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



Re: [PHP-DB] Help with If else if

2012-03-13 Thread Michael Stowe
From looking at your code, the issue is that your if statements are
checking for the same criteria as your else statements, meaning that if the
string is empty () the if statements will be triggered, and since the if
statements are true, the elseif statement will not be.  Or if the string
isn't empty, neither the if or the elseif statements will be triggered,
causing the else statement to be activated.  Either way, the images would
be printed out. *
*
*
*
*Did you mean to do this?*

?php
if($search-plugin-ListViewValue() ==  
$search-facebook-ListViewValue() == ) {
// Neither one has a value
} elseif ($search-plugin-ListViewValue() !=  
$search-facebook-ListViewValue() != ) {
// Both have a Value
echo 'a href=' . $search-plugin-ListViewValue() . 'img
src=images/twitter.gif width=22 height=23//a/a' . 'a
href=' . $search-facebook-ListViewValue() . 'img
src=images/facebook.gif width=22 height=23//a/a';
} elseif ($search-plugin-ListViewValue() != ) {
// Twitter has a value
echo 'a href=' . $search-plugin-ListViewValue() . 'img
src=images/twitter.gif width=22 height=23//a/a';
} else {
// Facebook has a value (only possible option left)
echo 'a href=' . $search-facebook-ListViewValue() . 'img
src=images/facebook.gif width=22 height=23//a/a';
}
?



Hope that helps,
Mike



On Tue, Mar 13, 2012 at 9:44 AM, Matijn Woudt tijn...@gmail.com wrote:

 On Tue, Mar 13, 2012 at 3:06 PM, Gu®u nagendra802...@gmail.com wrote:
  The issue is both the images are echoing and no if else statement is
  working.
 

 First of all, please bottom post on this (and probably any) mailing list.

 You should perhaps provide what the contents of
 $search-plugin-ListViewValue()== and
 $search-facebook-ListViewValue()== is.
 Though, if I understood you correctly, it would be as simple as:
 $facebookEnabled = $search-facebook-ListViewValue()!=;
 $twitterEnabled = $search-plugin-ListViewValue()!=;
 if($facebookEnabled)
  {

  echo 'a href='.$search-facebook-ListViewValue().'img
 src=images/facebook.gif width=22 height=23//a/a';
 }
  if($twitterEnabled)
  {

 echo 'a href='.$search-plugin-ListViewValue().'img
 src=images/twitter.gif width=22 height=23//a/a';
 }

 - Matijn

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




-- 
---

My command is this: Love each other as I
have loved you. John 15:12

---


Re: [PHP-DB] Help with If else if

2012-03-13 Thread Gu®u
No Michael, your code is also not working. What you have understood is
correct. let me explain it to others too.

If variable twitter and facebook are empty don't echo anything,

if variable twitter has a value and facebook is empty echo out only twitter,

if variable twitter has no value and facebook has a value echo out facebook
only,

and finally if both has values echo out both.

Basically I want to echo out only if there is some value in the database.
But in my case both the images are echoing out.




On Tue, Mar 13, 2012 at 8:54 PM, Michael Stowe m...@mikestowe.com wrote:

 From looking at your code, the issue is that your if statements are
 checking for the same criteria as your else statements, meaning that if the
 string is empty () the if statements will be triggered, and since the if
 statements are true, the elseif statement will not be.  Or if the string
 isn't empty, neither the if or the elseif statements will be triggered,
 causing the else statement to be activated.  Either way, the images would
 be printed out. *
 *
 *
 *
 *Did you mean to do this?*

 ?php
 if($search-plugin-ListViewValue() ==  
 $search-facebook-ListViewValue() == ) {
 // Neither one has a value
 } elseif ($search-plugin-ListViewValue() !=  
 $search-facebook-ListViewValue() != ) {
 // Both have a Value
 echo 'a href=' . $search-plugin-ListViewValue() . 'img
 src=images/twitter.gif width=22 height=23//a/a' . 'a
 href=' . $search-facebook-ListViewValue() . 'img
 src=images/facebook.gif width=22 height=23//a/a';
 } elseif ($search-plugin-ListViewValue() != ) {
 // Twitter has a value
 echo 'a href=' . $search-plugin-ListViewValue() . 'img
 src=images/twitter.gif width=22 height=23//a/a';
 } else {
 // Facebook has a value (only possible option left)
 echo 'a href=' . $search-facebook-ListViewValue() . 'img
 src=images/facebook.gif width=22 height=23//a/a';
 }
 ?



 Hope that helps,
 Mike



 On Tue, Mar 13, 2012 at 9:44 AM, Matijn Woudt tijn...@gmail.com wrote:

 On Tue, Mar 13, 2012 at 3:06 PM, Gu®u nagendra802...@gmail.com wrote:
  The issue is both the images are echoing and no if else statement is
  working.
 

 First of all, please bottom post on this (and probably any) mailing list.

 You should perhaps provide what the contents of
 $search-plugin-ListViewValue()== and
 $search-facebook-ListViewValue()== is.
 Though, if I understood you correctly, it would be as simple as:
 $facebookEnabled = $search-facebook-ListViewValue()!=;
 $twitterEnabled = $search-plugin-ListViewValue()!=;
 if($facebookEnabled)
  {

  echo 'a href='.$search-facebook-ListViewValue().'img
 src=images/facebook.gif width=22 height=23//a/a';
 }
  if($twitterEnabled)
  {

 echo 'a href='.$search-plugin-ListViewValue().'img
 src=images/twitter.gif width=22 height=23//a/a';
 }

 - Matijn

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




 --
 ---

 My command is this: Love each other as I
 have loved you. John 15:12

 ---




-- 
*Best,
*
*Gu®u*


Re: [PHP-DB] Help with If else if

2012-03-13 Thread Michael Stowe
Hmm, what happens with the code I sent you?  Just tested it on my end and
worked exactly as expected.

Try doing a
var_dump($search-plugin-ListViewValue(), $search-facebook-ListViewValue());
to make sure the data being returned is what's expected... you should be
getting string(0)  returned for both.

Thanks,
Mike



On Tue, Mar 13, 2012 at 10:53 AM, Gu®u nagendra802...@gmail.com wrote:

 No Michael, your code is also not working. What you have understood is
 correct. let me explain it to others too.

 If variable twitter and facebook are empty don't echo anything,

 if variable twitter has a value and facebook is empty echo out only
 twitter,

 if variable twitter has no value and facebook has a value echo out
 facebook only,

 and finally if both has values echo out both.

 Basically I want to echo out only if there is some value in the database.
 But in my case both the images are echoing out.




 On Tue, Mar 13, 2012 at 8:54 PM, Michael Stowe m...@mikestowe.com wrote:

 From looking at your code, the issue is that your if statements are
 checking for the same criteria as your else statements, meaning that if the
 string is empty () the if statements will be triggered, and since the if
 statements are true, the elseif statement will not be.  Or if the string
 isn't empty, neither the if or the elseif statements will be triggered,
 causing the else statement to be activated.  Either way, the images would
 be printed out. *
 *
 *
 *
 *Did you mean to do this?*

 ?php
 if($search-plugin-ListViewValue() ==  
 $search-facebook-ListViewValue() == ) {
 // Neither one has a value
 } elseif ($search-plugin-ListViewValue() !=  
 $search-facebook-ListViewValue() != ) {
 // Both have a Value
 echo 'a href=' . $search-plugin-ListViewValue() . 'img
 src=images/twitter.gif width=22 height=23//a/a' . 'a
 href=' . $search-facebook-ListViewValue() . 'img
 src=images/facebook.gif width=22 height=23//a/a';
 } elseif ($search-plugin-ListViewValue() != ) {
 // Twitter has a value
 echo 'a href=' . $search-plugin-ListViewValue() . 'img
  src=images/twitter.gif width=22 height=23//a/a';
 } else {
 // Facebook has a value (only possible option left)
 echo 'a href=' . $search-facebook-ListViewValue() . 'img
  src=images/facebook.gif width=22 height=23//a/a';
 }
 ?



 Hope that helps,
 Mike



 On Tue, Mar 13, 2012 at 9:44 AM, Matijn Woudt tijn...@gmail.com wrote:

 On Tue, Mar 13, 2012 at 3:06 PM, Gu®u nagendra802...@gmail.com wrote:
  The issue is both the images are echoing and no if else statement is
  working.
 

 First of all, please bottom post on this (and probably any) mailing list.

 You should perhaps provide what the contents of
 $search-plugin-ListViewValue()== and
 $search-facebook-ListViewValue()== is.
 Though, if I understood you correctly, it would be as simple as:
 $facebookEnabled = $search-facebook-ListViewValue()!=;
 $twitterEnabled = $search-plugin-ListViewValue()!=;
 if($facebookEnabled)
  {

  echo 'a href='.$search-facebook-ListViewValue().'img
 src=images/facebook.gif width=22 height=23//a/a';
 }
  if($twitterEnabled)
  {

 echo 'a href='.$search-plugin-ListViewValue().'img
 src=images/twitter.gif width=22 height=23//a/a';
 }

 - Matijn

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




 --
 ---

 My command is this: Love each other as I
 have loved you. John 15:12

 ---




 --
 *Best,
 *
 *Gu®u*




-- 
---

My command is this: Love each other as I
have loved you. John 15:12

---


Re: [PHP-DB] Help with If else if

2012-03-13 Thread Matijn Woudt
On Tue, Mar 13, 2012 at 4:53 PM, Gu®u nagendra802...@gmail.com wrote:
 No Michael, your code is also not working. What you have understood is
 correct. let me explain it to others too.

 If variable twitter and facebook are empty don't echo anything,

 if variable twitter has a value and facebook is empty echo out only twitter,

 if variable twitter has no value and facebook has a value echo out facebook
 only,

 and finally if both has values echo out both.

 Basically I want to echo out only if there is some value in the database.
 But in my case both the images are echoing out.


That's exactly what my code does too, except it's a bit simpler. If
mine isn't working too, then your input is probably different, try a
var_dump on the ListViewValue() items.

- Matijn

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



Re: [PHP-DB] Help with If else if

2012-03-13 Thread Gu®u
I tried the below code too considering may be the localhost is really dumb
and we need to tell each and every condition. But still its not working  :(


$tweet = $search-plugin-ListViewValue();
 $fb = $search-facebook-ListViewValue();


 if($tweet==  $fb==)
 {

echo ;

 }
 elseif($fb==  $tweet!=)
 {

 echo 'a href='.$search-plugin-ListViewValue().'img
src=images/twitter.gif width=22 height=23//a/a';


 }

 elseif($tweet==  $fb!=)
 {


 echo 'a
href='.$search-facebook-ListViewValue().'img
src=images/facebook.gif width=22 height=23//a/a';

 }

 elseif($fb!=  $tweet!=)
 {


echo 'a href='.$search-plugin-ListViewValue().'img
src=images/twitter.gif width=22 height=23//a/a'.'a
href='.$search-facebook-ListViewValue().'img
src=images/facebook.gif width=22 height=23//a/a';

 }



On Tue, Mar 13, 2012 at 9:44 PM, Matijn Woudt tijn...@gmail.com wrote:

 On Tue, Mar 13, 2012 at 4:53 PM, Gu®u nagendra802...@gmail.com wrote:
  No Michael, your code is also not working. What you have understood is
  correct. let me explain it to others too.
 
  If variable twitter and facebook are empty don't echo anything,
 
  if variable twitter has a value and facebook is empty echo out only
 twitter,
 
  if variable twitter has no value and facebook has a value echo out
 facebook
  only,
 
  and finally if both has values echo out both.
 
  Basically I want to echo out only if there is some value in the database.
  But in my case both the images are echoing out.
 

 That's exactly what my code does too, except it's a bit simpler. If
 mine isn't working too, then your input is probably different, try a
 var_dump on the ListViewValue() items.

 - Matijn




-- 
*Best,
*
*Gu®u*


[PHP-DB] Help with AVG()

2011-06-13 Thread Ron Piggott

Hi Everyone

I am trying to figure out how to write a SELECT query that will give me the 
average of `bible_anagrams`.`views` starting on the date specified in 
`bible_anagrams_rss_feed`.`rss_feed_date` and the previous 6 calendar days (for 
a total of 7 days).  What I am trying to figure out is the average of how many 
times the anagrams RSS Feed were accessed between June 1st and 7th, June 2nd 
and 8th, June 3rd and 9th, etc.

- There is 1 row for each date in the table bible_anagrams_rss_feed.
I tried the following syntax, but it is giving me an overall average, not by 
the date ranges:



SELECT AVG(`bible_anagrams`.`views`) AS average_views FROM `bible_anagrams` 
INNER JOIN `bible_anagrams_rss_feed` ON `bible_anagrams`.`reference` = 
`bible_anagrams_rss_feed`.`bible_anagrams_reference` ORDER BY 
`bible_anagrams_rss_feed`.`rss_feed_date` DESC LIMIT 7




I am wanting the query I am asking help for to be included as one of the mySQL 
results, where I have indicated “AVERAGE VIEWS QUERY HERE” (although if there 
is a better way I am opening to learning it):



SELECT `bible_anagrams_rss_feed`.`rss_feed_date` , 
`bible_anagrams`.`reference`, `bible_anagrams`.`bible_anagram_word` , 
`bible_anagrams`.`views` , 

(

AVERAGE VIEWS QUERY HERE

) AS average_views

FROM `bible_anagrams_rss_feed` INNER JOIN `bible_anagrams` ON 
`bible_anagrams`.`reference` = 
`bible_anagrams_rss_feed`.`bible_anagrams_reference` 
ORDER BY `bible_anagrams_rss_feed`.`rss_feed_date` DESC



Thanks for helping me,

Ron

The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info  


[PHP-DB] Help needed in searching a sentence in the code

2010-05-26 Thread nagendra prasad
Hi All,

I have this code where user can search a song or the entire song title. It
looks like when a user search a single word its searching and giving the
proper results. However if the user wants to search the entire sentence its
not giving the proper results. For example let say I have searched for the
MJ's song Earth Song, its giving me the proper results. However if I am
searching for the MJ's  Why You Wanna Trip On Me, its not giving me the
proper results. Below is the code:



?php


//get data
$button = $_GET['submit'];
$search = $_GET['search'];

$s = 0;
$s = $_GET['s'];
if (!$s)
$s = 0;
$i = 0;

$e = 30; // Just change to how many results you want per page


$next = $s + $e;
$prev = $s - $e;




 if (strlen($search)=2)


  echo brtable align='center'trtdsupdagger;/supfont
face='sana-serif' size='6'font color='blue'bsupa href='
http://localhost/searchengine/' style='text-decoration:
none'MP3dom/a/sup/b/b/fontfont face='sana-serif'
size='3'suptrade;/sup/tdtdsupform action='search.php'
method='GET'input type='text' onclick=value='' size='50' name='search'
value='$search' input type='submit' name='submit'
value='Search'/form/td/tr/table table bgcolor='#FF'
width='100%' height='1px'br //tabletable bgcolor='#f0f7f9'
width='100%' height='10px'trtddiv align='right'bMust be greater
then 3 chars/b/div/td/tr/tablep/sup;
 else
 {
  echo brtable align='center'trtddagger;font face='sana-serif'
size='6'font color='blue'ba href='http://localhost/searchengine/'
style='text-decoration: none'MP3dom/a/b/b/fontfont
face='sana-serif' size='3'suptrade;/sup/tdtdsubform
action='search.php' method='GET'input type='text' onclick=value=''
size='50' name='search' value='$search'input type='submit' name='submit'
value='Search'/form/td/tr/table/sub;

  //connect to database
  mysql_connect(localhost,root,);
  mysql_select_db(mp3);



   //explode out search term
   $search_exploded = explode( ,$search);

   foreach($search_exploded as $search_each)
   {

//construct query
$x++;
if ($x==1)
 $construct .= name LIKE '%$search_each%';
else
 $construct .=  OR name LIKE '%$search_each%';

   }

  //echo outconstruct
  $constructx = SELECT * FROM data WHERE $construct;

  $construct = SELECT * FROM data WHERE $construct LIMIT $s,$e ;
  $run = mysql_query($constructx);

  $foundnum = mysql_num_rows($run);


  $run_two = mysql_query($construct);

  if ($foundnum==0)
   echo table bgcolor='#F1EDC2' width='100%' height='1px'br
//tabletable bgcolor='#f0f7f9' width='100%' height='10px'trtddiv
align='right'No results found for
b$search/b/div/td/tr/tablep;
  else
  {
   echo table bgcolor='#F1EDC2' width='100%' height='1px'br
//tabletable bgcolor='#f0f7f9' width='100%' height='10px'trtddiv
align='right'Showing 1-30 of b$foundnum/b results found for
b$search./b/div/td/tr/tablep;







   print 'table bgcolor=#F1EDC2 width=700  height=30 border=0
align=center ';
   print 'tr';

 print 'td width=100 nowrap=nowrapstrongArtist/strong/td';
 print 'td width=250 nowrap=nowrapstrongSong
Name/strong/td';
 print 'td width=50 nowrap=nowrapstrongMovie
Date/strong/td';
 print 'td width=50 nowrap=nowrapstrongSize/strong/td';

   print '/tr';
   while ($runrows = mysql_fetch_assoc($run_two))
   {
//get data
   $type = $runrows['artist'];
   $date = $runrows['date'];
   $name = $runrows['name'];
   $size = $runrows['size'];



 foreach ($runrows as $row)
{
  if ($i % 2 != 0) # An odd row
$rowColor = #EBECE4;
  else # An even row
$rowColor = #FEF1E9;



 print 'table width=700 height=30 border=0 align=center';

}


   print '?php do { ?';
 print 'tr bgcolor=' . $rowColor . '';

   print 'td nowrap=nowrap width=100'.'font color=:blue
size=2'.$type.'/td';
   //print 'td nowrap=nowrap width=250'.'font size=2'.a
herf='$url'$name.'/td';

   print 'td nowrap=nowrap width=250'.'font color=blue
size=2'.a href='download.php?url=$url'$name.'/font/td';


   print 'td nowrap=nowrap width=100 align=center'.'font
size=2'.$date .'/td';
   print 'td nowrap=nowrap width=50'.'font size=2'.$size
.'/td';
   print 'td nowrap=nowrap width=25'.'font size=2'.$se
.'/td';
   print 'td nowrap=nowrap width=25'.'font size=2'.$le
.'/td';
 print '/tr';



 print '/table';
 print '/body';
 print '/html';

   }
?


table width='100%'
tr
td
div align=center
brbr
?php
if (!$s=0)
 echo a href='search.php?search=$searchs=$prev'Prev/a;

$i =1;
for ($x=0;$x$foundnum;$x=$x+$e)
{


 echo  a href='search.php?search=$searchs=$x'$i/a ;


$i++;


}

if ($s$foundnum-$e)
  echo a href='search.php?search=$searchs=$next'Next/a;

}
}


?
/div
/td
/tr
/table


***

Also, the above code is giving me the below errors:

*Notice*: Undefined index: s in *C:\wamp\www\searchengine\search.php* on
line *11
**Notice*: Undefined variable: x in *C:\wamp\www\searchengine\search.php* on
line *46*

*Notice*: Undefined variable: 

[PHP-DB] Help with mysql data sorting using php

2010-05-17 Thread nagendra prasad
Hi All,

I have a database of MP3's in mysql. The database contains MP3 name, artist,
date, size etc. I need to order the search results in both ascending and
descending order. For example if user wants to see the size of all mp3's in
ASC order he will click on size column and again if he wants to see the
MP3's in DEC order he can click on the size column. Suppose the MP3's are
arranged in ASC order and if he clicks on size column the data should
arrange in DEC order.

Any idea how I should go about it ?

Please help me :)

Best,
Guru.


Re: [PHP-DB] Help with mysql data sorting using php

2010-05-17 Thread nagendra prasad
DB is like more then 500MB

and it will grow day by day :)



On Mon, May 17, 2010 at 12:46 PM, Artur Ejsmont ejsmont.ar...@gmail.comwrote:

 If the DB is very small use tablesorter plugin of jquery. Otherwise
 custumizable query method.

 On 17 May 2010 07:56, nagendra prasad nagendra802...@gmail.com wrote:

 Hi All,

 I have a database of MP3's in mysql. The database contains MP3 name,
 artist,
 date, size etc. I need to order the search results in both ascending and
 descending order. For example if user wants to see the size of all mp3's in
 ASC order he will click on size column and again if he wants to see the
 MP3's in DEC order he can click on the size column. Suppose the MP3's are
 arranged in ASC order and if he clicks on size column the data should
 arrange in DEC order.

 Any idea how I should go about it ?

 Please help me :)

 Best,
 Guru.




Re: [PHP-DB] Help with mysql data sorting using php

2010-05-17 Thread Artur Ejsmont
Hehe. Then a method: ) just make a query builder method like 'findSongs'
with all the params ( optional or mandatory ) like page, limit, sortby,
filters etc. then inside build SQL based on args.  Just be careful - SQL
injection is your enemy here. From app pass all the args from get/ post and
that's it. Good luck.

On 17 May 2010 08:18, nagendra prasad nagendra802...@gmail.com wrote:

DB is like more then 500MB

and it will grow day by day :)





On Mon, May 17, 2010 at 12:46 PM, Artur Ejsmont ejsmont.ar...@gmail.com
wrote:

 If the DB i...


Re: [PHP-DB] Help with mysql data sorting using php

2010-05-17 Thread nagendra prasad
Hi Artur,

I am a beginner to this stuff. So, If you or anyone can give me some example
codes or may be some links for my reference that would be a great help.

Best,
Guru.

On Mon, May 17, 2010 at 12:57 PM, Artur Ejsmont ejsmont.ar...@gmail.comwrote:

 Hehe. Then a method: ) just make a query builder method like 'findSongs'
 with all the params ( optional or mandatory ) like page, limit, sortby,
 filters etc. then inside build SQL based on args.  Just be careful - SQL
 injection is your enemy here. From app pass all the args from get/ post and
 that's it. Good luck.

 On 17 May 2010 08:18, nagendra prasad nagendra802...@gmail.com wrote:

 DB is like more then 500MB

 and it will grow day by day :)





 On Mon, May 17, 2010 at 12:46 PM, Artur Ejsmont ejsmont.ar...@gmail.com
 wrote:
 
  If the DB i...




Re: [PHP-DB] Help with mysql data sorting using php

2010-05-17 Thread kesavan trichy rengarajan
take a look at this:
http://datatables.net/examples/data_sources/server_side.html

On Mon, May 17, 2010 at 5:30 PM, nagendra prasad
nagendra802...@gmail.comwrote:

 Hi Artur,

 I am a beginner to this stuff. So, If you or anyone can give me some
 example
 codes or may be some links for my reference that would be a great help.

 Best,
 Guru.

 On Mon, May 17, 2010 at 12:57 PM, Artur Ejsmont ejsmont.ar...@gmail.com
 wrote:

  Hehe. Then a method: ) just make a query builder method like 'findSongs'
  with all the params ( optional or mandatory ) like page, limit, sortby,
  filters etc. then inside build SQL based on args.  Just be careful - SQL
  injection is your enemy here. From app pass all the args from get/ post
 and
  that's it. Good luck.
 
  On 17 May 2010 08:18, nagendra prasad nagendra802...@gmail.com
 wrote:
 
  DB is like more then 500MB
 
  and it will grow day by day :)
 
 
 
 
 
  On Mon, May 17, 2010 at 12:46 PM, Artur Ejsmont ejsmont.ar...@gmail.com
 
  wrote:
  
   If the DB i...
 
 



[PHP-DB] help needed.

2010-03-17 Thread Vinay Kannan
Hello Guys,

I am developing an application, which would have a front end in Flash, and
the backend would be MySQL, now what I am thinking is to package this as an
exe file, similar to WAMP, which installs everything, So my exe should have
all my files, the MySQL data dump and should auto install PHP, APACHE,
MySQL, can something like this be done, i am sure it can be done, but how do
I do it, any guidelines please?


Thanks,
Vinay Kannan.


Re: [PHP-DB] help in implementing a progress bar

2010-01-11 Thread Philip Thompson
On Jan 7, 2010, at 2:36 PM, Vinay Kannan wrote:

 Hello,
 
 Theres this project that I am working on, and a specific module does take
 few secs to process, I am thinking it would be cool to be showing a progress
 bar(some kind on a .gif image) while the script runs, does any one have an
 idea how to implement this?
 
 Thanks,
 Vinay K

This isn't really database related, but ok...

?php
// Progress.php
class Progress {
public function start () {
echo file_get_contents ('progress.html');
flush ();
}
public function end ($url) {
$text  = script type=\text/javascript\;
$text .= window.location = '$url';;
$text .= /script;

echo $text;
flush ();
}
}
?

?php
// process.php - process the stuff
$progress = new Progress();
$progress-start();
// ... Do your processing here ...
$progress-end('nextpage.php');
?

In the progress.html file, it would just be an html page that has an animated 
gif (and whatever else you want on it). Hope this helps.

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



[PHP-DB] help in implementing a progress bar

2010-01-07 Thread Vinay Kannan
Hello,

Theres this project that I am working on, and a specific module does take
few secs to process, I am thinking it would be cool to be showing a progress
bar(some kind on a .gif image) while the script runs, does any one have an
idea how to implement this?

Thanks,
Vinay K


[PHP-DB] Help for a beginner

2009-12-23 Thread Adam Sonzogni
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/


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



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] HELP! PHP 4.4.4 and MySQL 4.1 - Can't find php_mysql.dll

2009-02-19 Thread Chris

John Burns wrote:

I did that but the php_mysql.dll is not in any of the zips from any of
the packages I tried downloading. I need to stay in PHP 4 because of
some applications. No matter what zip package I downloaded,
php_mysql.dll was not in the extensions directory. I tried a bunch of
different 4.x releases. I tried downloading the source code and saw
the mysql extensions uncompiled but I don't know how to compile.
That's why I'm so confused as to why the php_mysql.dll file is not in
any of the Windows binary zip packages. Take a look for yourself and
see if you can find a zip that has that file in it. If you can, I'd be
greatly appreciative.


Please always cc the mailing list so others can see your response and 
offer their suggestions.


Maybe ask on the php-windows mailing list, they might have better 
suggestions (and include what you've already tried).


--
Postgresql  php tutorials
http://www.designmagick.com/


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



[PHP-DB] HELP! PHP 4.4.4 and MySQL 4.1 - Can't find php_mysql.dll

2009-02-18 Thread John Burns
I'm using Windows 2003, IIS and PHP 4.4.4 with MySQL 4.1. I had this
same setup on a server that got corrupted by a virus. I can't use any
of the files from the old setup so I'm trying to reinstall the same
versions. However, I can't find a php_mysql.dll file that will work.
All of the zip packages I download from php.net don't have the
php_mysql.dll file in the extensions folder. They have everything else
but that. Am I missing something? Please help if you have any idea.
The one php_mysql.dll file I did find and dropped in gives me the
following error:

Unable to initialize module Module compiled with module API=20050922,
debug=0, thread-safety=1 PHP compiled with module API=20020429,
debug=0, thread-safety=1 These options need to match in Unknown on
line 0

I'm guessing that means that PHP was compiled older than the
php_mysql.dll and that the dll is too new. Does someone have the older
version? Thanks in advance for the help!

John

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



Re: [PHP-DB] HELP! PHP 4.4.4 and MySQL 4.1 - Can't find php_mysql.dll

2009-02-18 Thread Chris

John Burns wrote:

I'm using Windows 2003, IIS and PHP 4.4.4 with MySQL 4.1. I had this
same setup on a server that got corrupted by a virus. I can't use any
of the files from the old setup so I'm trying to reinstall the same
versions. However, I can't find a php_mysql.dll file that will work.
All of the zip packages I download from php.net don't have the
php_mysql.dll file in the extensions folder. They have everything else
but that. Am I missing something? Please help if you have any idea.
The one php_mysql.dll file I did find and dropped in gives me the
following error:

Unable to initialize module Module compiled with module API=20050922,
debug=0, thread-safety=1 PHP compiled with module API=20020429,
debug=0, thread-safety=1 These options need to match in Unknown on
line 0


As you found out, you can't do that - they need to come from the same 
release.


Try here:

http://www.php.net/releases/

Grab the 4.4.4 windows zipfile and that should have all of the 
extensions you need.


--
Postgresql  php tutorials
http://www.designmagick.com/


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



[PHP-DB] Help me with this someone

2009-02-09 Thread Wilson Osemeilu
i get the error:
Warning: mysql_pconnect() [function.mysql-pconnect]: Lost connection to MySQL 
server during query in /home/www/broadwaysecure.biz.nf/Index.php on line 9
Could not connect : Lost connection to MySQL server during query
 
 
I have done everything to connect to my database but its not working
this is my database information:
host: fdb1.biz.nf or  82.197.130.17 (pinged and working)
db name: 218708_accounts
pass: 


  

[PHP-DB] Help with Web services (facebook, myspace)

2009-01-21 Thread Abah Joseph
Hello PHP people,
I`m looking for facebook and myspace API that will enable user to login on
my site using their facebook and myspace id. if this is not possible, can i
find something closer like, user will be able to perform
some activities from my site like inviting facebook/myspace friends, send
IVs etc.

Please very new in this.

Thank you


Re: [PHP-DB] Help with Web services (facebook, myspace)

2009-01-21 Thread Chris

Abah Joseph wrote:

Hello PHP people,
I`m looking for facebook and myspace API that will enable user to login on
my site using their facebook and myspace id. if this is not possible, can i
find something closer like, user will be able to perform
some activities from my site like inviting facebook/myspace friends, send
IVs etc.


http://developers.facebook.com/?ref=pf

I don't know if myspace has a developer area but ask in their forum:

http://forums.myspace.com/?fuseaction=forums.home

--
Postgresql  php tutorials
http://www.designmagick.com/


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



Re: [PHP-DB] Help with Web services (facebook, myspace)

2009-01-21 Thread Abah Joseph
I just saw something on pear.net
http://pear.php.net/package/Services_Facebookmaybe it will work.


On Wed, Jan 21, 2009 at 10:27 PM, Chris dmag...@gmail.com wrote:

 Abah Joseph wrote:

 Hello PHP people,
 I`m looking for facebook and myspace API that will enable user to login on
 my site using their facebook and myspace id. if this is not possible, can
 i
 find something closer like, user will be able to perform
 some activities from my site like inviting facebook/myspace friends, send
 IVs etc.


 http://developers.facebook.com/?ref=pf

 I don't know if myspace has a developer area but ask in their forum:

 http://forums.myspace.com/?fuseaction=forums.home

 --
 Postgresql  php tutorials
 http://www.designmagick.com/




-- 
I develop dynamic website with PHP  MySql, Let me know about your site


[PHP-DB] help me JOIN 3 tables.

2009-01-13 Thread Abah Joseph
I have this SQL

SELECT e1.*, l1.* FROM e1
INNER JOIN l1 WHERE e1.entre_active = 'Y' AND l1.entreID = e1.entre_id

The above query works but i want to add the one below

SELECT SUM(a1.adp_amount) as amount FROM a1 WHERE a1.adp_loanID = e1.loanID;

the last part of the query is to SUM the part payment made on table 'l1' and
return total raised with the first query.

the whole idea is three tables, (business, loan, raised), loan referenced ID
from business, raised referenced ID from loan.

loan maybe $300 and it can be raised over time till completed, so all the
amount raised + the loanId will be stored inside the raised table.

Thank you


Re: [PHP-DB] help me JOIN 3 tables.

2009-01-13 Thread Yves Sucaet

Hi Joseph,

With the sum() aggregate function you'll need to use a GROUP BY clause and 
specify which fields you want from e1 and l1. Something like this:


SELECT e1.field1, e1.field2, l1.field3, SUM(a1.adp_amount) as amount
FROM a1 inner join e1 on (a1.loanID = a1.adp_loanID) inner join l1 on 
(l1.entreID = e1.entre_ID)

WHERE e1.entre_active = 'Y'

hth,

Yves

- Original Message - 
From: Abah Joseph joefa...@gmail.com

To: php-db@lists.php.net
Sent: Tuesday, January 13, 2009 6:46 AM
Subject: [PHP-DB] help me JOIN 3 tables.



I have this SQL

SELECT e1.*, l1.* FROM e1
INNER JOIN l1 WHERE e1.entre_active = 'Y' AND l1.entreID = e1.entre_id

The above query works but i want to add the one below

SELECT SUM(a1.adp_amount) as amount FROM a1 WHERE a1.adp_loanID = 
e1.loanID;


the last part of the query is to SUM the part payment made on table 'l1' 
and

return total raised with the first query.

the whole idea is three tables, (business, loan, raised), loan referenced 
ID

from business, raised referenced ID from loan.

loan maybe $300 and it can be raised over time till completed, so all the
amount raised + the loanId will be stored inside the raised table.

Thank you





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



Re: [PHP-DB] help me JOIN 3 tables. - fixed query

2009-01-13 Thread Yves Sucaet

Oops, actually forgot my GROUP BY clause. The full query is:

SELECT e1.field1, e1.field2, l1.field3, SUM(a1.adp_amount) as amount
FROM a1
inner join e1 on (e1.loanID = a1.adp_loanID)
inner join l1 on (l1.entreID = e1.entre_ID)
WHERE e1.entre_active = 'Y'
GROUP BY e1.field1, e1.field2, l1.field3

hth,

Yves

- Original Message - 
From: Yves Sucaet yves.suc...@usa.net

To: php-db@lists.php.net
Sent: Tuesday, January 13, 2009 7:49 AM
Subject: Re: [PHP-DB] help me JOIN 3 tables.



Hi Joseph,

With the sum() aggregate function you'll need to use a GROUP BY clause and 
specify which fields you want from e1 and l1. Something like this:


SELECT e1.field1, e1.field2, l1.field3, SUM(a1.adp_amount) as amount
FROM a1 inner join e1 on (e1.loanID = a1.adp_loanID) inner join l1 on 
(l1.entreID = e1.entre_ID)

WHERE e1.entre_active = 'Y'

hth,

Yves

- Original Message - 
From: Abah Joseph joefa...@gmail.com

To: php-db@lists.php.net
Sent: Tuesday, January 13, 2009 6:46 AM
Subject: [PHP-DB] help me JOIN 3 tables.



I have this SQL

SELECT e1.*, l1.* FROM e1
INNER JOIN l1 WHERE e1.entre_active = 'Y' AND l1.entreID = e1.entre_id

The above query works but i want to add the one below

SELECT SUM(a1.adp_amount) as amount FROM a1 WHERE a1.adp_loanID = 
e1.loanID;


the last part of the query is to SUM the part payment made on table 'l1' 
and

return total raised with the first query.

the whole idea is three tables, (business, loan, raised), loan referenced 
ID

from business, raised referenced ID from loan.

loan maybe $300 and it can be raised over time till completed, so all the
amount raised + the loanId will be stored inside the raised table.

Thank you





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






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



[PHP-DB] Help needed - SELECT query optimization

2008-10-26 Thread Nitsan Bin-Nun
Hi,
I have a mysql database with one table in it, currently it contains 36,807
records and it costs 6.8MB of space, every night another thousand~ of rows
are being added to the table.
The scheme (as taken from phpmyadmin) is like follows:

CREATE TABLE IF NOT EXISTS `search` (
  `id` int(11) NOT NULL auto_increment,
  `time` int(10) default NULL,
  `unique` varchar(255) collate utf8_unicode_ci default NULL,
  `site` varchar(50) collate utf8_unicode_ci default NULL,
  `url` varchar(255) collate utf8_unicode_ci default NULL,
  `filename` varchar(255) collate utf8_unicode_ci default NULL,
  `snippet` varchar(255) collate utf8_unicode_ci default NULL,
  `tags` varchar(255) collate utf8_unicode_ci default NULL,
  `password` varchar(255) collate utf8_unicode_ci default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
AUTO_INCREMENT=44306 ;


insert example:

INSERT INTO `search` VALUES (null, 1225041602, '110755357', 'rapidshare', '
http://rapidshare.com/files/110755357/Taxi4.By.HuNTeR.part1.rar',
'Taxi4.By.HuNTeR.part1.rar', 'Taxi 4 (2007) DVDRip XviD - KL', '',
'--'),(null, 1225041602, '110756297', 'rapidshare', '
http://rapidshare.com/files/110756297/Taxi4.By.HuNTeR.part2.rar',
'Taxi4.By.HuNTeR.part2.rar', 'Taxi 4 (2007) DVDRip XviD - KL', '',
'--'),(null, 1225041602, '110767009', 'rapidshare', '
http://rapidshare.com/files/110767009/Taxi4.By.HuNTeR.part3.rar',
'Taxi4.By.HuNTeR.part3.rar', 'Taxi 4 (2007) DVDRip XviD - KL', '',
'--'),(null, 1225041602, '110768015', 'rapidshare', '
http://rapidshare.com/files/110768015/Taxi4.By.HuNTeR.part4.rar',
'Taxi4.By.HuNTeR.part4.rar', 'Taxi 4 (2007) DVDRip XviD - KL', '',
'--'),(null, 1225041602, '110779013', 'rapidshare', '
http://rapidshare.com/files/110779013/Taxi4.By.HuNTeR.part5.rar',
'Taxi4.By.HuNTeR.part5.rar', 'Taxi 4 (2007) DVDRip XviD - KL', '',
'--'),(null, 1225041602, '110792243', 'rapidshare', '
http://rapidshare.com/files/110792243/Taxi4.By.HuNTeR.part6.rar',
'Taxi4.By.HuNTeR.part6.rar', 'Taxi 4 (2007) DVDRip XviD - KL', '',
'--'),(null, 1225041602, '110793721', 'rapidshare', '
http://rapidshare.com/files/110793721/Taxi4.By.HuNTeR.part7.rar',
'Taxi4.By.HuNTeR.part7.rar', 'Taxi 4 (2007) DVDRip XviD - KL', '', '--');

It should be a rapidshare links database (which updates with a PHP crawler I
wroted last Saturday).
I would like to change the snippet to title and add another column for the
snippet,
My main queries are INSERT's - a big insert (usually 10-100 links per
insert) in each hour.
My crawler is checking if the link it is about to add is already in the
database with a select query like this:
SELECT `id` FROM `tbl_name` WHERE `unique` = '%_UNIQUE_VARIABLE_%'

I'm definiatly not an database scheme expert, I'm looking to optimaize the
table for fast select queries (to check if file is already exists)
And for fast filename-based search (select * from `tbl_name` where
`filename` like '%_WHATEVER_%')

The unique colmn is used for other websites unique ID's as well so I don't
think I have any chance to crop it's length.
I probably can change the site colmn to numeric id or something (I'm just
about doing that) - but this is not the real problems, I have heard about
something called Indexes but I have no idea what this is about.

I hope I will find an answer, or a path where to look for in order to get
this table optimaized,

Thanks in Advance,
Nitsan


Re: [PHP-DB] Help needed - SELECT query optimization

2008-10-26 Thread Chris



It should be a rapidshare links database (which updates with a PHP crawler I
wroted last Saturday).
I would like to change the snippet to title and add another column for the
snippet,
My main queries are INSERT's - a big insert (usually 10-100 links per
insert) in each hour.
My crawler is checking if the link it is about to add is already in the
database with a select query like this:
SELECT `id` FROM `tbl_name` WHERE `unique` = '%_UNIQUE_VARIABLE_%'


create index unique_idx on tbl_name(unique);

mysql might work better with this index:

create index unique_idx on tbl_name(unique, id);

because in some cases it doesn't have to go back to the data file to get 
the actual data, it can just read everything from the index.



I'm definiatly not an database scheme expert, I'm looking to optimaize the
table for fast select queries (to check if file is already exists)
And for fast filename-based search (select * from `tbl_name` where
`filename` like '%_WHATEVER_%')


like queries are harder to optimize.

If you put a wildcard at the front:

like '%...%';

the db can't use an index to find it, because you're saying the text can 
be anywhere and for that type of search you're best off setting up 
fulltext (http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html).


If you don't put a % at the front:

like '...%';

the db use an index to find it (up until the wildcard)..

create index filename_idx on tbl_name(filename);


To understand indexing, check out my article:

http://www.designmagick.com/article/16/PostgreSQL/How-to-index-a-database

(Yes it's on a postgres site but the ideas/understanding work for all 
db's - and the commands should even work for mysql).


--
Postgresql  php tutorials
http://www.designmagick.com/


--
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-11 Thread Dee Ayy
On Fri, Aug 8, 2008 at 5:25 PM, Micah Gersten [EMAIL PROTECTED] wrote:
 How about select Incidents.* from Incidents inner join Calls on
 Incidents.id=Calls.incidentid where Calls.status='Open'?
...

 Dee Ayy wrote:
...
 The status column never has the text Open.
...

-- 
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-11 Thread Micah Gersten
Use an appropriate status.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Dee Ayy wrote:
 On Fri, Aug 8, 2008 at 5:25 PM, Micah Gersten [EMAIL PROTECTED] wrote:
   
 How about select Incidents.* from Incidents inner join Calls on
 Incidents.id=Calls.incidentid where Calls.status='Open'?
 
 ...
   
 Dee Ayy wrote:
 
 ...
   
 The status column never has the text Open.
   
 ...
   

-- 
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-11 Thread Dee Ayy
On Sat, Aug 9, 2008 at 1:32 AM, Niel Archer [EMAIL PROTECTED] wrote:
  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

With the id (auto incremented int), the last record of either table
would be the largest id in a particular group.


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

I'll modify that as you said.

My real concern is that $theHugeListOfIncidentIds keeps growing and is
used in the Calls.id IN ($theHugeListOfIncidentIds).

Even if the $theHugeListOfIncidentIds was replaced with an actual
MySQL query instead of first being processed by PHP, I think that is a
bad approach (but maybe that is the solution if I only change this
query and do not change/add columns or states).

-- 
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



[PHP-DB] Help to improve MySQL query

2008-08-08 Thread Dee Ayy
A database was designed with the following tables:

Incidents
_
id (auto incremented int)
...

Calls
_
id (auto incremented int)
incidentId (foreign key)
status (varchar 32)
...

The status of the last Call is the status of the related Incident.
Statuses can be Not started through various states up to Completed.
The status column never has the text Open.
If the last Call for the related Incident is not Completed, then it
is considered to be Open.

My task is to getIncidentsWithStatus(Open) using PHP.

The existing inefficient method is in the PHP function
getIncidentsWithStatus($status = Open), made worse by mingling with
PHP and then another MySQL query.  It first finds
$theHugeListOfIncidentIds of the last Calls OF ALL INCIDENTS, then
uses Calls.id IN ($theHugeListOfIncidentIds) AND Calls.status NOT LIKE
'Completed'.  The reason this was done was that if Calls.status NOT
LIKE 'Completed' was used first, then the result would include all
Incidents.

A) What would be an efficient MySQL query with the database in the
present state to getIncidentsWithStatus(Open)?

I can think of two alternatives, which require the database to be modified:
1a) Add a trigger to update a new column named statusFromCall in the
Incidents table when the Calls.status is updated.
1b) Add PHP code to update the new column named statusFromCall in
the Incidents table when the Calls.status is updated.
2) Then just query for Incidents WHERE statusFromCall NOT LIKE 'Completed'.

B) What would be the MySQL query to create such a trigger in 1a?

Thanks.

-- 
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-08 Thread Micah Gersten
How about select Incidents.* from Incidents inner join Calls on
Incidents.id=Calls.incidentid where Calls.status='Open'?

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Dee Ayy wrote:
 A database was designed with the following tables:

 Incidents
 _
 id (auto incremented int)
 ...

 Calls
 _
 id (auto incremented int)
 incidentId (foreign key)
 status (varchar 32)
 ...

 The status of the last Call is the status of the related Incident.
 Statuses can be Not started through various states up to Completed.
 The status column never has the text Open.
 If the last Call for the related Incident is not Completed, then it
 is considered to be Open.

 My task is to getIncidentsWithStatus(Open) using PHP.

 The existing inefficient method is in the PHP function
 getIncidentsWithStatus($status = Open), made worse by mingling with
 PHP and then another MySQL query.  It first finds
 $theHugeListOfIncidentIds of the last Calls OF ALL INCIDENTS, then
 uses Calls.id IN ($theHugeListOfIncidentIds) AND Calls.status NOT LIKE
 'Completed'.  The reason this was done was that if Calls.status NOT
 LIKE 'Completed' was used first, then the result would include all
 Incidents.

 A) What would be an efficient MySQL query with the database in the
 present state to getIncidentsWithStatus(Open)?

 I can think of two alternatives, which require the database to be modified:
 1a) Add a trigger to update a new column named statusFromCall in the
 Incidents table when the Calls.status is updated.
 1b) Add PHP code to update the new column named statusFromCall in
 the Incidents table when the Calls.status is updated.
 2) Then just query for Incidents WHERE statusFromCall NOT LIKE 'Completed'.

 B) What would be the MySQL query to create such a trigger in 1a?

 Thanks.

   

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



Re: [PHP-DB] Help in concatenation

2008-06-07 Thread Nitsan Bin-Nun
1.
a class=?php print($class);? href=?php
print($thispage.($y0?(?start=).$y:));??php
print($pg);?/a
2.  a href=?php print($thispage.($next0?(?start=).$next:));?/a

turns into:


 ?php
 $string = 'a class=' . $class . ' href=' . $thispage;
 if ($y  0) $string .= \$start= . $y;
 $string .= '' . $pg . '/a';
 ?






 ?php
 $string2 = 'a href=' . $thispage;
 if ($next  0) $string2 .= '?start=' . $next;
 $string2 .= '/a';
 ?

I can squeeze the if operation into the string but I can't see good cause
for this (this is less spageti this way)
On 06/06/2008, Nasreen Laghari [EMAIL PROTECTED] wrote:

 Hi,

 I need to change PHP embeded in HTML to HTML embeded in PHP as trying to
 use modularity approach.
 I'm stuck on below these lines where concatenation is the big issue. I have
 researched, read but couldnt sort this out after try really hard.
 Could any one please help me to change this code to HTML embeded in PHP
 please. Mostly i'm getting confuse where text is written in red
 I know it is very basic question but this concatenation is confusing me so
 much. I have spended my whole day in sorting this out but :(
 1. a class=?php print($class);? href=?php
 print($thispage.($y0?(?start=).$y:));??php print($pg);?/a
 2.  a href=?php
 print($thispage.($next0?(?start=).$next:));?/a
 Thank you





Re: [PHP-DB] Help in concatenation - modular development

2008-06-07 Thread YVES SUCAET
If you want to go for a modular approach, you should consider switching to a
solution such as Smarty: http://www.smarty.net for more info.

HTH,

Yves

-- Original Message --
Received: Sat, 07 Jun 2008 11:55:38 AM CDT
From: Nitsan Bin-Nun [EMAIL PROTECTED]
To: Nasreen Laghari [EMAIL PROTECTED]Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] Help in concatenation

1.
a class=?php print($class);? href=?php
print($thispage.($y0?(?start=).$y:));??php
print($pg);?/a
2.  a href=?php
print($thispage.($next0?(?start=).$next:));?/a

turns into:


 ?php
 $string = 'a class=' . $class . ' href=' . $thispage;
 if ($y  0) $string .= \$start= . $y;
 $string .= '' . $pg . '/a';
 ?






 ?php
 $string2 = 'a href=' . $thispage;
 if ($next  0) $string2 .= '?start=' . $next;
 $string2 .= '/a';
 ?

I can squeeze the if operation into the string but I can't see good cause
for this (this is less spageti this way)
On 06/06/2008, Nasreen Laghari [EMAIL PROTECTED] wrote:

 Hi,

 I need to change PHP embeded in HTML to HTML embeded in PHP as trying to
 use modularity approach.
 I'm stuck on below these lines where concatenation is the big issue. I have
 researched, read but couldnt sort this out after try really hard.
 Could any one please help me to change this code to HTML embeded in PHP
 please. Mostly i'm getting confuse where text is written in red
 I know it is very basic question but this concatenation is confusing me so
 much. I have spended my whole day in sorting this out but :(
 1. a class=?php print($class);? href=?php
 print($thispage.($y0?(?start=).$y:));??php print($pg);?/a
 2.  a href=?php
 print($thispage.($next0?(?start=).$next:));?/a
 Thank you








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



[PHP-DB] Help in concatenation

2008-06-06 Thread Nasreen Laghari
Hi,
 
I need to change PHP embeded in HTML to HTML embeded in PHP as trying to use 
modularity approach.
I'm stuck on below these lines where concatenation is the big issue. I have 
researched, read but couldnt sort this out after try really hard.
Could any one please help me to change this code to HTML embeded in PHP please. 
Mostly i'm getting confuse where text is written in red
I know it is very basic question but this concatenation is confusing me so 
much. I have spended my whole day in sorting this out but :(
1. 
a class=?php print($class);? href=?php print($thispage.($y0?(?start=).$y:));??php print($pg);?/a
2.  a href=?php print($thispage.($next0?(?start=).$next:));?/a 
Thank you


  

[PHP-DB] Help needed PHP with Excel database

2008-05-31 Thread JDP
Hi I am a PHP beginner and using Namo Webeditor trial version in 
order


to access an Excel file via ODBC...and I get no result
Namo generates the following code:
=
?
   $a_startrow = $startrow;
   $a_maxrows = $maxrows;
require('wed_php_odbc.inc');
?html
head
titleSans titre/title
meta name=generator content=Namo WebEditor v6.0
/head
body bgcolor=white text=black link=blue vlink=purple 
alink=red

?
   $w_disprows = 10;
   $w_sqlstr = SELECT Feuli1$_FilterDatabase.Country,
Feuli1$_FilterDatabase.Customer Name, Feuli1$_FilterDatabase.Model,
Feuli1$_FilterDatabase.Description, Feuli1$_FilterDatabase.Order 
Number,

Feuli1$_FilterDatabase.Quantity FROM Feuli1$_FilterDatabase;
   wed_read_list_process (trydb, , , $w_sqlstr, $w_record,
$w_disprows, $a_startrow, $a_maxrows, $w_rows);
?table border=1
   tr
   td width=160Feuli1$_FilterDatabase.Country/td
   td width=160Feuli1$_FilterDatabase.Customer Name/td
   td width=160Feuli1$_FilterDatabase.Model/td
   td width=160Feuli1$_FilterDatabase.Description/td
   td width=160Feuli1$_FilterDatabase.Order Number/td
   td width=160Feuli1$_FilterDatabase.Quantity/td
   /tr
?
   for ($w_i = 0; $w_i  $w_rows; $w_i++) {
$f_Feuli1__FilterDatabase_Country = $w_record[$w_i][0];
$f_Feuli1__FilterDatabase_Customer_Name = $w_record[$w_i][1];
$f_Feuli1__FilterDatabase_Model = $w_record[$w_i][2];
$f_Feuli1__FilterDatabase_Description = $w_record[$w_i][3];
$f_Feuli1__FilterDatabase_Order_Number = $w_record[$w_i][4];
$f_Feuli1__FilterDatabase_Quantity = $w_record[$w_i][5];
?tr
   td width=162?
wed_write($f_Feuli1__FilterDatabase_Country);
?/td
   td width=162?

wed_write($f_Feuli1__FilterDatabase_Customer_Name);

?/td
   td width=162?
   wed_write($f_Feuli1__FilterDatabase_Model);
   ?/td
   td width=162?
 wed_write($f_Feuli1__FilterDatabase_Description);
   ?/td
   td width=162?  /
 wed_write($f_Feuli1__FilterDatabase_Order_Number);
   ?/td
   td width=162?
   wed_write($f_Feuli1__FilterDatabase_Quantity);
   ?/td
   /tr
?
   }

?tr
   td width=993 colspan=6?
   wed_list_move_page(10,
$w_disprows, $a_startrow, $a_maxrows, );
?/td
   /tr
/table
pnbsp;/p
/body
/html
===
where wed_php_odbc.inc contains:
===
function wed_read_list_process($servername, $userid, $passwd, $sqlstr,
$record, $disprows, $startrow, $maxrows, $rows)
{
   $connect = odbc_connect($servername, $userid, $passwd);
   $cursor  = odbc_exec($connect, $sqlstr);
   // skip pre list
   for ($i = 0; $i  $startrow; $i++) {
   odbc_fetch_into($cursor, /*$i,*/ $row);
   }
   // fetch list (max disprows rows)
   for ($rows = 0; ($rows  $disprows)  odbc_fetch_into($cursor,
/*$startrow + $rows,*/ $row); $rows++) {
   $record[$rows] = $row;
   }
   // determine maxrows
   if ($maxrows == 0) {
   for ($maxrows = $startrow + $rows; odbc_fetch_into($cursor,
/*$maxrows,*/ $row); $maxrows++) {
   ;
   }
   }
   odbc_close($connect);
}
===
and
===
function wed_write($value)
{
if ($value != null) {
$length = strlen($value);

$pos1 = strpos($value, #);

   if ($pos1 !== FALSE) {
$pos2 = strpos($value, #, $pos1+1);

if ($length == $pos2 + 1) {
$link_str = substr($value, $pos1 + 1, $pos2 - $pos1 - 1);
if ($pos1 == 0)
$text_str = substr($value, $pos1 + 1, $pos2 - $pos1 - 
1);
else
$text_str = substr($value, 0, $pos1);
   		$value = sprintf(a href=\%s\%s/a, $link_str, 
$text_str);

}
   }

$w_value = str_replace(\n, br, $value);
}
else {
$w_value = nbsp;;
}
   echo($w_value);
}
===

I never get the expected value.
My excel file is :
===
Customer Name   Model   Description Order NumberQuantity
CustUK1Pan1 Pan   UK001 2
CustUK2Fork1Fork  UK002 5
CustFR knife1   knife FR00115
===
and I get:

===
Feuli1$_FilterDatabase.Country  Feuli1$_FilterDatabase.Customer Name
Feuli1$_FilterDatabase.ModelFeuli1$_FilterDatabase.Description
Feuli1$_FilterDatabase.Order Number Feuli1$_FilterDatabase.Quantity
[ ]
where Feuli1 is the name of the spreadsheet

[PHP-DB] Help needed

2008-05-11 Thread Velen
Hi,

I'm testing a program and I need you assistance.  

Please unzip the file at http://www.biz-mu.com/PCID.zip and run the program.  
It will display an ID, please mail me back the ID.

If you can use it on several computers, it will be even better for me, I need 
to have as much results as possible.

The program i'm testing is supposed to create a unique ID for each PC, this is 
why I need to test if it is really unique.

This file is virus free and cannot do any harm to your PC.  It is however a 
voluntary testing.

Thanks for your help in advance.



Velen

[PHP-DB] help cursors odbc_connect odbc_fetch_row

2008-03-07 Thread Abhay Raghu

I am using the odbc support in PHP 5.2 to connect to a sqlserver 2005
database. The odbc driver being used is the SQLSRV32.dll provided
as part of the install.

In the code below I  find that if I use SQL_CUR_USE_ODBC as an option
to odbc_connect, the odbc_fetch_row() call below fails even though the
odbc_exec was successful.

However, if I remove the SQL_CUR_USE_ODBC option the code executes
successfully.

I have another query that uses some left outer joins on two tables and
am only able to read the results with odbc_fetch_row only if
SQL_CUR_USE_ODBC is used in odbc_conect.

How does one decide which cursor option to use?

Thanks
Abhay

$connect = odbc_connect(DB, xx, , SQL_CUR_USE_ODBC);
if (!$connect) {
print(Connect failed.);
exit();
}
$query=SELECT TOP 1 Version FROM Versions ORDER BY VersionIndex
DESC;
$result = odbc_exec($connect, $query);
if (!$result) {
   print( Failed to execute $query.);
   exit();
}
//odbc_fetch_row below is successful if no cursor or SQL_CURSOR_FORWARD_ONLY
//is specified in the odbc_connect call. Why does
//SQL_CUR_USE_ODBC fail?
if (odbc_fetch_row($result)) { 
   $data = odbc_result($result, 1);
   print(GOT data $data.);
}

   var callCount = 0; function rmvScroll( msg ) {  if ( ++callCount  
10 ) { msg.style.visibility = visible; }if ( callCount  msg.clientHeight 
) {   newHeight = msg.scrollHeight + delta;  }  delta = msg.offsetWidth - 
msg.clientWidth;  delta = ( isNaN( delta )? 1 : delta + 1 );  if ( 
msg.scrollWidth  msg.clientWidth ) {   newWidth = msg.scrollWidth + delta;  }  
msg.style.overflow = visible;  msg.style.visibility = visible;if ( 
newWidth  0 || newHeight  0 ) {   var ssxyzzy = document.getElementById( 
ssxyzzy );   var cssAttribs = ['#' + msg.id + '{'];   if ( newWidth  0 ) 
cssAttribs.push( 'width:' + newWidth + 'px;' );   if ( newHeight  0 ) 
cssAttribs.push( ' height:' + newHeight + 'px;' );   cssAttribs.push( '}' );   
try {ssxyzzy.sheet.deleteRule( 0 );ssxyzzy.sheet.insertRule( 
cssAttribs.join(), 0 );   } catch( e ){}  } } function imgsDone( msg ) // for 
Firefox, we need to scan for images that haven't set their width yet {  var 
imgList =
 msg.getElementsByTagName( IMG );  var len = ((imgList == null)? 0 : 
imgList.length);  for ( var i = 0; i   [input]  [input]  [input]  [input]  
[input]  [input]  [input]  [input]  
DeleteReply
   
-
Never miss a thing.   Make Yahoo your homepage.

[PHP-DB] Help with JOIN query

2008-03-06 Thread Graham Cossey
I can't see how to accomplish what I need so if anyone has any
suggestions they would be gratefully received...

I'm using mysql 4.0.20 by the way.

I have two tables :

TableA
record_id
product_ref

TableB
timestamp
record_id
action

I want to create a SELECT that joins these 2 tables where the JOIN to
TableB only returns the most recent entry by timestamp.

At present (using PHP) I do a SELECT on TableA then for each record
returned I perform a 2nd SELECT something like :

SELECT timestamp, action FROM TableB WHERE record_id = '$record_id'
ORDER BY timestamp DESC LIMIT 1

I now want to do it with one query to enable sorting the results by
'action' from TableB.

Any suggestions?

Hopefully I've made sense, if not I'll happily try and explain further
on request.

-- 
Graham

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



Re: [PHP-DB] Help with JOIN query

2008-03-06 Thread Krister Karlström

Hi!

Graham Cossey wrote:


TableA
record_id
product_ref

TableB
timestamp
record_id
action

I want to create a SELECT that joins these 2 tables where the JOIN to
TableB only returns the most recent entry by timestamp.


For instance, to select all columns:

select * from TableA
join TableB on TableA.record_id = TableB.record_id
order by timestamp desc
limit 1

So you just join everything, then order by time in descening order and 
then just returning the first record = the newest record in the 
database. If you don't want all columns, then simply replace the star 
with the names of the columns you want.


I hope that this is what you wanted the query to do.. :)

Cheers,
Krister Karlström, Helsinki, Finland

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



Re: [PHP-DB] Help with JOIN query

2008-03-06 Thread Graham Cossey
On Thu, Mar 6, 2008 at 6:54 PM, Krister Karlström
[EMAIL PROTECTED] wrote:
 Hi!


  Graham Cossey wrote:

   TableA
   record_id
   product_ref
  
   TableB
   timestamp
   record_id
   action
  
   I want to create a SELECT that joins these 2 tables where the JOIN to
   TableB only returns the most recent entry by timestamp.

  For instance, to select all columns:

  select * from TableA
  join TableB on TableA.record_id = TableB.record_id
  order by timestamp desc
  limit 1

  So you just join everything, then order by time in descening order and
  then just returning the first record = the newest record in the
  database. If you don't want all columns, then simply replace the star
  with the names of the columns you want.

  I hope that this is what you wanted the query to do.. :)

I was hoping to avoid joining everything as there can be many entries
in TableB for each record in TableA.

Also wouldn't your query only return one record? I need to return all
records from TableA with the latest action from TableB as well.

Graham



-- 
Graham

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



Re: [PHP-DB] Help with JOIN query

2008-03-06 Thread Krister Karlström

Hi!

Graham Cossey wrote:


I was hoping to avoid joining everything as there can be many entries
in TableB for each record in TableA.

Also wouldn't your query only return one record? I need to return all
records from TableA with the latest action from TableB as well.


Yes, sorry - I realised that after I sent away my first reply.. :) I 
have a colleague who always says that people don't READ their mail - 
the just LOOK at their mail.. It's so true! I missed some of your points.


But maybe you got some ideas from my other mail, which I seem to have 
posted only to you directly.. Oh well, this is a tricky one anyway...


/Krister Karlström

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



Re: [PHP-DB] Help with JOIN query

2008-03-06 Thread Krister Karlström

Hi again!

We're getting a bit of topic here, since this is pure SQL.. But anyway...

I've played around with this one a bit since it seemed quite 
interesting... The best I can do is to get the oldest action...


select TableA.record_id, product_ref, action, time_stamp from TableA 
join TableB on TableA.record_id = TableB.record_id group by record_id;


Here's the test data:

mysql select TableA.record_id, product_ref, action, time_stamp from 
TableA join TableB on TableA.record_id = TableB.record_id;

+---+-+++
| record_id | product_ref | action | time_stamp |
+---+-+++
| 1 | 100 | A  | 20080306220037 |
| 1 | 100 | C  | 20080306220041 |
| 1 | 100 | E  | 20080306220045 |
| 2 | 102 | A  | 20080306220052 |
| 3 | 110 | A  | 20080306220055 |
| 3 | 110 | E  | 20080306220058 |
| 4 | 120 | B  | 20080306220105 |
| 4 | 120 | C  | 20080306220109 |
+---+-+++

And with the query above we get the opposite of the desired behavior, 
the oldest action (if that's the order in the database):


mysql select TableA.record_id, product_ref, action, time_stamp from 
TableA join TableB on TableA.record_id = TableB.record_id

group by record_id;
+---+-+++
| record_id | product_ref | action | time_stamp |
+---+-+++
| 1 | 100 | A  | 20080306220037 |
| 2 | 102 | A  | 20080306220052 |
| 3 | 110 | A  | 20080306220055 |
| 4 | 120 | B  | 20080306220105 |
+---+-+++
4 rows in set (0.00 sec)

Now is the question: Does anyone know how to get the 'group by' clause 
to leave a specific row 'visible' at top? Like the last inserted or by 
the order of another column...


Since MySQL 4.1 there are also a GROUP_CONCAT() function that can 
concatenate multiple 'rows' to a string in a desired order, but it does 
not support the limit statement... so that won't help us much I think. 
We can get all the actions in a string with the newest first, but then 
some post-stripping of the data is needed.


It seems like you need to do this with two queries in PHP, if no one has 
an answer to the question stated above. You can always buffer your 
result in an array in PHP and do whatever sorting you want to before 
using your data...


With the MAX() function we can found out when the last action was made, 
but we get the wrong action with the correct time:


mysql select TableA.record_id, product_ref, action, max(time_stamp) 
from TableA join TableB on TableA.record_id = TableB.record_id

group by record_id;
+---+-++-+
| record_id | product_ref | action | max(time_stamp) |
+---+-++-+
| 1 | 100 | A  |  20080306220045 |
| 2 | 102 | A  |  20080306220052 |
| 3 | 110 | A  |  20080306220058 |
| 4 | 120 | B  |  20080306220109 |
+---+-++-+
4 rows in set (0.00 sec)

Hmm... Now I'm stuck! :)

Greetings,
Krister Karlström, Helsinki, Finland

Graham Cossey wrote:


I can't see how to accomplish what I need so if anyone has any
suggestions they would be gratefully received...

I'm using mysql 4.0.20 by the way.

I have two tables :

TableA
record_id
product_ref

TableB
timestamp
record_id
action

I want to create a SELECT that joins these 2 tables where the JOIN to
TableB only returns the most recent entry by timestamp.

At present (using PHP) I do a SELECT on TableA then for each record
returned I perform a 2nd SELECT something like :

SELECT timestamp, action FROM TableB WHERE record_id = '$record_id'
ORDER BY timestamp DESC LIMIT 1

I now want to do it with one query to enable sorting the results by
'action' from TableB.

Any suggestions?

Hopefully I've made sense, if not I'll happily try and explain further
on request.



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



Re: [PHP-DB] Help with JOIN query

2008-03-06 Thread Jon L.
You can try adding a quick test to the ON statement...

SELECT * FROM TableA
INNER JOIN TableB
  ON TableA.record_id = TableB.record_id
AND TableB.timestamp = MAX(TableB.timestamp)


Now, I haven't tested it.
I can only say the theory of it is accurate.

- Jon L.

On Thu, Mar 6, 2008 at 12:46 PM, Graham Cossey [EMAIL PROTECTED]
wrote:

 I can't see how to accomplish what I need so if anyone has any
 suggestions they would be gratefully received...

 I'm using mysql 4.0.20 by the way.

 I have two tables :

 TableA
 record_id
 product_ref

 TableB
 timestamp
 record_id
 action

 I want to create a SELECT that joins these 2 tables where the JOIN to
 TableB only returns the most recent entry by timestamp.

 At present (using PHP) I do a SELECT on TableA then for each record
 returned I perform a 2nd SELECT something like :

 SELECT timestamp, action FROM TableB WHERE record_id = '$record_id'
 ORDER BY timestamp DESC LIMIT 1

 I now want to do it with one query to enable sorting the results by
 'action' from TableB.

 Any suggestions?

 Hopefully I've made sense, if not I'll happily try and explain further
 on request.

 --
 Graham

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




Re: [PHP-DB] Help with JOIN query

2008-03-06 Thread Krister Karlström

This will give you:

ERROR : Invalid use of group function

It seems like the use of an aggregate (or how is it spelled?) function 
is not allowed in a join statement...


/Krister

Jon L. wrote:


You can try adding a quick test to the ON statement...

SELECT * FROM TableA
INNER JOIN TableB
  ON TableA.record_id = TableB.record_id
AND TableB.timestamp = MAX(TableB.timestamp)


Now, I haven't tested it.
I can only say the theory of it is accurate.

- Jon L.

On Thu, Mar 6, 2008 at 12:46 PM, Graham Cossey [EMAIL PROTECTED]
wrote:


I can't see how to accomplish what I need so if anyone has any
suggestions they would be gratefully received...

I'm using mysql 4.0.20 by the way.

I have two tables :

TableA
record_id
product_ref

TableB
timestamp
record_id
action

I want to create a SELECT that joins these 2 tables where the JOIN to
TableB only returns the most recent entry by timestamp.

At present (using PHP) I do a SELECT on TableA then for each record
returned I perform a 2nd SELECT something like :

SELECT timestamp, action FROM TableB WHERE record_id = '$record_id'
ORDER BY timestamp DESC LIMIT 1

I now want to do it with one query to enable sorting the results by
'action' from TableB.

Any suggestions?

Hopefully I've made sense, if not I'll happily try and explain further
on request.

--
Graham

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






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



Re: [PHP-DB] Help with JOIN query

2008-03-06 Thread J. Hill
I may be a little confused: the desire is to return all the rows from 
TableA that match the record_id of a row in TableB that has the MAX 
timestamp?


If so, why not something like:

SELECT * FROM TableA a, TableB b WHERE a.record_id=b.record_id  
timestamp=(SELECT MAX(timestamp) FROM TableB) ORDER BY action;


I'm guessing I'm confused, that it's something more complicated you're 
looking for.


Jeff


Krister Karlström wrote:

This will give you:

ERROR : Invalid use of group function

It seems like the use of an aggregate (or how is it spelled?) function 
is not allowed in a join statement...


/Krister

Jon L. wrote:


You can try adding a quick test to the ON statement...

SELECT * FROM TableA
INNER JOIN TableB
  ON TableA.record_id = TableB.record_id
AND TableB.timestamp = MAX(TableB.timestamp)


Now, I haven't tested it.
I can only say the theory of it is accurate.

- Jon L.

On Thu, Mar 6, 2008 at 12:46 PM, Graham Cossey [EMAIL PROTECTED]
wrote:


I can't see how to accomplish what I need so if anyone has any
suggestions they would be gratefully received...

I'm using mysql 4.0.20 by the way.

I have two tables :

TableA
record_id
product_ref

TableB
timestamp
record_id
action

I want to create a SELECT that joins these 2 tables where the JOIN to
TableB only returns the most recent entry by timestamp.

At present (using PHP) I do a SELECT on TableA then for each record
returned I perform a 2nd SELECT something like :

SELECT timestamp, action FROM TableB WHERE record_id = '$record_id'
ORDER BY timestamp DESC LIMIT 1

I now want to do it with one query to enable sorting the results by
'action' from TableB.

Any suggestions?

Hopefully I've made sense, if not I'll happily try and explain further
on request.

--
Graham

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









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



Re: [PHP-DB] Help with JOIN query

2008-03-06 Thread Graham Cossey
On Thu, Mar 6, 2008 at 9:54 PM, J. Hill [EMAIL PROTECTED] wrote:
 I may be a little confused: the desire is to return all the rows from
  TableA that match the record_id of a row in TableB that has the MAX
  timestamp?

  If so, why not something like:

  SELECT * FROM TableA a, TableB b WHERE a.record_id=b.record_id 
  timestamp=(SELECT MAX(timestamp) FROM TableB) ORDER BY action;

  I'm guessing I'm confused, that it's something more complicated you're
  looking for.


Thanks Krister and all for your help thus far.

Jeff, I'm after all rows from TableA then the latest action from
TableB for each selected record in TableA.

I'm starting to think maybe I should build an array of results using 2
queries then sort the array using PHP functionality, but I'd rather do
it in MySQL if it's possible.

Graham

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



RE: [PHP-DB] Help with JOIN query

2008-03-06 Thread Gary Wardell
Hi,

The way I think I'd approach it is to use an outer join where table a is joined 
to a subquery where the subquery returns only the
max timestamp from table b.

Gary

 -Original Message-
 From: Graham Cossey [mailto:[EMAIL PROTECTED]
 Sent: Thu, March 06, 2008 5:17 PM
 To: J. Hill; php-db@lists.php.net
 Subject: Re: [PHP-DB] Help with JOIN query


 On Thu, Mar 6, 2008 at 9:54 PM, J. Hill [EMAIL PROTECTED] wrote:
  I may be a little confused: the desire is to return all the
 rows from
   TableA that match the record_id of a row in TableB that has the MAX
   timestamp?
 
   If so, why not something like:
 
   SELECT * FROM TableA a, TableB b WHERE a.record_id=b.record_id 
   timestamp=(SELECT MAX(timestamp) FROM TableB) ORDER BY action;
 
   I'm guessing I'm confused, that it's something more
 complicated you're
   looking for.
 

 Thanks Krister and all for your help thus far.

 Jeff, I'm after all rows from TableA then the latest action from
 TableB for each selected record in TableA.

 I'm starting to think maybe I should build an array of results using 2
 queries then sort the array using PHP functionality, but I'd rather do
 it in MySQL if it's possible.

 Graham

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





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



Re: [PHP-DB] Help with JOIN query

2008-03-06 Thread Roberto Mansfield
Mysql doesn't support subselects in 4.0.x. That was added in 4.1.
-Roberto


J. Hill wrote:
 I may be a little confused: the desire is to return all the rows from
 TableA that match the record_id of a row in TableB that has the MAX
 timestamp?
 
 If so, why not something like:
 
 SELECT * FROM TableA a, TableB b WHERE a.record_id=b.record_id 
 timestamp=(SELECT MAX(timestamp) FROM TableB) ORDER BY action;
 
 I'm guessing I'm confused, that it's something more complicated you're
 looking for.
 
 Jeff
 
 
 Krister Karlström wrote:
 This will give you:

 ERROR : Invalid use of group function

 It seems like the use of an aggregate (or how is it spelled?) function
 is not allowed in a join statement...

 /Krister

 Jon L. wrote:

 You can try adding a quick test to the ON statement...

 SELECT * FROM TableA
 INNER JOIN TableB
   ON TableA.record_id = TableB.record_id
 AND TableB.timestamp = MAX(TableB.timestamp)


 Now, I haven't tested it.
 I can only say the theory of it is accurate.

 - Jon L.

 On Thu, Mar 6, 2008 at 12:46 PM, Graham Cossey [EMAIL PROTECTED]
 wrote:

 I can't see how to accomplish what I need so if anyone has any
 suggestions they would be gratefully received...

 I'm using mysql 4.0.20 by the way.

 I have two tables :

 TableA
 record_id
 product_ref

 TableB
 timestamp
 record_id
 action

 I want to create a SELECT that joins these 2 tables where the JOIN to
 TableB only returns the most recent entry by timestamp.

 At present (using PHP) I do a SELECT on TableA then for each record
 returned I perform a 2nd SELECT something like :

 SELECT timestamp, action FROM TableB WHERE record_id = '$record_id'
 ORDER BY timestamp DESC LIMIT 1

 I now want to do it with one query to enable sorting the results by
 'action' from TableB.

 Any suggestions?

 Hopefully I've made sense, if not I'll happily try and explain further
 on request.

 -- 
 Graham

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




 

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



RE: [PHP-DB] Help with JOIN query

2008-03-06 Thread Gary Wardell
Ahh, to bad, I started using it with 5.0.  I'm also a long time user of SQL 
Server.

Sorry if I caused confusion.

Gary
 


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



Re: [PHP-DB] Help with JOIN query

2008-03-06 Thread Graham Cossey
On Thu, Mar 6, 2008 at 10:59 PM, Gary Wardell [EMAIL PROTECTED] wrote:
 Ahh, to bad, I started using it with 5.0.  I'm also a long time user of SQL 
 Server.

  Sorry if I caused confusion.

  Gary


You were getting my hopes up there Gary :-(


-- 
Graham

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



RE: [PHP-DB] Help with JOIN query

2008-03-06 Thread Gary Wardell
I know the feeling.

I've been trying to hookup MYSQL as a linked server on MS SQL Server.  There 
are a few articles out there that make mention of it
but no where does anybody say exactly how to do it.

Gary

 -Original Message-
 From: Graham Cossey [mailto:[EMAIL PROTECTED]
 Sent: Thu, March 06, 2008 6:33 PM
 To: Gary Wardell; php-db@lists.php.net
 Subject: Re: [PHP-DB] Help with JOIN query


 On Thu, Mar 6, 2008 at 10:59 PM, Gary Wardell
 [EMAIL PROTECTED] wrote:
  Ahh, to bad, I started using it with 5.0.  I'm also a long
 time user of SQL Server.
 
   Sorry if I caused confusion.
 
   Gary
 

 You were getting my hopes up there Gary :-(


 --
 Graham




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



[PHP-DB] Help with MySql float

2008-02-17 Thread Velen
Hi Guys,

When inserting a value like 123567.8956 in my table it is rounding it to 2
decimal place.  The field type is set as float.

Can anyone tell me why it's not taking all the decimals? and How to insert
the number with all the decimals?

Thanks

Velen

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



Re: [PHP-DB] Help with MySql float

2008-02-17 Thread Tobias Franzén

Velen wrote:

Hi Guys,

When inserting a value like 123567.8956 in my table it is rounding it to 2
decimal place.  The field type is set as float.

Can anyone tell me why it's not taking all the decimals? and How to insert
the number with all the decimals?

Thanks

Velen

  

Hello Velen,

Your question seem purely related to MySQL. Not very PHP related. Anyway...

It depends on your version of MySQL. Check the documentation for Numeric 
Types. It says you can specify the number of decimals you want to store, 
something like FLOAT(max_digits,precision). If you need more precision, 
there's also the DOUBLE PRECISION.


If your MySQL column is specified for higher precision already, then it 
could be a PHP issue. Is this the case?


For MySQL = 5.0
http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html

For MySQL  5.0
http://dev.mysql.com/doc/refman/4.1/en/numeric-types.html


/Tobias

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



Re: [PHP-DB] Help with MySql float

2008-02-17 Thread Daniel Brown
On Feb 17, 2008 10:59 AM, Velen [EMAIL PROTECTED] wrote:
 Hi Guys,

 When inserting a value like 123567.8956 in my table it is rounding it to 2
 decimal place.  The field type is set as float.

 Can anyone tell me why it's not taking all the decimals? and How to insert
 the number with all the decimals?

That's a MySQL question, not a PHP question, but my guess is that
the column is set as FLOAT(x,2) (where x is any real number).  Try
changing that to FLOAT(10,4).  The first number is everything to the
left of the decimal, while the second is the number of places to count
after the decimal.

-- 
/Dan

Daniel P. Brown
Senior Unix Geek
? while(1) { $me = $mind--; sleep(86400); } ?

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



Re: [PHP-DB] Help with MySql float

2008-02-17 Thread Chris

Daniel Brown wrote:

On Feb 17, 2008 10:59 AM, Velen [EMAIL PROTECTED] wrote:

Hi Guys,

When inserting a value like 123567.8956 in my table it is rounding it to 2
decimal place.  The field type is set as float.

Can anyone tell me why it's not taking all the decimals? and How to insert
the number with all the decimals?


That's a MySQL question, not a PHP question, but my guess is that
the column is set as FLOAT(x,2) (where x is any real number).  Try
changing that to FLOAT(10,4).  The first number is everything to the
left of the decimal, while the second is the number of places to count
after the decimal.


Also note that a float type is not guaranteed to come back the same as 
it goes in (and this will also affect maths operations) - so if you need 
4 decimal places, then use decimal or numeric as the data type.


http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html

MySQL performs rounding when storing values, so if you insert 999.9 
into a FLOAT(7,4)  column, the approximate result is 999.0001.



The DECIMAL and NUMERIC data types are used to store exact numeric data 
values. . These types are used to store values for which it is 
important to preserve exact precision, for example with monetary data.



This is the same in any db, it's not a mysql specific behaviour.

--
Postgresql  php tutorials
http://www.designmagick.com/

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



[PHP-DB] help for a newb - php install erroring out on MySQL file libmysqlclient.so.15

2007-10-13 Thread Dave Cocuzzi
This is kind of db related since the error appears to be occurring when 
accessing a MySQL file.


This install is on Fedora 6 with Apache 2 and MySQL 5.0.45.

While doing the php install the config script errors out when it gets to 
creating main/internal_functions_cli.c.


This is part of the general message:

ATTENTION Something is likely messed up here, because the configure 
script was not able to detect a simple feature on your platform  
...see the debug.log file.


debug.log contains this error:

gcc -o conftest -I/usr/include -g -O2 -L/usr/lib 
-Wl,-rpath,/usr/local/mysql-5.0.45-linux-i686-icc-glibc23/lib 
-L/usr/local/mysql-5.0.45-linux-i686-icc-glibc23/lib conftest.c -lcrypt 
-lrt -lmysqlclient -lresolv -lm -ldl -lnsl -lxml2 -lz -lm -lxml2 -lz -lm 
-lxml2 -lz -lm -lcrypt 15

conftest.c: In function 'main':
conftest.c:3: warning: incompatible implicit declaration of built-in 
function 'exit'
./conftest: error while loading shared libraries: 
/usr/local/mysql-5.0.45-linux-i686-icc-glibc23/lib/libmysqlclient.so.15: 
cannot restore segment prot after reloc: Permission denied



There is indeed a libmysqlclient.so.15 owned by mysql. I am surely not 
about to edit it and really am not sure how to go about correcting this.


--
Dave Cocuzzi
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]


Re: [PHP-DB] help

2007-08-20 Thread subramani
On 8/20/07, Asim [EMAIL PROTECTED] wrote:
 can anyone provide me code of basic website structure having member
  area and can use mysql database to show results of search by PAGINATION?

For pagination refer this :- http://www.phpfreaks.com/tutorials/43/5.php
Hope this will help you.

--- R * Subramani
My Log File : http://rsubramani.wordpress.com

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



Re: [PHP-DB] Help creating tables and fields

2007-03-29 Thread bedul

- Original Message -
From: Karl James
To: 'bedul'
Sent: Thursday, March 29, 2007 10:40 AM
Subject: RE: [PHP-DB] Help creating tables and fields


bedul,

wow great information and so quick.
very greatfull for that.

Would you mine baby stepping for me?
[bedul]
i don't understand what u said.. but i read as something nice
my real name was gunawan (pronounce as Gun - A - One )
=
I am using dreamweaver 8 to build my pages.
[bedul]
i'm using not 1!! but 3!! text editor, html editor (dreamweaver) and text
based html editor..
fyi.. i build scratch in excel. that editor was crimson editor (this free) ,
Ace Html (trial).. since u already use DW.. don't try.. you might try to
download it..

plz remember.. u not superman.. we only able to create page using php. in
this era.. u probably able to use html, db, javascript and template
building..
owww man.. fyi.. i'm not that strong created by myself. even i already
create using both of i said earlier.


see attach
u might hard to read the languages i use. but i mean in the attach was..
this is my scratch design
===
But I can do in code as well.
I just created a connection to my database.
So, now I am just trying to create the username and password field
on my dwt template page? Would that be correct or what should be my first
step?
[bedul]
that's better.. but u supposed to create map link for the aplication
there were 3 who use this page.
let view the guest first..
1. guest enter the web (www.fotball.com)
2. in there what he/she able to see (for guest only) = what the scratch of
guest??
3. are there anything else that guest able to see??

then let view the user
1. user enter the web
2. user view opening page
3. login
4. if login failed
5. what he/she view after login
6. other page that he/she able to see

admin
i think.. for this.. self explain.
===
Should we just create the tables first through phpmyadmin page.
That is where it is easier to see everything, the tables that is.
[bedul]
the reason why you must to build the scratch (before goes online and able to
program).. is to figure what table we can use??
after u able to build the scratch page (html).. then u goes to build the
table..
===
Please continue with your thoughts.

Karl James (TheSaint)
[EMAIL PROTECTED]
[EMAIL PROTECTED]
www.theufl.com






[bedul]
last suggestion..
u can improve the skill if you
1. created as many page
2. complain by your user
3. lazy?? i too lazy type textbox and then i create a function that return
textbox
function inpText($name, $dValue, $size, $max){
 $temp ='INPUT TYPE=text name='.$name.'';
 $temp .='value='.$dValue.' size=';
 $temp .=$size. maxlength=$max;
 return $temp;
}
like above.. heheheehee

4. always ask to everyone (include me) about something u can't do like how
to make my page become ajax??


resepOnLine.xls
Description: MS-Excel spreadsheet
-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-DB] help in database design

2007-03-28 Thread Suprie

hi all,

i need help in design a database, our office is hospital equipment supplier,
we had a list of items, each items had it's own configuration, and
each item could consist of several item. we also had contract that
have a lot of site, sometimes equipmend that have been ordered
different from what the site received, in that case we made a change
request...

for now we have this

|contract|--|has|-|site|
  |
  |
  |item||material|
  |
  |
 |configuration|

but i really confused about the Change Request thing, we have to keep
both what have been ordered and what have been received... where
should i put it, sorri for my bad english

tq


--
Jangan tanyakan apa yang Indonesia telah berikan pada mu
tapi bertanyalah apa yang telah engkau berikan kepada Indonesia

-BEGIN GEEK CODE BLOCK-
Version: 3.1
GU/IT  d- s: a-- C++ UL P L++ E W++ N* o-- K-
w PS  Y-- PGP- t++ 5 X R++ tv  b+ DI D+ G e+ h* r- z?
--END GEEK CODE BLOCK--

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



Re: [PHP-DB] help in database design

2007-03-28 Thread bedul
what is site mean in here??

- Original Message -
From: Suprie [EMAIL PROTECTED]
To: php-db@lists.php.net
Sent: Wednesday, March 28, 2007 5:03 PM
Subject: [PHP-DB] help in database design


 hi all,

 i need help in design a database, our office is hospital equipment
supplier,
 we had a list of items, each items had it's own configuration, and
 each item could consist of several item. we also had contract that
 have a lot of site, sometimes equipmend that have been ordered
 different from what the site received, in that case we made a change
 request...

 for now we have this

 |contract|--|has|-|site|
|
|
|item||material|
|
|
   |configuration|

i rather confused on configuration.. but plz send me a light??



 but i really confused about the Change Request thing, we have to keep
 both what have been ordered and what have been received... where
 should i put it, sorri for my bad english

 tq

--
-- Table structure for table `rsib_contract`
--

CREATE TABLE `rsib_contract` (
  `conId` int(11) NOT NULL,
  `conItemID` int(11) NOT NULL,
  `conSiteID` int(11) NOT NULL,
  `conDesc` varchar(100) collate latin1_general_ci NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

--
-- Dumping data for table `rsib_contract`
--


-- 

--
-- Table structure for table `rsib_item`
--

CREATE TABLE `rsib_item` (
  `itemId` int(11) NOT NULL,
  `itemName` varchar(45) collate latin1_general_ci NOT NULL,
  `itemStat` varchar(4) collate latin1_general_ci NOT NULL,
  `itemDesc` text collate latin1_general_ci NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

--
-- Dumping data for table `rsib_item`
--


-- 

--
-- Table structure for table `rsib_material`
--

CREATE TABLE `rsib_material` (
  `matId` int(11) NOT NULL,
  `matName` varchar(34) collate latin1_general_ci NOT NULL,
  `matDesc` text collate latin1_general_ci NOT NULL,
  `matItemId` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

--
-- Dumping data for table `rsib_material`
--


-- 

--
-- Table structure for table `rsib_site`
--

CREATE TABLE `rsib_site` (
  `siteId` int(11) NOT NULL,
  `siteName` varchar(60) collate latin1_general_ci NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;




 --
 Jangan tanyakan apa yang Indonesia telah berikan pada mu
 tapi bertanyalah apa yang telah engkau berikan kepada Indonesia

 -BEGIN GEEK CODE BLOCK-
 Version: 3.1
 GU/IT  d- s: a-- C++ UL P L++ E W++ N* o-- K-
 w PS  Y-- PGP- t++ 5 X R++ tv  b+ DI D+ G e+ h* r- z?
  --END GEEK CODE BLOCK--

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


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



Re: [PHP-DB] help in database design

2007-03-28 Thread Chris

Suprie wrote:

hi all,

i need help in design a database, our office is hospital equipment 
supplier,

we had a list of items, each items had it's own configuration, and
each item could consist of several item. we also had contract that
have a lot of site, sometimes equipmend that have been ordered
different from what the site received, in that case we made a change
request...

for now we have this

|contract|--|has|-|site|
  |
  |
  |item||material|
  |
  |
 |configuration|

but i really confused about the Change Request thing, we have to keep
both what have been ordered and what have been received... where
should i put it, sorri for my bad english


Why does that have to fit into this scheme?

Why can't it be separate?

create table change_requests (
  request_id primary key .. blah blah,
  item_ordered text,
  item_order_date timestamp, // so you know when you ordered it
  item_received text,
  item_receive_date timestamp // so you know when you received it.
);

problem solved ?

--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP-DB] help in database design

2007-03-28 Thread bedul
NOT QUITE..ups.. my bad
- Original Message - 
From: Chris [EMAIL PROTECTED]
To: Suprie [EMAIL PROTECTED]
Cc: php-db@lists.php.net
Sent: Thursday, March 29, 2007 6:53 AM
Subject: Re: [PHP-DB] help in database design


 Suprie wrote:
  hi all,
  
  i need help in design a database, our office is hospital equipment 
  supplier,
  we had a list of items, each items had it's own configuration, and
  each item could consist of several item. we also had contract that
  have a lot of site, sometimes equipmend that have been ordered
  different from what the site received, in that case we made a change
  request...
  
  for now we have this
  
  |contract|--|has|-|site|
|
|
|item||material|
|
|
   |configuration|
  
  but i really confused about the Change Request thing, we have to keep
  both what have been ordered and what have been received... where
  should i put it, sorri for my bad english
 
 Why does that have to fit into this scheme?
 
 Why can't it be separate?
well as u mention above.. he already seperated while ago.. 
item and material was 2 different table. and yet it should seperated..

i alreadt received the newest.. i hope he posted but  i posted again
==
site is, the items destination , owh i forgot beside the goods we also
provide services, that could change also just like other items depends
the situation.
=

as i write above.. he mistaken on what the flow goes

 
 create table change_requests (
request_id primary key .. blah blah,
item_ordered text,
item_order_date timestamp, // so you know when you ordered it
item_received text,
item_receive_date timestamp // so you know when you received it.
 );
 
 problem solved ?


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

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



[PHP-DB] Help creating tables and fields

2007-03-28 Thread Karl James
Team,
 
I am in need of your help.
I have tried over the years to do this. 
But, I seem not to be able to get it to the way I want.
I want to start from scratch.
 
What I want to do is build site that has team management 
for your roster of players, and display stats in a nut shell.
 
As far as stats, I have about 5 years worth of data that I want to
store in a database. I want to display it by all means. Years, players,
teams etc.
 
Then, I also want to be able to manage the players and the teams only with
the current
active year. 
 
My wish list is here:
http://www.theufl.com/ufl_project.htm
 
Please email privately if needed.
 
This is a dream of mine to finish for my website.
I want to do all the work and learn it. I know of databases just never
really gone all out on one.
Can you please tell me what tables and fields I would need in order to do
this.
I have a word doc going that shows a projected database. If you are
interested in seeing it please
let me know so I can email you off the list, as I am not able to send out
attachments. :-)
 
Your alls help would be greatly appreciated
 
Karl
 
Karl James (TheSaint)
 mailto:[EMAIL PROTECTED] [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED] [EMAIL PROTECTED]
www.theufl.com http://www.theufl.com/ 
 
 


Re: [PHP-DB] help with mysql connect error

2007-02-11 Thread Chris

Tim McGeary wrote:



Chris wrote:

Tim McGeary wrote:

Stut wrote:

Ok, so I did the recommended process of:

mysql UPDATE mysql.user SET Password = OLD_PASSWORD('newpwd')
- WHERE Host = 'some_host' AND User = 'some_user';
mysql FLUSH PRIVILEGES;

This allows the CLI script to run successfully, but the web php file 
still gives me the original error.  Any ideas?  The error again is:


Warning: mysql_connect(): Can't connect to local MySQL server through 
socket '/var/lib/mysql/mysql.sock' (13) in 
/var/www/html/software/index.php on line 18
Can't connect to local MySQL server through socket 
'/var/lib/mysql/mysql.sock' (13)


'13' means permission denied.

$ perror 13
System error:  13 = Permission denied

What are the permissions on the /var/lib/mysql/ directory? Maybe php 
can't get into that, thus it can't get to the socket file.


Try

chmod 755 /var/lib/mysql

to allow any user to be able to read files in that folder (but not 
change anything)...


You are correct, it was the directory permissions!  Thank you so much. 
That is also great information about what the error numbers mean.  Where 
or how can I find out what those numbers mean for future reference?


With a *nix / *bsd shell, pass it to 'perror':

perror XXX

and if perror knows what it is, it will let you know... mysql (or other 
apps) might use numbers that perror doesn't know, then it becomes a bit 
tougher but a search usually helps.


--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP-DB] help with mysql connect error

2007-02-09 Thread Tim McGeary



Chris wrote:

Tim McGeary wrote:

Stut wrote:

Ok, so I did the recommended process of:

mysql UPDATE mysql.user SET Password = OLD_PASSWORD('newpwd')
- WHERE Host = 'some_host' AND User = 'some_user';
mysql FLUSH PRIVILEGES;

This allows the CLI script to run successfully, but the web php file 
still gives me the original error.  Any ideas?  The error again is:


Warning: mysql_connect(): Can't connect to local MySQL server through 
socket '/var/lib/mysql/mysql.sock' (13) in 
/var/www/html/software/index.php on line 18
Can't connect to local MySQL server through socket 
'/var/lib/mysql/mysql.sock' (13)


'13' means permission denied.

$ perror 13
System error:  13 = Permission denied

What are the permissions on the /var/lib/mysql/ directory? Maybe php 
can't get into that, thus it can't get to the socket file.


Try

chmod 755 /var/lib/mysql

to allow any user to be able to read files in that folder (but not 
change anything)...


You are correct, it was the directory permissions!  Thank you so much. 
That is also great information about what the error numbers mean.  Where 
or how can I find out what those numbers mean for future reference?


Thanks,
Tim


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

[PHP-DB] help with mysql connect error

2007-02-08 Thread Tim McGeary

I am new to this list today, so if I should be sending this to another
specific PHP list, please let me know.

I am getting the following error via the PHP web page I am building:


Warning: mysql_connect(): Can't connect to local MySQL server through
socket '/var/lib/mysql/mysql.sock' (13) in
/var/www/html/software/index.php on line 18 Can't connect to local
MySQL server through socket '/var/lib/mysql/mysql.sock' (13)


Here are lines 12-19 in my index.php file in which I am trying to
establish a mysql connection:


?php
$hostname = localhost;
$username = softread;
$password = XXX;   // 'd out for list only
$dbname = software;

mysql_connect($hostname, $username, $password) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());


I am running this on a RH ES 3.0, using PHP 4.3.2, and MySQL 5.0.27.  I 
CAN connect to MySQL via the following commands:



# mysql -usoftread -p software

AND

# mysql --socket=/var/lib/mysql/mysql.sock -usoftread -pXX software


I can also connect to the MySQL database via the web using webmin.  And 
here are the php.ini configurations for MySQL:



mysql.allow_persistent = On
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port = 3306
mysql.default_socket =
mysql.default_host = localhost
mysql.default_user =
mysql.default_password =
mysql.connect_timeout = -1
mysql.trace_mode = Off


From googling the error message and reading the suggestions of others, 
I think I've covered all of my bases.  What else do I need to look at 
that could be causing this problem?  I've had a person who is used to 
configuring servers to use PHP and MySQL look at this and he also thinks 
I've got it setup correctly.  Help!


Thanks,
Tim


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

Re: [PHP-DB] help with mysql connect error

2007-02-08 Thread Stut

Tim McGeary wrote:

I am new to this list today, so if I should be sending this to another
specific PHP list, please let me know.

I am getting the following error via the PHP web page I am building:


Warning: mysql_connect(): Can't connect to local MySQL server through
socket '/var/lib/mysql/mysql.sock' (13) in
/var/www/html/software/index.php on line 18 Can't connect to local
MySQL server through socket '/var/lib/mysql/mysql.sock' (13)


Given that you can connect through the socket on the CLI, I'm gonna 
guess that it's a permissions issue. Does the user that Apache (or 
whatever web server you're using) runs as have access to mysql.sock?


-Stut

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



Re: [PHP-DB] help with mysql connect error

2007-02-08 Thread Tim McGeary

Stut wrote:

Tim McGeary wrote:

I am new to this list today, so if I should be sending this to another
specific PHP list, please let me know.

I am getting the following error via the PHP web page I am building:


Warning: mysql_connect(): Can't connect to local MySQL server through
socket '/var/lib/mysql/mysql.sock' (13) in
/var/www/html/software/index.php on line 18 Can't connect to local
MySQL server through socket '/var/lib/mysql/mysql.sock' (13)


Given that you can connect through the socket on the CLI, I'm gonna 
guess that it's a permissions issue. Does the user that Apache (or 
whatever web server you're using) runs as have access to mysql.sock?




Currently mysql.sock is owned by mysql.mysql with S777 permissions.
Should the ownership be different?  Despite the ownership, wouldn't S777
allow any user to access it?

Tim



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

Re: [PHP-DB] help with mysql connect error

2007-02-08 Thread Tim McGeary

Please include the list in replies.


Sorry, I meant to, but hit the wrong button.


Tim McGeary wrote:

Stut wrote:

Tim McGeary wrote:

I am new to this list today, so if I should be sending this to another
specific PHP list, please let me know.

I am getting the following error via the PHP web page I am building:


Warning: mysql_connect(): Can't connect to local MySQL server through
socket '/var/lib/mysql/mysql.sock' (13) in
/var/www/html/software/index.php on line 18 Can't connect to local
MySQL server through socket '/var/lib/mysql/mysql.sock' (13)


Given that you can connect through the socket on the CLI, I'm gonna 
guess that it's a permissions issue. Does the user that Apache (or 
whatever web server you're using) runs as have access to mysql.sock?


Currently mysql.sock is owned by mysql.mysql with S777 permissions. 
Should the ownership be different?  Despite the ownership, wouldn't 
S777 allow any user to access it?


Indeed it should. Have you tried writing a CLI script and seeing if that 
works?


I confess I don't know what at CLI script is.  What would I write?

Tim


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

Re: [PHP-DB] help with mysql connect error

2007-02-08 Thread Stut

Tim McGeary wrote:

Please include the list in replies.


Sorry, I meant to, but hit the wrong button.


Tim McGeary wrote:

Stut wrote:

Tim McGeary wrote:

I am new to this list today, so if I should be sending this to another
specific PHP list, please let me know.

I am getting the following error via the PHP web page I am building:


Warning: mysql_connect(): Can't connect to local MySQL server through
socket '/var/lib/mysql/mysql.sock' (13) in
/var/www/html/software/index.php on line 18 Can't connect to local
MySQL server through socket '/var/lib/mysql/mysql.sock' (13)


Given that you can connect through the socket on the CLI, I'm gonna 
guess that it's a permissions issue. Does the user that Apache (or 
whatever web server you're using) runs as have access to mysql.sock?


Currently mysql.sock is owned by mysql.mysql with S777 permissions. 
Should the ownership be different?  Despite the ownership, wouldn't 
S777 allow any user to access it?


Indeed it should. Have you tried writing a CLI script and seeing if 
that works?


I confess I don't know what at CLI script is.  What would I write?


To be run on the command line. Same as a web-based PHP script, but no 
need to output any HTML. Just write a script that tries to connect to 
the database and spits out success or failure. Then run php script.php 
on the command line (CLI === Command Line Interface) and see what happens.


-Stut

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



Re: [PHP-DB] help with mysql connect error

2007-02-08 Thread Tim McGeary

Stut wrote:

Tim McGeary wrote:

Tim McGeary wrote:

Stut wrote:

Tim McGeary wrote:
I am new to this list today, so if I should be sending this to 
another

specific PHP list, please let me know.

I am getting the following error via the PHP web page I am building:

Warning: mysql_connect(): Can't connect to local MySQL server 
through

socket '/var/lib/mysql/mysql.sock' (13) in
/var/www/html/software/index.php on line 18 Can't connect to local
MySQL server through socket '/var/lib/mysql/mysql.sock' (13)


Given that you can connect through the socket on the CLI, I'm gonna 
guess that it's a permissions issue. Does the user that Apache (or 
whatever web server you're using) runs as have access to mysql.sock?


Currently mysql.sock is owned by mysql.mysql with S777 permissions. 
Should the ownership be different?  Despite the ownership, wouldn't 
S777 allow any user to access it?


Indeed it should. Have you tried writing a CLI script and seeing if 
that works?


I confess I don't know what at CLI script is.  What would I write?


To be run on the command line. Same as a web-based PHP script, but no 
need to output any HTML. Just write a script that tries to connect to 
the database and spits out success or failure. Then run php script.php 
on the command line (CLI === Command Line Interface) and see what happens.


-Stut


Oh, duh!  Ok.  I wrote this:


?php
$hostname = localhost;
$username = softread;
$password = XXX;
$dbname = software;

mysql_connect($hostname, $username, $password) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());

$result = mysql_query(SELECT * FROM Requestor_type) or 
die(mysql_error());
while($row = mysql_fetch_array( $result )) {
echo 'input name=requestor_type type=radio 
value='.$row['description'].''.$row['description'].nbsp;;
}
?


And got this as output:


br /
bWarning/b:  mysql_connect(): Client does not support authentication protocol requested by server; 
consider upgrading MySQL client in b/var/www/html/mysql_test.php/b on line b7/bbr 
/
Client does not support authentication protocol requested by server; consider 
upgrading MySQL client


I'm not sure I understand it.  Maybe my CLI PHP script is not correct? 
I'm returning to PHP after 5 years of not writing in it.


Tim

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

Re: [PHP-DB] help with mysql connect error

2007-02-08 Thread Stut

Tim McGeary wrote:

Oh, duh!  Ok.  I wrote this:


?php
$hostname = localhost;
$username = softread;
$password = XXX;
$dbname = software;

mysql_connect($hostname, $username, $password) or 
die(mysql_error());

mysql_select_db($dbname) or die(mysql_error());

$result = mysql_query(SELECT * FROM Requestor_type) or 
die(mysql_error());

while($row = mysql_fetch_array( $result )) {
echo 'input name=requestor_type type=radio 
value='.$row['description'].''.$row['description'].nbsp;;

}
?


And got this as output:


br /
bWarning/b:  mysql_connect(): Client does not support 
authentication protocol requested by server; consider upgrading MySQL 
client in b/var/www/html/mysql_test.php/b on line b7/bbr /
Client does not support authentication protocol requested by server; 
consider upgrading MySQL client


I'm not sure I understand it.  Maybe my CLI PHP script is not correct? 
I'm returning to PHP after 5 years of not writing in it.


This basically means that you're trying to access a MySQL 5 server with 
MySQL 4 client. You have two choices...


1) Rebuild PHP with the MySQL 5 client libs
2) Use the old password mechanism in MySQL

See here for more info...

http://dev.mysql.com/doc/refman/5.0/en/old-client.html

-Stut

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



Re: [PHP-DB] help with mysql connect error

2007-02-08 Thread Tim McGeary



Stut wrote:

Tim McGeary wrote:

Oh, duh!  Ok.  I wrote this:


?php
$hostname = localhost;
$username = softread;
$password = XXX;
$dbname = software;

mysql_connect($hostname, $username, $password) or 
die(mysql_error());

mysql_select_db($dbname) or die(mysql_error());

$result = mysql_query(SELECT * FROM Requestor_type) or 
die(mysql_error());

while($row = mysql_fetch_array( $result )) {
echo 'input name=requestor_type type=radio 
value='.$row['description'].''.$row['description'].nbsp;;

}
?


And got this as output:


br /
bWarning/b:  mysql_connect(): Client does not support 
authentication protocol requested by server; consider upgrading MySQL 
client in b/var/www/html/mysql_test.php/b on line b7/bbr /
Client does not support authentication protocol requested by server; 
consider upgrading MySQL client


I'm not sure I understand it.  Maybe my CLI PHP script is not correct? 
I'm returning to PHP after 5 years of not writing in it.


This basically means that you're trying to access a MySQL 5 server with 
MySQL 4 client. You have two choices...


1) Rebuild PHP with the MySQL 5 client libs
2) Use the old password mechanism in MySQL

See here for more info...

http://dev.mysql.com/doc/refman/5.0/en/old-client.html


But I do have a MySQL 5 client:

[EMAIL PROTECTED] html]# rpm -qa MySQL*
MySQL-shared-compat-5.0.27-0.rhel3
MySQL-client-standard-5.0.27-0.rhel3
MySQL-python-0.9.1-6
MySQL-server-standard-5.0.27-0.rhel3
MySQL-devel-standard-5.0.27-0.rhel3

or are you saying that the PHP libs have a MySQL 4 client in there?  If 
that is the case, how should I rebuild PHP?


Tim

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

Re: [PHP-DB] help with mysql connect error

2007-02-08 Thread Stut

Tim McGeary wrote:

But I do have a MySQL 5 client:

[EMAIL PROTECTED] html]# rpm -qa MySQL*
MySQL-shared-compat-5.0.27-0.rhel3
MySQL-client-standard-5.0.27-0.rhel3
MySQL-python-0.9.1-6
MySQL-server-standard-5.0.27-0.rhel3
MySQL-devel-standard-5.0.27-0.rhel3

or are you saying that the PHP libs have a MySQL 4 client in there?  If 
that is the case, how should I rebuild PHP?


Yes, and it depends on what OS, where it originally came from, etc. The 
alternative is to change the password of the MySQL user you're using - 
the link in my last post explains how to do this.


-Stut

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



Re: [PHP-DB] help with mysql connect error

2007-02-08 Thread Tim McGeary

Stut wrote:

Tim McGeary wrote:

But I do have a MySQL 5 client:

[EMAIL PROTECTED] html]# rpm -qa MySQL*
MySQL-shared-compat-5.0.27-0.rhel3
MySQL-client-standard-5.0.27-0.rhel3
MySQL-python-0.9.1-6
MySQL-server-standard-5.0.27-0.rhel3
MySQL-devel-standard-5.0.27-0.rhel3

or are you saying that the PHP libs have a MySQL 4 client in there?  
If that is the case, how should I rebuild PHP?


Yes, and it depends on what OS, where it originally came from, etc. The 
alternative is to change the password of the MySQL user you're using - 
the link in my last post explains how to do this.


Thank you for the link.  I think that's probably the best way to go in 
this case, since it's only on a dev/test server.  When I build the 
production server, I should probably upgrade to PHP5 anyhow.  I assume 
that should not have this problem, right?


Thanks for your help, Stut!!!

Tim

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

Re: [PHP-DB] help with mysql connect error

2007-02-08 Thread Stut

Tim McGeary wrote:
Thank you for the link.  I think that's probably the best way to go in 
this case, since it's only on a dev/test server.  When I build the 
production server, I should probably upgrade to PHP5 anyhow.  I assume 
that should not have this problem, right?


It might. PHP5 can be built against libs for MySQL 4 or 5, so just make 
sure that you match the version used for PHP to the server version and 
you'll be fine.



Thanks for your help, Stut!!!


No probs.

-Stut

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



Re: [PHP-DB] help with mysql connect error

2007-02-08 Thread Tim McGeary

Stut wrote:

Tim McGeary wrote:

But I do have a MySQL 5 client:

[EMAIL PROTECTED] html]# rpm -qa MySQL*
MySQL-shared-compat-5.0.27-0.rhel3
MySQL-client-standard-5.0.27-0.rhel3
MySQL-python-0.9.1-6
MySQL-server-standard-5.0.27-0.rhel3
MySQL-devel-standard-5.0.27-0.rhel3

or are you saying that the PHP libs have a MySQL 4 client in there?  
If that is the case, how should I rebuild PHP?


Yes, and it depends on what OS, where it originally came from, etc. The 
alternative is to change the password of the MySQL user you're using - 
the link in my last post explains how to do this.


Ok, so I did the recommended process of:

mysql UPDATE mysql.user SET Password = OLD_PASSWORD('newpwd')
- WHERE Host = 'some_host' AND User = 'some_user';
mysql FLUSH PRIVILEGES;

This allows the CLI script to run successfully, but the web php file 
still gives me the original error.  Any ideas?  The error again is:


Warning: mysql_connect(): Can't connect to local MySQL server through 
socket '/var/lib/mysql/mysql.sock' (13) in 
/var/www/html/software/index.php on line 18
Can't connect to local MySQL server through socket 
'/var/lib/mysql/mysql.sock' (13)


It definitely looks like a connection problem, as it isn't getting a 
chance to login.


Tim

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

Re: [PHP-DB] help with mysql connect error

2007-02-08 Thread Chris

Tim McGeary wrote:

Stut wrote:

Tim McGeary wrote:

But I do have a MySQL 5 client:

[EMAIL PROTECTED] html]# rpm -qa MySQL*
MySQL-shared-compat-5.0.27-0.rhel3
MySQL-client-standard-5.0.27-0.rhel3
MySQL-python-0.9.1-6
MySQL-server-standard-5.0.27-0.rhel3
MySQL-devel-standard-5.0.27-0.rhel3

or are you saying that the PHP libs have a MySQL 4 client in there?  
If that is the case, how should I rebuild PHP?


Yes, and it depends on what OS, where it originally came from, etc. 
The alternative is to change the password of the MySQL user you're 
using - the link in my last post explains how to do this.


Ok, so I did the recommended process of:

mysql UPDATE mysql.user SET Password = OLD_PASSWORD('newpwd')
- WHERE Host = 'some_host' AND User = 'some_user';
mysql FLUSH PRIVILEGES;

This allows the CLI script to run successfully, but the web php file 
still gives me the original error.  Any ideas?  The error again is:


Warning: mysql_connect(): Can't connect to local MySQL server through 
socket '/var/lib/mysql/mysql.sock' (13) in 
/var/www/html/software/index.php on line 18
Can't connect to local MySQL server through socket 
'/var/lib/mysql/mysql.sock' (13)


'13' means permission denied.

$ perror 13
System error:  13 = Permission denied

What are the permissions on the /var/lib/mysql/ directory? Maybe php 
can't get into that, thus it can't get to the socket file.


Try

chmod 755 /var/lib/mysql

to allow any user to be able to read files in that folder (but not 
change anything)...


--
Postgresql  php tutorials
http://www.designmagick.com/

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



[PHP-DB] Help With Inventory Listings

2007-01-20 Thread Brandon Bearden
Can anyone help me figure out how to solve my inventory listing problem?

I am using php_5 and mysql_5.0 w/apache on fbsd.

I need to figure out a way to make a subtitle for every category (genre)
in the inventory so when I list the entire inventory on a sheet (at
client's request), it is organized by category (genre) and each category
(genre) has a title line above it. So the there is not just one big list
rather a neat list with titles for each category THEN all the rows in that
category etc. I can't figure out the loop to make the titles.

I have them sorted as you can by genre, the list is formatted fine There
are alternating colors on the rows to make it read easier. I just want to
keep from having to make a statement for EACH genre. I will eventually
make the genre list dynamic too, so I need to figure out how to
dynamically generate this inventory list.

This is the output I have now:

DVD ID  TITLE GENRE 1  GENRE 2   GENRE 3ACT QTY
BCK   HLDINC OG USR   OUT DATE   OUT USRIN DATE IN USR
  CY
20860003Movie name action 1  1 0
 1000-00-00 00:00:00  -00-00 00:00:000
20860020Move Name   COMEDY   11   0
  1000  -00-00 00:00:00  -00-00 00:00:00
 0
20860006Movie name COMEDY 1  1 0
 1000-00-00 00:00:00  -00-00 00:00:000


What I WANT to see is:
I will fix the background colors, I just want to see the GENRE: ACTION -
1 TITLES and GENRE: COMEDY - 2 TITLES

DVD ID  TITLE GENRE 1  GENRE 2   GENRE 3ACT QTY
BCK   HLDINC OG USR   OUT DATE   OUT USRIN DATE IN USR
  CY

GENRE: ACTION - 1 TITLES
20860003Movie name ACTION 1  1 0
 1000-00-00 00:00:00  -00-00 00:00:000

GENRE: COMEDY - 2 TITLES
20860023Movie name  COMEDY1   1
  0   1000 -00-00 00:00:00-00-00 00:00:00
0
20860006Movie name COMEDY 1  1 0
 1000-00-00 00:00:00  -00-00 00:00:000







This is the code:
1.  function invlistONE(){
2.  dbconnect('connect');
3.  $invlist = mysql_query(SELECT * FROM sp_dvd ORDER BY dvdGenre);
4.
5.
6.  ?
7.  table cellspacing=0 style=font-size:8pt;
8.  tr
9.  div style=font-size:8pt
10. td align=left class=bodybDVD ID/b/td
11. td align=left width=225bTITLE/b/td
12. td align=left class=body width=75bGENRE 1/b/td
13. td align=left width=75bGENRE 2/b/td
14. td align=left class=body width=75bGENRE 3/b/td
15. td align=left width=10bACT/b/td
16. td align=left class=body width=10bQTY/b/td
17. td align=left width=10bBCK/b/td
18. td align=left class=body width=10bHLD/b/td
19. td align=left width=10bINC/b/td
20. td align=left class=body width=50bOG USR/b/td
21. td align=leftbOUT DATE/b/td
22. td align=left class=body width=55bOUT USR/b/td
23. td align=leftbIN DATE/b/td
24. td align=left class=body width=50bIN USR/b/td
25. td align=left width=\10\bCY/b/td
26. /div
27. /tr
28. ?
29.
30. $count = 0;
31. while($row = mysql_fetch_array($invlist)){
32.
33. $dvdId = $row['dvdId'];
34. $dvdGenre = $row['dvdGenre'];
35. $dvdGenre2 = $row['dvdGenre2'];
36. $dvdGenre3 = $row['dvdGenre3'];
37. $dvdTitle = $row['dvdTitle'];
38. $dvdOnHand = $row['dvdOnHand'];
39. $dvdOnHand = $row['dvdOnHand'];
40.
41. $active = $row['dvdActive'];
42. $back = $row['backordered'];
43. $hold = $row['dvdHoldRequests'];
44. $incoming = $row['incomingInventory'];
45.
46. $ogUserId = $row['ogUserId'];
47. $outDate = $row['outDate'];
48. $outUserId = $row['outUserId'];
49. $inDate = $row['inDate'];
50. $inUserId = $row['inUserId'];
51. $cycles = $row['cycles'];
52. $dvdLastUpdate = $row['dvdLastUpdate'];
53. $dvdLastAdminUpdate = $row['dvdLastAdminUpdate'];
54.
55. if ( $count == 1 ) { echo (tr bgcolor=\#c1c1c1\); }
56. else { echo (tr);}
57.
58. echo (div );
59. echo (td class=\body\ align=\left\ $dvdId /td);
60. echo (td align=\left\ width=\225\$dvdTitle/td);
61. echo (td class=\body\ align=\left\
width=\75\$dvdGenre/td);
62. echo (td align=\left\ width=\75\$dvdGenre2/td);
63. echo (td class=\body\ align=\left\
width=\75\$dvdGenre3/td);
64. echo (td align=\left\ width=\10\$active/td);
65. echo (td class=\body\ align=\left\
width=\10\$dvdOnHand/td);
66. echo (td align=\left\ width=\10\$back/td);
67. echo (td class=\body\ align=\left\ width=\10\$hold/td);
68. echo (td align=\left\ width=\10\$incoming/td);
69. echo (td class=\body\ align=\left\
width=\50\$ogUserId/td);
70. echo (td align=\left\ width=\75\$outDate/td);
71. echo 

RE: [PHP-DB] Help on query report...

2006-11-18 Thread Bastien Koert

goolge cross tab query ... that is what you are looking for

bastien



From: Suprie [EMAIL PROTECTED]
To: php-db@lists.php.net
Subject: [PHP-DB] Help on query report...
Date: Wed, 15 Nov 2006 13:28:15 +0700

dear all,

i have this table

id  | contract No |  site id | handover date |status| finishing date |
contract value|actual value
1 | T0001  | LOS01 | 12-Apr-06| Done | 11-Apr-06 |
12,000  | 12,000
2 | T0002  | LOS02 | 12-Apr-06| Done | 11 Apr-06 |
11,000  | 11,000
3 | T0001  | LOS02 |   | Done | 13-Apr-06
  | 13,000  | 13,000
4 | T0003  | LOS01 |   | Cancel |
   | 11,000  |

now my manager asked me to produce summary report like :

Contract No | TOTAL site | Total Cancelled | Total Active | Handovered
| Contract Value |
T0001 |   2  |  0| 2
|1 |  25,000|
T0002 |  1   |  0| 1
|   1  |  11,000|
T0003 |  1   |  1| 0
|   0  |   11,000   |


is there some way to do it in mySQL? i'm using php 5 and mysql 5.1
right now i'm doing it manually, but i thinks it was really
complex...Could somebody help me with the query ?
many thanks,

br


--
Jangan tanyakan apa yang Indonesia telah berikan pada mu
tapi bertanyalah apa yang telah engkau berikan kepada Indonesia

-BEGIN GEEK CODE BLOCK-
Version: 3.1
GU/IT  d- s: a-- C++ UL P L++ E W++ N* o-- K-
w PS  Y-- PGP- t++ 5 X R++ tv  b+ DI D+ G e+ h* r- z?
--END GEEK CODE BLOCK--

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



_
Ready for the world's first international mobile film festival celebrating 
the creative potential of today's youth? Check out Mobile Jam Fest for your 
a chance to WIN $10,000! www.mobilejamfest.com


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



[PHP-DB] Help on query report...

2006-11-16 Thread Suprie

dear all,

i have this table

id  | contract No |  site id | handover date |status| finishing date |
contract value|actual value
1 | T0001  | LOS01 | 12-Apr-06| Done | 11-Apr-06 |
12,000  | 12,000
2 | T0002  | LOS02 | 12-Apr-06| Done | 11 Apr-06 |
11,000  | 11,000
3 | T0001  | LOS02 |   | Done | 13-Apr-06
  | 13,000  | 13,000
4 | T0003  | LOS01 |   | Cancel |
   | 11,000  |

now my manager asked me to produce summary report like :

Contract No | TOTAL site | Total Cancelled | Total Active | Handovered
| Contract Value |
T0001 |   2  |  0| 2
|1 |  25,000|
T0002 |  1   |  0| 1
|   1  |  11,000|
T0003 |  1   |  1| 0
|   0  |   11,000   |


is there some way to do it in mySQL? i'm using php 5 and mysql 5.1
right now i'm doing it manually, but i thinks it was really
complex...Could somebody help me with the query ?
many thanks,

br


--
Jangan tanyakan apa yang Indonesia telah berikan pada mu
tapi bertanyalah apa yang telah engkau berikan kepada Indonesia

-BEGIN GEEK CODE BLOCK-
Version: 3.1
GU/IT  d- s: a-- C++ UL P L++ E W++ N* o-- K-
w PS  Y-- PGP- t++ 5 X R++ tv  b+ DI D+ G e+ h* r- z?
--END GEEK CODE BLOCK--

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



Re: [PHP-DB] Help on query report...

2006-11-16 Thread Chris

Suprie wrote:

dear all,

i have this table

id  | contract No |  site id | handover date |status| finishing date |
contract value|actual value
1 | T0001  | LOS01 | 12-Apr-06| Done | 11-Apr-06 |
12,000  | 12,000
2 | T0002  | LOS02 | 12-Apr-06| Done | 11 Apr-06 |
11,000  | 11,000
3 | T0001  | LOS02 |   | Done | 13-Apr-06
  | 13,000  | 13,000
4 | T0003  | LOS01 |   | Cancel |
   | 11,000  |

now my manager asked me to produce summary report like :

Contract No | TOTAL site | Total Cancelled | Total Active | Handovered
| Contract Value |
T0001 |   2  |  0| 2
|1 |  25,000|
T0002 |  1   |  0| 1
|   1  |  11,000|
T0003 |  1   |  1| 0
|   0  |   11,000   |


is there some way to do it in mySQL? i'm using php 5 and mysql 5.1
right now i'm doing it manually, but i thinks it was really
complex...Could somebody help me with the query ?
many thanks,


Show us the query you already have rather than us just guessing the 
tables etc.


--
Postgresql  php tutorials
http://www.designmagick.com/

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



[PHP-DB] Help Needed!!

2006-11-08 Thread David Skyers
Hello,

I have an input field that inserts data into an oracle table. The users
of the system will be composing the data that goes into this input field
in Microsoft Word. 

They will also be using Microsoft Word formatting features.

1. Is it possible for my input box to retain the formatting and if so
how?
2. Can the Oracle database store this type of formatting?
3. Can the data and formatting then be extracted in XML

Thanks,

David



David Skyers
Support Analyst
Management Systems, EISD, UCL
Extension: 41849
Tel: 020 7679 1849
Email: [EMAIL PROTECTED]
 

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



Re: [PHP-DB] Help Needed!!

2006-11-08 Thread John Meyer
Forgive me for saying this, but you should be posting this to the Oracle
mailing list, not here.

David Skyers wrote:
 Hello,

 I have an input field that inserts data into an oracle table. The users
 of the system will be composing the data that goes into this input field
 in Microsoft Word. 

 They will also be using Microsoft Word formatting features.

 1. Is it possible for my input box to retain the formatting and if so
 how?
 2. Can the Oracle database store this type of formatting?
 3. Can the data and formatting then be extracted in XML

 Thanks,

 David


 
 David Skyers
 Support Analyst
 Management Systems, EISD, UCL
 Extension: 41849
 Tel: 020 7679 1849
 Email: [EMAIL PROTECTED]
  

   

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



RE: [PHP-DB] Help Needed!!

2006-11-08 Thread Bastien Koert
1. yes, user a rich text editor plugin in you web page 
(http://www.kevinroth.com/rte/ is one such beast)


2. sure, in a text / blob field

3. yes, but likely you'll need to do it as CDATA

hth

Bastien





From: David Skyers [EMAIL PROTECTED]
To: php-db@lists.php.net
Subject: [PHP-DB] Help Needed!!
Date: Wed, 8 Nov 2006 11:59:28 -

Hello,

I have an input field that inserts data into an oracle table. The users
of the system will be composing the data that goes into this input field
in Microsoft Word.

They will also be using Microsoft Word formatting features.

1. Is it possible for my input box to retain the formatting and if so
how?
2. Can the Oracle database store this type of formatting?
3. Can the data and formatting then be extracted in XML

Thanks,

David



David Skyers
Support Analyst
Management Systems, EISD, UCL
Extension: 41849
Tel: 020 7679 1849
Email: [EMAIL PROTECTED]


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



_
Say hello to the next generation of Search. Live Search – try it now. 
http://www.live.com/?mkt=en-ca


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



[PHP-DB] Help! With MySQL CASE problem

2006-10-15 Thread Andrew Darby

Hello, all.  I'm having a problem with a php/mysql app which is
probably in the SQL, so please don't get angry at me.  Basically, I
have a CASE statement that works on my localhost, but doesn't seem to
get recognised on the production server (i'm running php/mysql 5.x on
my localhost, 4.x of both on the production server).  Query looks like
this:

SELECT DISTINCT e.exhibition_id, e.title, e.begin_date,
CASE 'heading'
WHEN UNIX_TIMESTAMP( ) = e.begin_date
THEN 'Coming Up'
ELSE 'Now Showing'
END 'heading', e.end_date, special
FROM exhibition e
WHERE e.end_date = UNIX_TIMESTAMP()
ORDER BY heading DESC , e.begin_date ASC

On my localhost, the results look like this:

exhibition_id  - title   -  begin_date   - heading  - end_date  - special

84  20/21 Vision1159599600  Now Showing 1161154800  1
85  David S 1161327600  Coming Up   1162972800  0
86  Yang H 1161327600   Coming Up   1162972800  0

but on the production server looks like this:

85  David S 1161327600  Coming Up   1162972800  0
84  20/21 Vision1159599600  Now Showing 1161154800  1
86  Yang H 1161327600   Coming Up   1162972800  0

I need it to sort like the localhost, and can't figure out what's
happening.  I can't seem to ORDER BY at all on the production server.
Any ideas?  I'm going nuts.

Thanks,

Andrew

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



[PHP-DB] Help displaying Column Names

2006-09-14 Thread Grant Griffith
Hello All,

 

I am fairly new to PHP but have coded in asp and asp.net for years.  I
am trying to find the code that will allow me to display the name of the
column's from the table I am using.  Below is the code where I am
writing all the data out in a comma delimited fashion, but I want to
make the very first row show the name of the database table names.  For
example I want to show the ID,Name,Address, etc...

 

Can someone tell me what that command is in PHP?  I have searched and
can not find anything, I guess I am searching for the wrong info as I
know it can be done!!!

 

code snippet

$sel_result = mysql_query(select * from customerdata where account_type
= '$tmpType',$db);

 

//Now loop thru account types and show the one selected

while($sel_row=mysql_fetch_array($sel_result))

  {

  print
\$sel_row[0]\,\$sel_row[1]\,\$sel_row[2]\,\$sel_row[3]\,\$sel_
row[4]\,\$sel_row[5]\,\$sel_row[6]\,\$sel_row[7]\,\$sel_row[8]\
,\$sel_row[9]\,;

  print
\$sel_row[10]\,\$sel_row[11]\,\$sel_row[12]\,\$sel_row[13]\,\$
sel_row[14]\,\$sel_row[15]\,\$sel_row[16]\,\$sel_row[17]\,\$sel_
row[18]\,\$sel_row[19]\,;

  print
\$sel_row[20]\,\$sel_row[21]\,\$sel_row[22]\,\$sel_row[23]\,\$
sel_row[24]\,\$sel_row[25]\,\$sel_row[26]\,\$sel_row[27]\\n;

  }

/codesnippet

 

Thanks,

Grant Griffith

Web Application Developer

Enhanced Telecommunications

http://www.etczone.com

812-932-1000

 



Re: [PHP-DB] Help displaying Column Names

2006-09-14 Thread Dimiter Ivanov

On 9/14/06, Miguel Guirao [EMAIL PROTECTED] wrote:



You haven't searched at all, go to www.php.net and look up for
mysql_field_name() and related functions!!

-Original Message-
From: Grant Griffith [mailto:[EMAIL PROTECTED]
Sent: Jueves, 14 de Septiembre de 2006 10:22 a.m.
To: php-db@lists.php.net
Subject: [PHP-DB] Help displaying Column Names


Hello All,



I am fairly new to PHP but have coded in asp and asp.net for years.  I
am trying to find the code that will allow me to display the name of the
column's from the table I am using.  Below is the code where I am
writing all the data out in a comma delimited fashion, but I want to
make the very first row show the name of the database table names.  For
example I want to show the ID,Name,Address, etc...



Can someone tell me what that command is in PHP?  I have searched and
can not find anything, I guess I am searching for the wrong info as I
know it can be done!!!



This functionality is related to the database you are using. Thus you
have to look into the functions that PHP provides for this database.

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



[PHP-DB] help width sql

2006-05-02 Thread suad

hi

I have a problem whith inforcing the result of a selekect query, here is 
my tables and the query:


I create this 4 tables:

CREATE TABLE a (
a_id SERIAL PRIMARY KEY,
a_name text );

CREATE TABLE b (
b_id SERIAL PRIMARY KEY,
b_price INT2 );

CREATE TABLE c (
c_id SERIAL PRIMARY KEY,
a_id INT4 REFERENCES a ON UPDATE CASCADE ON DELETE CASCADE,
b_id INT4 REFERENCES b ON UPDATE CASCADE ON DELETE CASCADE,
c_price INT2 );

CREATE TABLE d (
d_id SERIAL PRIMARY KEY,
a_id INT4 REFERENCES a ON UPDATE CASCADE ON DELETE CASCADE,
b_id INT4 REFERENCES b ON UPDATE CASCADE ON DELETE CASCADE,
d_price INT2 );

Insert some values:

INSERT INTO a (a_name) VALUES ('org1');
INSERT INTO a (a_name) VALUES ('org2');
INSERT INTO a (a_name) VALUES ('org3');

INSERT INTO b (b_price) VALUES (100);
INSERT INTO b (b_price) VALUES (200);
INSERT INTO b (b_price) VALUES (50);

INSERT INTO c (a_id, b_id,c_price) VALUES (1,1,50);
INSERT INTO c (a_id, b_id,c_price) VALUES (2,1,50);
INSERT INTO c (a_id, b_id,c_price) VALUES (1,2,100);
INSERT INTO c (a_id, b_id,c_price) VALUES (2,2,100);
INSERT INTO c (a_id, b_id,c_price) VALUES (1,3,25);
INSERT INTO c (a_id, b_id,c_price) VALUES (3,3,25);

INSERT INTO d (a_id, b_id,d_price) VALUES (1,1,50);
INSERT INTO d (a_id, b_id,d_price) VALUES (2,1,50);
INSERT INTO d (a_id, b_id,d_price) VALUES (1,2,100);
INSERT INTO d (a_id, b_id,d_price) VALUES (2,2,100);

a_id | a_name
--+
   1 | org1
   2 | org2
   3 | org3

b_id | b_price
--+-
   1 | 100
   2 | 200
   3 |  50

c_id | a_id | b_id | c_price
--+--+--+-
   1 |1 |1 |  50
   2 |2 |1 |  50
   3 |1 |2 | 100
   4 |2 |2 | 100
   5 |1 |3 |  25
   6 |3 |3 |  25

d_id | a_id | b_id | d_price
--+--+--+-
   1 |1 |1 |  50
   2 |2 |1 |  50
   3 |1 |2 | 100
   4 |2 |2 | 100


SELECT SUM(c_price) as sum,(SELECT SUM(d_price) FROM d WHERE 
a_id=t1.a_id ) AS payed FROM c AS t1 group by a_id order by payed;


the result of this query is:

sum | payed
-+---
150 |   150
175 |   150
 25 |

(3 rows)


The question is : how can I force that the result of the col payed to be 
zerro 0 insted of notthig (NULL)

and the order will be in way that the zerro's values comes first.
and the result will be:

sum | payed
-+---
 25 |   0
150 |   150
175 |   150

Thanks
Suad

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



[PHP-DB] help in sql - postgresql

2006-05-02 Thread suad

Hi,

I need some help in sql - postgresql:

I create this 4 tables:

CREATE TABLE a (
a_id SERIAL PRIMARY KEY,
a_name text );

CREATE TABLE b (
b_id SERIAL PRIMARY KEY,
b_price INT2 );

CREATE TABLE c (
c_id SERIAL PRIMARY KEY,
a_id INT4 REFERENCES a ON UPDATE CASCADE ON DELETE CASCADE,
b_id INT4 REFERENCES b ON UPDATE CASCADE ON DELETE CASCADE,
c_price INT2 );

CREATE TABLE d (
d_id SERIAL PRIMARY KEY,
a_id INT4 REFERENCES a ON UPDATE CASCADE ON DELETE CASCADE,
b_id INT4 REFERENCES b ON UPDATE CASCADE ON DELETE CASCADE,
d_price INT2 );

Insert some values:

INSERT INTO a (a_name) VALUES ('org1');
INSERT INTO a (a_name) VALUES ('org2');
INSERT INTO a (a_name) VALUES ('org3');

INSERT INTO b (b_price) VALUES (100);
INSERT INTO b (b_price) VALUES (200);
INSERT INTO b (b_price) VALUES (50);

INSERT INTO c (a_id, b_id,c_price) VALUES (1,1,50);
INSERT INTO c (a_id, b_id,c_price) VALUES (2,1,50);
INSERT INTO c (a_id, b_id,c_price) VALUES (1,2,100);
INSERT INTO c (a_id, b_id,c_price) VALUES (2,2,100);
INSERT INTO c (a_id, b_id,c_price) VALUES (1,3,25);
INSERT INTO c (a_id, b_id,c_price) VALUES (3,3,25);

INSERT INTO d (a_id, b_id,d_price) VALUES (1,1,50);
INSERT INTO d (a_id, b_id,d_price) VALUES (2,1,50);
INSERT INTO d (a_id, b_id,d_price) VALUES (1,2,100);
INSERT INTO d (a_id, b_id,d_price) VALUES (2,2,100);

a_id | a_name
--+
   1 | org1
   2 | org2
   3 | org3

b_id | b_price
--+-
   1 | 100
   2 | 200
   3 |  50

c_id | a_id | b_id | c_price
--+--+--+-
   1 |1 |1 |  50
   2 |2 |1 |  50
   3 |1 |2 | 100
   4 |2 |2 | 100
   5 |1 |3 |  25
   6 |3 |3 |  25

d_id | a_id | b_id | d_price
--+--+--+-
   1 |1 |1 |  50
   2 |2 |1 |  50
   3 |1 |2 | 100
   4 |2 |2 | 100


SELECT SUM(c_price) as sum,(SELECT SUM(d_price) FROM d WHERE 
a_id=t1.a_id ) AS payed, SUM(c_price)-(SELECT SUM(d_price) FROM d WHERE 
a_id=t1.a_id ) AS to_pay FROM c AS t1 group by a_id order by payed;


the result of this query is:

 sum | payed | to_pay
-+---+
150 |   150 |  0
175 |   150 | 25
 25 |   |



*The question is* : how can I force that the result of the col payed to 
be zerro 0 insted of nothing (NULL)

and the order will be in way that the zerro's values comes first.
and the result will be:

 sum | payed | to_pay
-+---+
 25 | 0 |  0
150 |   150 |  0
175 |   150 | 25

Thanks
Suad

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



  1   2   3   4   5   6   >