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
251 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 83

Expert Comment

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

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 109

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

830 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