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

2011-06-13 Thread C0mf0rtably Numb
Hello everyone,

I am in the process of learning php and I was trying to connect to a mysql
database on my own computer(localhost). I have done the following as
prerequisites:

copied the dll files in system32
removed the semicolon(;) from extension=php_mysqli.dll

In spite of doing the above when I try to run the following :

?php
$db = new MySQLi('localhost', 'root', 'Password123', 'test');
$sql = 'SELECT * FROM a123';
$result = $db-query($sql);

while($row = $result-fetch_object()) {
echo 'div' . $row-name . '/div';
}

$db-close();
?

I get the error: *Fatal error*: Class 'MySQLi' not found in *C:\Program
Files\Apache Software Foundation\Apache2.2\htdocs\a.php* on line *2

*Please guide me as to how can I get rid of this error?

Regards,
Kushal


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

2011-06-13 Thread C0mf0rtably Numb
Okay. I tried using that too. If I run this:
?php
$link = mysql_connect('localhost', 'root',

'Password123');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?

I get the error: *Fatal error*: Call to undefined function mysql_connect()
in *C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\a.php* on
line *2

*I think there is something wrong with my configuration.

On Mon, Jun 13, 2011 at 6:00 PM, mrfroasty mrfroa...@gmail.com wrote:

 Your error message is about class not found.That means there is no class
 named MySQLi.Please use a textbook with online manual
 http://www.php.net/manual/en/ref.mysql.php

 On 06/13/2011 02:08 PM, C0mf0rtably Numb wrote:
  Hello everyone,
 
  I am in the process of learning php and I was trying to connect to a
 mysql
  database on my own computer(localhost). I have done the following as
  prerequisites:
 
  copied the dll files in system32
  removed the semicolon(;) from extension=php_mysqli.dll
 
  In spite of doing the above when I try to run the following :
 
  ?php
  $db = new MySQLi('localhost', 'root', 'Password123', 'test');
  $sql = 'SELECT * FROM a123';
  $result = $db-query($sql);
 
  while($row = $result-fetch_object()) {
  echo 'div' . $row-name . '/div';
  }
 
  $db-close();
  ?
 
  I get the error: *Fatal error*: Class 'MySQLi' not found in *C:\Program
  Files\Apache Software Foundation\Apache2.2\htdocs\a.php* on line *2
 
  *Please guide me as to how can I get rid of this error?
 
  Regards,
  Kushal
 


 --
 Extra details:
 OSS:Gentoo Linux
 profile:x86
 Hardware:msi geforce 8600GT asus p5k-se
 location:/home/muhsin
 language(s):C/C++,PHP,SQL,HTML
 Typo:40WPM
 url:http://www.mzalendo.net
 url:http://www.zanbytes.com






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

2011-06-13 Thread Richard Quadling
On 13 June 2011 13:26, C0mf0rtably Numb 08.kus...@gmail.com wrote:
 Okay. I tried using that too. If I run this:
 ?php
 $link = mysql_connect('localhost', 'root',

 'Password123');
 if (!$link) {
    die('Could not connect: ' . mysql_error());
 }
 echo 'Connected successfully';
 mysql_close($link);
 ?

 I get the error: *Fatal error*: Call to undefined function mysql_connect()
 in *C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\a.php* on
 line *2

 *I think there is something wrong with my configuration.

 On Mon, Jun 13, 2011 at 6:00 PM, mrfroasty mrfroa...@gmail.com wrote:

 Your error message is about class not found.That means there is no class
 named MySQLi.Please use a textbook with online manual
 http://www.php.net/manual/en/ref.mysql.php

 On 06/13/2011 02:08 PM, C0mf0rtably Numb wrote:
  Hello everyone,
 
  I am in the process of learning php and I was trying to connect to a
 mysql
  database on my own computer(localhost). I have done the following as
  prerequisites:
 
  copied the dll files in system32
  removed the semicolon(;) from extension=php_mysqli.dll
 
  In spite of doing the above when I try to run the following :
 
  ?php
  $db = new MySQLi('localhost', 'root', 'Password123', 'test');
  $sql = 'SELECT * FROM a123';
  $result = $db-query($sql);
 
  while($row = $result-fetch_object()) {
      echo 'div' . $row-name . '/div';
  }
 
  $db-close();
  ?
 
  I get the error: *Fatal error*: Class 'MySQLi' not found in *C:\Program
  Files\Apache Software Foundation\Apache2.2\htdocs\a.php* on line *2
 
  *Please guide me as to how can I get rid of this error?
 
  Regards,
  Kushal
 


 --
 Extra details:
 OSS:Gentoo Linux
 profile:x86
 Hardware:msi geforce 8600GT asus p5k-se
 location:/home/muhsin
 language(s):C/C++,PHP,SQL,HTML
 Typo:40WPM
 url:http://www.mzalendo.net
 url:http://www.zanbytes.com






Copying the files to windows\system ... what files? Where were you
told to do this?

Normally the extension files you need for PHP are in C:\PHP5\ext (or PHPx).

I've never copied a single file into my Windows folder for PHP.



-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

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



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

2011-06-13 Thread C0mf0rtably Numb
Any help?

On Mon, Jun 13, 2011 at 5:38 PM, C0mf0rtably Numb 08.kus...@gmail.comwrote:

 Hello everyone,

 I am in the process of learning php and I was trying to connect to a mysql
 database on my own computer(localhost). I have done the following as
 prerequisites:

 copied the dll files in system32
 removed the semicolon(;) from extension=php_mysqli.dll

 In spite of doing the above when I try to run the following :

 ?php
 $db = new MySQLi('localhost', 'root', 'Password123', 'test');
 $sql = 'SELECT * FROM a123';
 $result = $db-query($sql);

 while($row = $result-fetch_object()) {
 echo 'div' . $row-name . '/div';
 }

 $db-close();
 ?

 I get the error: *Fatal error*: Class 'MySQLi' not found in *C:\Program
 Files\Apache Software Foundation\Apache2.2\htdocs\a.php* on line *2

 *Please guide me as to how can I get rid of this error?

 Regards,
 Kushal



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

2011-06-13 Thread Richard Quadling
On 13 June 2011 14:12, C0mf0rtably Numb 08.kus...@gmail.com wrote:
 Any help?

 On Mon, Jun 13, 2011 at 5:38 PM, C0mf0rtably Numb 08.kus...@gmail.comwrote:

 Hello everyone,

 I am in the process of learning php and I was trying to connect to a mysql
 database on my own computer(localhost). I have done the following as
 prerequisites:

 copied the dll files in system32
 removed the semicolon(;) from extension=php_mysqli.dll

 In spite of doing the above when I try to run the following :

 ?php
 $db = new MySQLi('localhost', 'root', 'Password123', 'test');
 $sql = 'SELECT * FROM a123';
 $result = $db-query($sql);

 while($row = $result-fetch_object()) {
     echo 'div' . $row-name . '/div';
 }

 $db-close();
 ?

 I get the error: *Fatal error*: Class 'MySQLi' not found in *C:\Program
 Files\Apache Software Foundation\Apache2.2\htdocs\a.php* on line *2

 *Please guide me as to how can I get rid of this error?

 Regards,
 Kushal



If you are able to reset your system and then read through the manual
Windows installation documentation at
http://uk.php.net/manual/en/install.windows.manual.php

Personally, I'd change the path to C:\PHP5,x,y, where the x and y are
the complete version numbers (PHP5.3.6) , but that's me. I then use
Junction to create C:\PHP5 which maps to C:\PHP5.3.6.

Junction is like a link at least in terms of how I use it.

I'd also take a good look at
http://uk.php.net/manual/en/install.windows.commandline.php and
http://uk.php.net/manual/en/install.windows.apache2.php

One covers making better use of PHP from the command line and the
other deals with getting things working with Apache.

And an issue. Please make sure you use the right version of PHP for
the version of Apache you are using. If you are using a VC9 build
Apache (say from ApacheLounge or something like that), then you can
use a VC9 build of PHP.

If you are using an VC6 build, then you must use a VC6 build of PHP
and that limits you to PHP5.2 (PHP5.2.17 is the latest there). I use
IIS with FastCGI so I use a NTS (non thread safe) build. I don't know
which sort of threading model you need for Apache (hopefully it is
mentioned in one of the Apache related pages).

And with regard to the php.ini file, you can make it available by many
different means.

I use the registry. This is documented at
http://uk.php.net/manual/en/configuration.file.php

Look at ...

As of PHP 5.2.0, the location of the php.ini file can be set for
different versions of PHP. The following registry keys are examined in
order: [HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y.z],
[HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y] and
[HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x], where x, y and z mean the PHP
major, minor and release versions. If there is a value for IniFilePath
in these keys, then the first one found will be used as the location
of the php.ini (Windows only).

[HKEY_LOCAL_MACHINE\SOFTWARE\PHP], value of IniFilePath (Windows only).

And, I think finally, if you need different php.ini files for apache
and the command line, ...

If php-SAPI.ini exists (where SAPI is used SAPI, so the filename is
e.g. php-cli.ini or php-apache.ini), it's used instead of php.ini.
SAPI name can be determined by php_sapi_name().

Richard.

-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

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



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

2011-06-13 Thread Richard Quadling
On 13 June 2011 15:28, C0mf0rtably Numb 08.kus...@gmail.com wrote:
 My php and apache are working fine together. I was doing good with php and
 apache until I decided to work with mysql. I will have a look at all the
 links you provided and see if gives me a solution. Thanks.

 On Mon, Jun 13, 2011 at 7:36 PM, Richard Quadling rquadl...@gmail.com
 wrote:

 On 13 June 2011 14:12, C0mf0rtably Numb 08.kus...@gmail.com wrote:
  Any help?
 
  On Mon, Jun 13, 2011 at 5:38 PM, C0mf0rtably Numb
  08.kus...@gmail.comwrote:
 
  Hello everyone,
 
  I am in the process of learning php and I was trying to connect to a
  mysql
  database on my own computer(localhost). I have done the following as
  prerequisites:
 
  copied the dll files in system32
  removed the semicolon(;) from extension=php_mysqli.dll
 
  In spite of doing the above when I try to run the following :
 
  ?php
  $db = new MySQLi('localhost', 'root', 'Password123', 'test');
  $sql = 'SELECT * FROM a123';
  $result = $db-query($sql);
 
  while($row = $result-fetch_object()) {
      echo 'div' . $row-name . '/div';
  }
 
  $db-close();
  ?
 
  I get the error: *Fatal error*: Class 'MySQLi' not found in *C:\Program
  Files\Apache Software Foundation\Apache2.2\htdocs\a.php* on line *2
 
  *Please guide me as to how can I get rid of this error?
 
  Regards,
  Kushal
 
 

 If you are able to reset your system and then read through the manual
 Windows installation documentation at
 http://uk.php.net/manual/en/install.windows.manual.php

 Personally, I'd change the path to C:\PHP5,x,y, where the x and y are
 the complete version numbers (PHP5.3.6) , but that's me. I then use
 Junction to create C:\PHP5 which maps to C:\PHP5.3.6.

 Junction is like a link at least in terms of how I use it.

 I'd also take a good look at
 http://uk.php.net/manual/en/install.windows.commandline.php and
 http://uk.php.net/manual/en/install.windows.apache2.php

 One covers making better use of PHP from the command line and the
 other deals with getting things working with Apache.

 And an issue. Please make sure you use the right version of PHP for
 the version of Apache you are using. If you are using a VC9 build
 Apache (say from ApacheLounge or something like that), then you can
 use a VC9 build of PHP.

 If you are using an VC6 build, then you must use a VC6 build of PHP
 and that limits you to PHP5.2 (PHP5.2.17 is the latest there). I use
 IIS with FastCGI so I use a NTS (non thread safe) build. I don't know
 which sort of threading model you need for Apache (hopefully it is
 mentioned in one of the Apache related pages).

 And with regard to the php.ini file, you can make it available by many
 different means.

 I use the registry. This is documented at
 http://uk.php.net/manual/en/configuration.file.php

 Look at ...

 As of PHP 5.2.0, the location of the php.ini file can be set for
 different versions of PHP. The following registry keys are examined in
 order: [HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y.z],
 [HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y] and
 [HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x], where x, y and z mean the PHP
 major, minor and release versions. If there is a value for IniFilePath
 in these keys, then the first one found will be used as the location
 of the php.ini (Windows only).

 [HKEY_LOCAL_MACHINE\SOFTWARE\PHP], value of IniFilePath (Windows only).

 And, I think finally, if you need different php.ini files for apache
 and the command line, ...

 If php-SAPI.ini exists (where SAPI is used SAPI, so the filename is
 e.g. php-cli.ini or php-apache.ini), it's used instead of php.ini.
 SAPI name can be determined by php_sapi_name().

 Richard.

 --
 Richard Quadling
 Twitter : EE : Zend : PHPDoc
 @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea



If you have PHP working, then create the following file and save it as
info.php in the docroot of your website.


?php
phpinfo();
?


When you load this, you'll see a list of settings being reported. The
important one in this instance is the value for the loaded
configuration file near the top of the page.

That's the INI file you are needing to edit.

Open it in your favourite text editor and look for the lines starting with ...

extension=

You need to choose which mysql driver you need - there are several.

mysql
myslqi
pdo_mysql


If you are using a modern mysql, then mysqli is the one to use. So,
add a line to the INI file that looks like ...

extension=php_mysqli.dll

It may already exist with a ; in front of it. Remove the ;

Save the ini.

Restart Apache.

You MAY need to reboot Windows.

Now load up the phpinfo() page again.

Do you see mysqli content?

If you do, then at that stage, the mysqli extension is loaded and you
can start using it : http://uk.php.net/manual/en/book.mysqli.php


-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

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

[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] Re: Help with AVG()

2011-06-13 Thread Jim Giner
you have no WHERE clause in your query.
Ron Piggott ron.pigg...@actsministries.org wrote in message 
news:F6C4EF096B4446CA8AECD201C1E86C39@RonPiggottPC...

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 Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] delete message function

2011-06-13 Thread Chris Stinemetz
I created the below delete function, but it doesn't seem to be working
correctly. When I enter the correct password it get my echo Incorrect
Password Did not Delete! When I leave the password blank the message
will delete from mysql table.

Am I missing something??

Thanks in advance,

Chris

function delete_message($msg) {
extract($msg, EXTR_PREFIX_ALL, 'row');
$result = mysql_query(SELECT ID FROM mbmsgs WHERE Parent = $row_ID;);

while ($row = mysql_fetch_array($result)) {
delete_message($row);
}
mysql_query(DELETE FROM mbmsgs WHERE ID = $row_ID;);
}

$result = mysql_query(SELECT Title, Password FROM mbmsgs WHERE ID
= {$_REQUEST['Msg']};);
if (!$result) exit;
if (!mysql_num_rows($result)) exit;
extract(mysql_fetch_array($result), EXTR_PREFIX_ALL, 'msg');

if (isset($_POST['Password'])) {
if (sha1($_POST['Password']) != $msg_Password) {
echo Incorrect password did not delete!;
exit;

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



[PHP-DB] Re: delete message function

2011-06-13 Thread Chris Stinemetz
On Tue, Jun 14, 2011 at 12:31 AM, Chris Stinemetz
chrisstinem...@gmail.com wrote:
 I created the below delete function, but it doesn't seem to be working
 correctly. When I enter the correct password it get my echo Incorrect
 Password Did not Delete! When I leave the password blank the message
 will delete from mysql table.

 Am I missing something??

 Thanks in advance,

 Chris

Sorry. I left out the call to the function. Below is the whole snippit
for the function and call.

function delete_message($msg) {
extract($msg, EXTR_PREFIX_ALL, 'row');
$result = mysql_query(SELECT ID FROM mbmsgs WHERE Parent = $row_ID;);

while ($row = mysql_fetch_array($result)) {
delete_message($row);
}
mysql_query(DELETE FROM mbmsgs WHERE ID = $row_ID;);
}

$result = mysql_query(SELECT Title, Password FROM mbmsgs WHERE ID
= {$_REQUEST['Msg']};);
if (!$result) exit;
if (!mysql_num_rows($result)) exit;
extract(mysql_fetch_array($result), EXTR_PREFIX_ALL, 'msg');

if (isset($_POST['Password'])) {
if (sha1($_POST['Password']) != $msg_Password) {
echo Incorrect password did not delete!;
exit;
}
$result = mysql_query(SELECT ID FROM mbmsgs WHERE Parent =
{$_POST['Msg']};);

while ($row = mysql_fetch_array($result)) {
delete_message($row);
}

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