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
248 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
5 Comments
 
LVL 21

Expert Comment

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

Expert Comment

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

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 108

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
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 dynamically set the form action using jQuery.

708 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now