473,396 Members | 2,102 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

PHP4 and this function

Jon
function query($query, $return = false)
{
$fetch = mysql_query($query, $this->connection) or
die2(mysql_error($this->connection));
if($return)
return $fetch;
}

mysql_error(): supplied argument is not a valid MySQL-Link resource

the line that begins with $fetch is my problem. This was originally a
PHP5 script that I am retrofitting.
The $query is used all over, and it is really gumming things up.
Thanks!
jon

Jan 23 '06 #1
4 1478
I think it the -> problem. php5 class is different with php4 class

Jon wrote:
function query($query, $return = false)
{
$fetch = mysql_query($query, $this->connection) or
die2(mysql_error($this->connection));
if($return)
return $fetch;
}

mysql_error(): supplied argument is not a valid MySQL-Link resource

the line that begins with $fetch is my problem. This was originally a
PHP5 script that I am retrofitting.
The $query is used all over, and it is really gumming things up.
Thanks!
jon

Jan 23 '06 #2

"ming" <my*****@gmail.com> wrote in message
news:vE****************@nnrp.ca.mci.com!nnrp1.uune t.ca...
I think it the -> problem. php5 class is different with php4 class
No, this works in both PHP 4 and 5 as I use it all the time.
Jon wrote:
function query($query, $return = false)
{
$fetch = mysql_query($query, $this->connection) or
die2(mysql_error($this->connection));
if($return)
return $fetch;
}

mysql_error(): supplied argument is not a valid MySQL-Link resource

the line that begins with $fetch is my problem. This was originally a
PHP5 script that I am retrofitting.
The $query is used all over, and it is really gumming things up.
Ths function can only be used in an object as $this->connection refers to a
property called $connection within the current object. Have you checked to
see if $this->connection actually refers to a valid resource? Where did the
previous call to mysql_connect() store its result?

--
Tony Marston
http://www.tonymarston.net
Thanks!
jon

Jan 23 '06 #3
Jon
On 2006-01-22 21:50:34 -0600, "Tony Marston" <to**@NOSPAM.demon.co.uk> said:

"ming" <my*****@gmail.com> wrote in message
news:vE****************@nnrp.ca.mci.com!nnrp1.uune t.ca...
I think it the -> problem. php5 class is different with php4 class


No, this works in both PHP 4 and 5 as I use it all the time.
Jon wrote:
function query($query, $return = false)
{
$fetch = mysql_query($query, $this->connection) or
die2(mysql_error($this->connection));
if($return)
return $fetch;
}

mysql_error(): supplied argument is not a valid MySQL-Link resource

the line that begins with $fetch is my problem. This was originally a
PHP5 script that I am retrofitting.
The $query is used all over, and it is really gumming things up.


Ths function can only be used in an object as $this->connection refers
to a property called $connection within the current object. Have you
checked to see if $this->connection actually refers to a valid
resource? Where did the previous call to mysql_connect() store its
result?

function constructor($host, $user, $pass, $database)
{

$this->connection = mysql_connect($host, $user, $pass) or die2

This was modified from a more PHP5 compatible __constructor, and
function cnstructor allowed it to "work" apparently, but not as well as
I need it to.

jon

Jan 23 '06 #4
NC
Jon wrote:
"Tony Marston" <to**@NOSPAM.demon.co.uk> said:
Ths function can only be used in an object as $this->connection refers
to a property called $connection within the current object. Have you
checked to see if $this->connection actually refers to a valid
resource? Where did the previous call to mysql_connect() store its
result?


function constructor($host, $user, $pass, $database)
{

$this->connection = mysql_connect($host, $user, $pass) or die2

This was modified from a more PHP5 compatible __constructor, and
function cnstructor allowed it to "work" apparently, but not as well as
I need it to.


In PHP 4, the consturctor has the same name as the class. So your
constructor() function is probably never executed.

Cheers,
NC

Jan 23 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Chung Leong | last post by:
Help me here. I've become a bitconfused about how PHP4 deals with objects after reading this description of PHP5: "PHP's handling of objects has been completely rewritten, allowing for better...
5
by: Jan Pieter Kunst | last post by:
(apologies if this message is a duplicate -- my news server seems to have problems) Greetings, When using PHP 4, this: // ex. 1 class A { function A(&$obj) {
2
by: Terry Richards | last post by:
i am getting lots of errors such as:"...differs in signedness" what is it from? /Users/terryrichards/tmp/php-4.3.11/ext/zlib/zlib.c: In function 'zif_gzcompress':...
4
by: Kevin | last post by:
Hi all, I've got a PHP4 app that I developed which I'm trying to get to run on a PHP5 server. Everything works great, except for one thing. There's a particular routine that creates an...
2
by: Stefan Huber | last post by:
Hi I've got a really strange problem, and can't find out why it's not working as intended. in order to use php4 and 5 together on a webserver and the requirement for running as different...
1
by: Snef | last post by:
Hi, It should be possible (as far as I know) to use createimagefromjpg('<urltoimage>'); In PHP4.3.11 it worked just fine, but now I use PHP4.4 and it is not working anymore! I only can do:...
7
by: Mathieu Maes | last post by:
Hi there I'm quite experienced in programming in PHP4, but I would like to make a step to PHP5. I created following class which works perfectly in PHP4 : Class Nessi { // ident part
9
by: java | last post by:
Hey there, I just removed an elderly PHP4-Installation from my Windows-Box and installed PHP 5.2.1. I used the PHP4-Module as local batchfile- interpreter by E:\ersDHCP>php ./extractLog.php ...
1
by: jana123 | last post by:
Im running php4, so i know that the imagefilter function wont work.. but I'm needing to smooth out some text in an image i created fully with PHP GD.. (and im using ttf fonts) I was wondering if:...
8
by: FFMG | last post by:
Hi, I am slowly moving my code to php5. But I would like to make it backward compatible in case something bad happens, (and to make sure I understand what the changes are). The way the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.