Solved

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

Posted on 2012-03-16
5
256 Views
Last Modified: 2012-03-18
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
0
Comment
Question by:johnecollins
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 21

Expert Comment

by:K V
ID: 37732153
still reading your question but "mysquli"??
shouldn't it be mysqlui ?? is it correct?
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 37732160
In jobheadclass.inc , $cxn is not assigned a value anywhere that I could find.
0
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 37734694
This is pretty self-explanatory:
Call to undefined method mysquli::error()

And on line 134, you probably want this
if(!$res = mysqli_query($this->cxn, $sql))

Open in new window

0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 37734697
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.
0
 

Author Closing Comment

by:johnecollins
ID: 37734972
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
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question