Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
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
Medium Priority
?
266 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 84

Expert Comment

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

Accepted Solution

by:
Ray Paseur earned 2000 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 111

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

670 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