Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




How Do We Use OOP With Php & Mysql


I am new to the OOP. If someone help me how to use oop and explain me what is the advantages of using OOP?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
PHP And MySQL: How To Properly Call A Stored Procedure With Output Parameters From PHP - Mysql, Mysqli, Or PDO
I am currently using PHP 5 and MySQL 5, both on Fedora Core 5. I am
unable to call a MySQL stored procedure that returns output parameters
using mysql, mysqli, or PDO. I'm having a hell of a time with it...

The following comes from phpinfo():
PHP Version: 5.1.2
mysql Client API version: 5.0.18
mysqli Client API version: 5.0.18
PDO Driver for MySQL, client library version: 5.0.18

MySQL version, from running SELECT version(); = 5.0.18

Here's the procedure I've created in MySQL:
CREATE PROCEDURE testproc(OUT p_testvar varchar(50)) BEGIN SET
p_testvar = 'HELLO WORLD!' END
[color=blue]
>From the MySQL Command Line, I can do the following:[/color]
mysql> call testproc(@a);
Query OK, 0 rows affected (0.00 sec)

mysql> select @a;
+--------------+
| @a |
+--------------+
| HELLO WORLD! |
+--------------+
1 row in set (0.00 sec)

MySQL Error - Supplied Argument Is Not A Valid MySQL-Link Resource
I am getting the error

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/server7/public_html/71/arranholloway/database4.php on line 7

I tested my code on local computer and there were no problems, the error message only appeared when I loaded it onto my web hosters server. I'm new to PHP so its probably something simple but any help would be appreciated.

Connection With MySQL. Navicat - CANNOT CONNECT TO MYSQL SERVER ON LOCALHOST
I am new in PHP & MYSQL. I installed PHP & MYSQL properly. To easy
operate for MYSQL I installed Navicat and it installed properly. But
when I am going to test the connection between MYSQL & Navicate the
error message showing CANNOT CONNECT TO MYSQL SERVER ON LOCALHOST
(10022) it should mention that my connection name = localhost, Ip =
localhost,port = 3306 , user name = root in Navicat.


PHP Saying Error In Mysql Syntax, But Written My Mysql Query Browser!
I have a basic db that I access with MySQL query browser. Everything
seems fine to me but I am using this db as part of a php shopping
basket and when I try to add an item I get:

Notice: Query failed: You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near '>function.extract]: First argument should be an
array in functions.inc.php on line 31
Notice: Undefined variable: price in functions.inc.php on line 36
Notice: Undefined variable: price in functions.inc.php on line 39
Notice: Undefined variable: total in unctions.inc.php on line 39

I'm assuming the last three are caused by this problem as price should
be passed to the cart, and total is worked out using it. However
although I know mySQL code it was the MySQL query browser that
actually generated the code and I cannot see a way to view or debug
the code.

The db has one table in it which is made up of id, name, subname,
desc, and price.

The code in the php file that is being referred to is:

Automatic Scheduled MySQL Backup (MySQL Dump)
Is it possible to configure a UNIX/LINUX server to do a MySQL Dump for a database on an automatic schedule and then to email the dump file to me (the administrator)?

I want to be able to have my database automatically backed up every week and emailed to me for storage purposes without any action on my part.

PHP/MySQL: Using PHP To Probe MySQL Db And Send An Email Automatically
Let's say you have a login feature on your site... and a user forgets their password which is stored along side their email address in a MySQL database. Is it possible to use PHP to automatically send the password to that email address upon request? If so, please provide a detailed solution. If not, can Java be used in some way to accomplish this?

--with-mysql ? Php-4.4.2 With Mysql Install In Special Directory
I'm trying to link php-4.4.2 with mysql install in special directory,
like /usr/newsystem/mysql, but whatever options I try, php always gets
linked to version in /usr/local/lib. I've tried several options:

--with-mysql=/usr/newsystem/mysql
--with-mysql-dir=/usr/newsystem/mysql
--with-mysql-lib=/usr/newsystem/mysql
--with-mysql-lib-dir=/usr/newsystem/mysql

....but none of them work, CLI is always build against /usr/local/lib/
libraries.

Create A Sequence In MySQL, With Mysql Variable?
This might be fairly easy to do and I think I've seen the code before,
but I haven't seen many good examples of this. Of course Pear::DB
probably uses this code in some of its API, probably in dealing with
auto-increment indexes and prepared statements.

Maybe I'm off base here, but I'm looking for something like this:
(psuedo-code)
Of course the seq table only needs 1 row holding id, which is
updated.
select id from tbl;
// get result resouce and do fetch, store value in $myid
set @myvar = $myid + 1; // can php send to MySQL with a query? (
never seen this )
update myseq set id=@myvar // send this statement through in a
update/query

// for use in PHP code
$newSeqVal = $myid +1

Create A Sequence In MySQL, With Mysql Variable?
This might be fairly easy to do and I think I've seen the code before,
but I haven't seen many good examples of this. Of course Pear::DB
probably uses this code in some of its API, probably in dealing with
auto-increment indexes and prepared statements.

Maybe I'm off base here, but I'm looking for something like this:
(psuedo-code)
Of course the seq table only needs 1 row holding id, which is
updated.
select id from tbl;
// get result resouce and do fetch, store value in $myid
set @myvar = $myid + 1; // can php send to MySQL with a query? (
never seen this )
update myseq set id=@myvar // send this statement through in a
update/query

// for use in PHP code
$newSeqVal = $myid +1

Copy And Paste On MySQL To MySQL Database
Would there be any issues if i literary Copy and Paste a mysql db from one server to another mysql db server? When i say "copy and paste" is just like tranferring one word doc from one pc to another pc.

I tried the copy and paste already and the new server had recognize the DB i had pasted. I just want to confirm if there would be issues doing it so.. Or should i use Mysql.com Migration toolkit?

Php/Mysql- Uploading Mysql Database
I've set up a basic database using Mysql (just creating a web blog I followed a tutorial) and then started writing the php code for interacting with the database. how do I put the Mysql database onto the the web server where I have server space (the server I use is just some company that I pay €100 a year for). I need the php file to get the data from the Mysql database...

Problem Getting PHP To Recognize MySQL, Using PHP 4.3.7 And MySQL 4.0.20
I have both PHP 4.0( RPM) installed and MySQL 4.0.20 installed with the
mysqld daemon up and running. But when I look at the output of phpinfo() ,
I do not see it there, which is worrisome and so I tried to recompile PHP
and do ./configure with the --with-mysql=path but I don't really know
where my mysql's header files should be , is there any way to find that
out by using any of the mysql commands?

I did try to do ./configure for PHP4 without any parameters and when I
looked at the output, I do see that PHP seems to recognize that mySQL is
there :

....
checking for MSSQL support via FreeTDS... no
checking for MySQL support... yes
checking for specified location of the MySQL UNIX socket... no
checking for MySQL UNIX socket location... /var/lib/mysql/mysql.sock
checking for inline... (cached) inline
.....

Hence, why is that when I do phpinfo() , mySQL still doesn't show up?

I suspect that mysql isn't working correctly with php, because if I use
the mysql_connect() function in my php, I get the error "Fatal error: Call
to undefined function: mysql_connect() "
and yet it DOES seem like PHP recognizes mysql is there.

That "unable to recognize mysql_connect function" error comes up after
installing PHP using ./configure with or without any parameters.

Seeking Resources On Mysql, Not Mysql.com
I'm looking for some resources that can aid me in getting deeper into
php/mysql.
I am presently looking at a syntax that lets me check a mysql row for one
particular value, using sql.
Then I look for a sql based solution to get a column name based on the above
value.
Last I need to update that row, actually NULL that particular field in that
particular row.

I've been reading mysql.com the function list all afternoon, nothing found
that might make it able for me to write those statements in question.
So now I better expand and seek new sources, google.com didn't give me much
while searching the groups.

Migrate Old Mysql DB To New Mysql Server
I am trying to migrate our old mysql DB to another new mysql server using AB: MySQL Migration Tool. The migration has some problem.

One of the tables from the old DB had a column defined Datatype as DATE. However, when I do migration. The migration informs me that " The following error occured while transfering data from log Cannot convert value '0000-00-00' from column 13 to TIMESTAMP."

I believe the migration forces to convert the datatype into timestamp. The work around i can do on this is to change the datatype of the column on the old DB into Timestamp. However, I don't want that. I want to retain the DATE datatype.

How To Compare 2 Dates In Mysql As Mysql Treats Dates As String ?
I'm trying to compare two dates in MYSQL. But its not treating the dates as numbers, but as strings. I try using strtotime but that did not work.

MySQL? XML? XML And MySQL? SQLite?!
I've been using PHP for a while now and I'm beginning to migrate to
PHP5. So far, I'm impressed.

I need to develop an admin application to enable users to update a
website that is built on a MySQL database. In most cases, I'd simply
develop an application to manipulate the database but as the website is
updated fairly infrequently, I am considering a number of further
options instead to alleviate server load.

I am considering retaining the MySQL database for structure and building
scripts to generate XML from the data that can be processed and
transformed server-side (XSLT). Another option is SQLite. And yet
another approach is to generate static HTML pages from the database when
it needs to be updated or published.



MYSQL To WEB
What I want is for people to be able to come to a page put in an id number and all their information pop up on the screen, then maybe even have then be able to edit it, can anyone help or tell me where to look.

PHP/MySQL
I've got a petition database running from MySQL and i want to display the entries or "signatures" on a page with a limit of 100 signatures per page, creating links at the bottom of each page.

Say i had 243 signatures, I want the links at the bottom to look like this:

"1-100, 101-200, 201-243"

rather than:

"1-100, 101-200, 201-300" (Which is what i had working before)

I've done this code, but it's not working. Here is the code:

PHP, MySQL On IIS
I am running IIS, and i have php installed (and is working). I have installed MySQL onto the same pc, and i am running mysqladmin. If i want to run mysql commands in php should they work like this, or do i need to set up an odbc connection to the mysql server or something?

I am asking because currently what is happening is that i have IIS running along with MySQLadmin, and when i try to connect to the database it says it can't.

New To PHP And MySQL
I'm am just beginning to learn PHP and MySQL. My web host does not allow telnet access, so I am trying to find a php script or something that will let me edit my database through my browser. Does anyone know of anything?

POS With MySql And PHP
I am thinking to create an app POS using mysql,php and apache with web interface for a company that it wants reduce costs about dedicated lines for using internet.

My question is :
1-)Can I use the mask for function keys and how?
2-)How can I print using a button or a link to send directly to printer or using Print Manager for Windows?
3-)If I open a new window how can I close this using PHP?

MySQL
is there anyways to *downlaod* a whole MySQL DB, and export it into MS Acces / Excel ?

Php And Mysql, But A Different One
I am workin on a intranet which has linux, apache, mysql and php for the local site. We are connecting to the server via telnet and we editing the php files. But sometimes I require to connect to mysql database directly so that we could do the query and check certain updations. I am workin from a windows 98, is there a client through which I can connect to a remote mysql server and do some queries?

From TXT To A MySQL Db
I need some helps/tips to know if a transition from a txt file to a sql
database is viable to do.

I have a TXT file that has lots of records like this:

While() And MySQL
I have a database where I use the while() command to iterate through each
row and their resultant arrays to populate a table as the while() command
is executed.

I would like to have in the database a "pointer" that says something like
$MyString, but in the PHP $MyString is given a URL of an image. So every
time during the while() command it comes across the text $MyString it
instead substitutes it for the URL instead of echoing $MyString.

I have tried putting the URL of the image in a few fields directly into the
database, whilst this method does work, it is not the solution I want as
the database fields would start becoming large to cope with the URL instead
of a short VARCHAR declaration.

Does anyone have an idea how to get the text to be substituted while the
while() command is going through an array? The array cannot be "messed"
around with, it has to stay in the order it is being read out of for
display into a table.

My current code looks like:

$Yes = '<img src="tick.png">'

while ($row = @mysql_fetch_array($result))
{
$FName = $row['FeatureName'];
$AccountType1 = $row['Coll-1'];
$AccountType2 = $row['Coll-2'];
$AccountType3 = $row['Coll-3'];
$AccountType4 = $row['Coll-4'];

$entry .= "<tr class="BottomLine"><td
style="text-align:left;"><B>$FName</B></td><td>$AccountType1</td>
etc.etc.
}

Mysql And Php
I am calling some data from my sql database into a form in a php4 script, most of my datas are the text like " john devis argentar", but when the data is called to my form It only displays the first part of data ( "john" is displayed instead of "john devis argentar").
I have tried urlencode and urldecode function but what I get is: "john+devis+ argentar".
It should be very nice if some one could help me with this topic as I am in it since last week without any success.

PHP Cannot See Mysql?
I have php and mysql both working seperately but not together
<?php phpinfo(); ?> - Shows everything working fine but no mention of
Mysql in it.

Mysql is setup and working properly. Users and databases all connect fine
All my PHP scripts which have mysql connection info just show as a blank
page. No error messages....

MySQL And SVN
Maybe slightly off topic, but I would like to know how you guys handle
mysql structures between different computers (and for that matter from
the developer desktop to the stable server).

I work on my home and my office computer with the same php projects. I
keep all my php files on svn, so I just update and commit the first and...

PHP And MySQL 5
I'm trying to develop under the newest MySQL using PHP. Problem is
that the newer versions of MySQL use a beafier hashing algorithm. I
can reverse the hash to a 16 bit one within MySQL, but I don't want to
do this because I would then only be able to access it with older
applications. (MySQL querybrowser will not work correctly in this case)
Is it possible to get PHP to use the newer 41 bit hash when
authenticating with MySQL?

MySQL Or PHP Or Even Both
Im trying to write an SQL statement or PHP function that looks through a column on a table (or through the results of a SQL statement) and lists the contents of that column. But if there are rows in that column with the same data it doesn't display the data again.

I don't know if this diagram will help to show what I mean or not.

id column results
1 xxx xxx
2 xxx yyy
3 xxx SQL/PHP
4 yyy
5 yyy

Any help on how I can do this would be great.(still new to it all).

MySQL->XML Via PHP
I was wondering if anyone could recommend a good script to convert a recordset (from MySQL or any db type for that matter) into XML via PHP.

Looking For PHP & MySQL For RH 7.2
I am running RedHat Linux 7.2 ... for a lot of reasons I can't upgrade it to
a later release but want to add PHP and MySQL.

Does anyone have or know of sources for those earlier releases of either PHP
or MySQL ... it seems that the earliest releases I can find were designed
for RedHat 8.0 or later.

PDO For MySQL 4.1
Does anybody know, if there is a PDO-Driver for MySQL 4.1?
I think the only thing to do is to link it to a 4.1 mysql client
library.

I would do it on my own, but i need it for a Windows system, and I do
not have a c-compiler, etc running on Windows.
Perhaps anybody already compiled it and has link, where I can download
php_pdo_mysql.dll for MySQL 4.1!

PNP & MySQL
i was wondering if anyone knew what free web servers supported both pnp and mysql. because i'm trying 2 make a forum using vBulletin and most of the free web servers i've seen so far haven't supported it.

PHP MySQL WHY?
I've been thinking on this long and hard, and I can't seem to come up
with an answer on it.

Why is it almost always assumed the MySQL will be the server for nearly
any PHP app?

Why is it MySQL and not PostGRES or SQLite?

At this point the only reason I can think of is that MySQL has a much
more friendly name. But is that really it?

Is there some winning advantage that MySQL has over PostGRES that makes
it the de-facto standard in the PHP world?

Just curious, because I've been playing with PostGRES for about a month
now and it seems to scale MUCH better than MySQL, what with
clustering,transactions and all that jazz.

From Xml To Mysql
with phpmyadmin i export a table of a mysql db in xml file. Now i want
import a xml file in a mysql db.
How can i do?

Sms To Php & Mysql
I'm looking for any resources on how to update a mysql database by sms. I guess that the sms will have to go through an sms gateway which will run the php script.

PHP And MySQL
I've currently been trying to tackle making PHP 5.1.4 use the MySQL
extension. I've followed the instructions I've seen on the web but
whenever I acces my test page, I still get a "Call to undefined
function mysql_connect()..." Basically the instructions I've found say,
to edit the php.ini file so this line is uncommented:

extensions=php_msql.dll

and to make sure that the extension_dir value points to my extensions
folder:

extension_dir = "c:phpext"

My Current setup:
Windows XP
Apache 2.2
MySQL 5.0.12
PHP 5.1.4

Is there any step I'm missing?

Php And MySQL
MySQL and php

I'm trying to design a very basic php script which displays the
contents of the table, then I want to enable the user to filter out
certain results. So I went about writing a MySQL query something like
......WHERE gender="$gender" AND group="$group" and then wrote a
form which sets the variables $gender and $group. Now is there a way of
setting $gender and $group to something that would display the whole
table?

And is this the right way of going about this? Or is there a better
way... Infact does anyone know of a good site that might guide me in
creating such a script?

Mysql
I've ever the same problem.

Table1
idperson, name, zip

table2
zip, city, region.

Table2: same zip, many cities (1000, Lausanne - 1000, Lausanne1, ...)

Now I'd like ONE query wich return the name, zip and city, but just one
record per zip.

I mean if a record in table1 has zip 1000, I only want the first occurence
of the city (in my case Lausanne).
Actually I get as many records as they are cities with the same zip.

namex,1000,Lausanne
namex,1000,Lausanne1
namex,1000,LausanneN....

How to do so ? in fact what I need is count the number of peoples in a
region, and the region is linked to a zip.

1000, Lausanne, VD
1000, Lausanne1, VD....

the actual query is
select count(idperson), region from table1 inner join table2 on table1.zip =
table2.zip group by region.

PHP And MySQL On CD-rom
I want to use PHP and mySQL on a CD-rom. So this has to function no matter what platform the user is on..Is this possible?

PHP 5.2 And Mysql
I have redhat 3.0 Enterprise, and mysql (3.58.xxx more or less)
installed from a redhat rpm,
and php 4.3.9 (installed from an rpm) - I can access data from my mysql
db using php and the "pear" Db .php. I recently upgraded my Apache to
2.2 and installed (more or less) PHP 5.2 as well - neither of these
installs were from a Redhat rpm, I downloaded the tarballs, extracted,
configed, make, etc.
Apache seems to work fine (but not with the php 4.3.9 rpm). I set the
httpd.conf file to access php 5 (libphp5.so) and can display PHP 5.2.0
info using phpinfo(). But... I cannot access any data in my mysql
database (/usr/local/share/DB.php) from the "pear". And it does not
appear that phpinfo() is reading the php.ini file. I have two php.ini
files, one in /etc (redhat rpm location), and another in
/usr/local/lib/php.ini. I have edited and changed both these files,
but the "changed" items (like default
mysql.socket=/var/lib/mysql/mysql.sock) do not show up in the phpinfo()
page. I have even renamed each php.ini file so there is no php.ini
file (like php_ini), and the phpinfo() data still displays! this is in
php 5.2.0. In 4.3.9 - all is well - the file (/etc/php.ini) is read,
etc, and I can access the db.

I have attempted to set the PHP 5.2 switch to the location where my
mysql binary is (/usr/bin/mysql), but still nothing seems to work. My
guess is that I am not selecting the correct place for PHP 5.2 to hook
up with my already installed (but old) redhat my sql rpm.

Any ideas on how I can get PHP 5.2 to work with my version of mysql?
Or should I remove the existing mysql rpm, and start fresh with a later
version of mysql - and install it from tarball, etc Then I would at
least know where the mysql stuff is. Redhat seems to spread the
package info all over the place.

MySQL And UTF-8
I created a table using :

----------------------------------------------------------------------------
CREATE TABLE test(
unicodeText VARCHAR(45) NOT NULL
)
CHARACTER SET utf8 COLLATE utf8_general_ci;
-----------------------------------------------------------------------------

in php, when i need to query for the data, i need to set the character
set per each connection, i.e.

$DB->query("SET NAMES 'utf8'");

however, i expect this is a kind of overhead ? (a roundtrip delay per
connection)

how to perform this automatically?

I tried to set "default-character-set=utf8 " in my.ini

MySQL And PHP
I'm using mySQL and PHP on a webhost, and WordPress. ...

Wordpress is what I'm using to make it easy for my pops to post articles.
My index.php uses some code to pull from the mySQL db (created by wordpress)
and puts the post content into a div, then p class. However, I'm noticing
that when the content contains html coding, it seems to fall out of the
class and lose it's padding. Is there some command I need to use to modify
the html code in the content when it's posted to my page?

Below is what I think is the relevant code: You can check the results at
www.meetwithkbh.com (yes, it's got a goal). If there's no html like <ul>'s
and <li>'s included in the post, it formats fine with the padding, but - if
there is, it'll drop out of the padding that i'm trying to keep.

<?php
$db = mysql_connect("localhost", "mywordpressdb", "*******"); /*no, these
aren't the real user/pass ;) */
mysql_select_db("dbwordpress",$db);
$result = mysql_query("SELECT id, post_title, post_content, post_date_gmt
FROM wp_posts ORDER BY post_date_gmt DESC Limit 0, 5",$db);
while ($myrow = mysql_fetch_row($result)) {
echo "<div class="post">
<p class="posttitle">";
printf("%10.60s", $myrow[1]);
echo "</p>";
echo "
<p class="postcontent">";
printf("%10.400s",$myrow[2]);
echo "...<a href="More.php">Read More</a></p>
</div><br />
";
}
mysql_close($db);
?>

Here is the css, contained in the index.php too, which is in the proper
place in the index.php:
..posttitle { font-size: 120%;
font-weight: bold;
color: white;
background: #806C59;
padding: 3px 3px 3px 1em;
margin-top:0em;
}

..postcontent { padding-left:2em;
padding-right: 2em;
text-align: justify;
}

..post {
border: 1px solid #cccccc;
line-height:1em;
}

PHP MySQL
I'm designing an application and have field defined in a table as Text where
I store Articles. I need to search the contents of my field for specific
keyword phrases for all the rows (5000+ rows). What is the best method to
do this? Should I use indexes or FullText? Also with indexes what would be
the best Key size?

PHP/Mysql Bug
I am using PHP3.0.16 on Apache 1.3.12 and Mysql 3.22.25 on a Linux machine (Redhat) with downloaded and compiled softwares as mentioned above.

In PHP, the select distinct <fieldname> clause doesnt reurn distinct record on one field. But in Mysql when thu Mysql Client I give the same distinct query, it returns correctly.
Why? Moroever instead of distinct, group by <field1> order by <field1> also doesnt return unique records on <field1> and they are not sorted either in that order.

Is this a serious BUG in php-mysql functions or somewhere. I mean it seems to work correctly in Mysql alone but not thru PHP. What other reason could there be? This needs examination, If this is true for others as well.

MySQL PHP & SSL
I am trying to use PHP & MySQL over SSL, my issue is that the data that I am
querying also needs to be available by non-secure as well.

PHP & Mysql
First time I have installed mysql.

I have not been able to connect to the server/database with a new php
installation.

I have installed IIS. Do I need this for mysql?

The php works fine. I can run scripts,etc.

When I try mysql_connect ("localhost","mysql_user", mysql_password") or
die....

I get cannot connect to Mysql server on localhost(10061) ....

How do I locate the name or define the server name? ??localhost??
How do I define or locate the username for the server?
How do I locate the password or define the password?

Is there a program (control panel) in Windows 2000 Pro that will let me look
at the server name, info? To make sure the server is functioning properly?

Look at the database information, such as, database name, tables, etc.
without connecting through php?

MySQL SUM()
I am trying to run a sql (select) statement on a MySQL DB, using the sum function...
It keeps returning a value that I know is not correct (in fact it is 1.3356959598149e-315)...

The statment is: Select sum(domain_cost), sum(domain_charge) from table_name;

I know the answer should be about $12,000, but it is clearly not giving me this... Is there a formatting that needs to be included in the statement.


Copyright © 2005-08 www.BigResource.com, All rights reserved