Link to home
Start Free TrialLog in
Avatar of johnecollins
johnecollinsFlag for United Kingdom of Great Britain and Northern Ireland

asked on

MySql update works fine when I apply the text to MySql Command but not as part of my program

jobheadclass.php
I pass an array of field values, to a function that creates a MySql update statement and reading the error it seems to doubt that my mysquli resources are correct.

I have included a copy of jobheadclass.php in here is the constructor for objects of jobhead class.

Three other functions are included as well, one = initialisejob works well, getmessage is trivial and the last of these is update newjobhead.

This function receives an array of data and is designed to update an existing record in the table. However there is a screen print with the following warning

Warning: mysquli_query() expects parameter 1 to be mysqli, null given in C:\wamp\bin\apache2.2.21\htdocs\SAMS\include\jobheadclass.inc on line 134

Plus the following error

Fatal error: Call to undefined method mysquli::error() in C:\wamp\bin\apache2.2.21\htdocs\SAMS\include\jobheadclass.inc on line 137

see file two messages.doc

and

jobheadclass.php

I would be grateful if anybody can help

Thanks very much

John
two-messages.doc
Avatar of theGhost_k8
theGhost_k8
Flag of India image

still reading your question but "mysquli"??
shouldn't it be mysqlui ?? is it correct?
In jobheadclass.inc , $cxn is not assigned a value anywhere that I could find.
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Just a sidebar note... I found some other instances of $cxn and $this->cxn in other parts of the script.  You might want to make a coding practice that avoids naming class properties and local variables with the same kinds of names.  It's just too easy to confuse the meaning of the variables when the names are so similar.
Avatar of johnecollins

ASKER

Hi Ray,

Thanks for looking in, you were of course right I entered your amendment and it worked.

I am struggling with many things relative to my development, things like returns from SQL statements, and being sure I have chosen the correct mysqli command or that I got the desired result, is there somewhere that I can consult and interpret the values returned.

Plus how I can setup connections correctly.

Thanks Ray

John