I have a query where its returning, something like:
SELECT `students`.id,
CONCAT(
COALESCE(`students`.student_name,"")," ",
COALESCE(`students`.student_middle_names,"")," ",
COALESCE(`students`.student_surname,"")) AS student_full_name,
And getting a bunch of errors like:
Unable to resolve column ''
How can I fix this (I dont want to disable SQL Inspection - I just want it to not give these false errors because I am returning an empty string instead of a column).
Using PhpStorm 2021.2.4
Related
Good afternoon -
I am working Visual Studio 2013, attempting to build one (1) parameter which has different values assigned to each option. I have created a data attribute which contains the following values:
Active
Error 1
Error 2
I have specified the value in an expression for each option:
All = "Active", "Error 1", "Error 2"
Active = "Active"
Errors Only = "Error 1", "Error 2"
The only option that works is the Active option. The others return no records.
How should I define the expression?
Any and All assistance is very much appreciated!
here is what you can do, you need to handle the query condition formatting and parameter values correctly. e.g. see below example.
Dataset Query for Stored Procedure:
*declare #renderType nvarchar(max)
declare #script nvarchar(max)
--set #renderType = 'txt,dump'
SELECT #renderType = REPLACE(#renderType , ',', ''',''')
set #script = 'select render_format, subscriber_id from Sub_fact where render_format in (''' +#renderType+ ''')'
exec (#script);*
create stored procedure to do all this formatting correctly.
now in parameter properties this is what i have provided
this works perfectly for me.
change your solution accordingly and it should work. respond with how it goes.
mysql php admin table query enter image description here
I don't see why it says partID is giving me a problem? it is in the table and i think i have them linked correctly. I Have changed a few things i replaced comma with the and statement which cleared up alot of my errors. But since I've done that it continues to give me #1305 - FUNCTION homeshopping.partID does not exist. I have even looked at the structures an designer to make sure column names an tables are correct.
Don't forget to post your query as text also.
Because it's missing the keywork IN to have a query like this:
SELECT CONCAT(hscust.first,' ', hscust.last AS Customer,hsitems.description,hsitems.price,hsitems.itemCalss
FROM hscust,hsorders,hslineitem,hsitems
WHERE hslineitems.orderId = hsorders.orderId AND hsitems.partID = hslineitem.partNum AND hslineitem.price = hsitems.price AND partID IN ('CB03', 'CZ82');
I have this websql script (http://pastebin.com/gvJseBAn) which doesn't perform correctly.
If I run the statement select * from news where id=0772348890 , I get the error The conversion of the varchar value ' 0017707787068' overflowed an int column.
If I run the statement select * from news where id='0772348890' , I get the error Incorrect syntax near '0772348890'.
If I run the statement select * from news where id="0772348890" , I get Invalid column name '0772348890'
Any other variation of '#0772348890#' or #0772348890# or "#0772348890#" I have tried gives the error "incorrect column" or "incorrect syntax near ..."
Any ideas on how to fix this error, or a better method of creating a simple websql query form?
A) the issue here is that db column will not under any conditions accept "0772348890" as a valid input because it is mismatched. The column is an "int" type (according to your first error), but your value has a padded 0 prependedto the front as in 0 772...
What is the purpose of this zero? Ordinarily prepended zeros appear in fixed length character fields where a space is not allowed. Should the value not be "772348890"?
B) Remember that ColdFusion will escape your single quotes in your query. In your second error example (where you use single quotes), this code:
<cfquery name="runsql" datasource="#Form.datasource#" timeout="30">
#Form.sql#
</cfquery>
Produces this SQL statement:
select * from news where id=''0772348890''
Which would give you your syntax error. If you wish to successfully test your second example you will need to alter your code to:
<cfquery name="runsql" datasource="#Form.datasource#" timeout="30">
#preservesinglequotes(Form.sql)#
</cfquery>
Preservesinglequotes() gets you past the second error issue and MSSQL's implicit conversion may strip off the prepended zero and allow the query to succeed - though I'm not sure will give you what you want.
C) Finally you should probably never do what you are trying to do - at least not in this fashion (sorry to be so direct!). Your opening up your DB to arbitrary queries from a web form. The resulting damage from even casual mistakes could be catastrophic to your data, let alone a malicious user bent on stealing or altering or using your site for malicious purposes. That's my take. :)
Good day, I'm having a problem updating records in MySQL. The following code is in VB.Net. Whenever I execute the code I get no errors, but the information is not saved in the table. Please tell me what I am doing wrong.
SQLstr = "UPDATE mainfinancials SET charge1=?charge1, charge2=?charge2, charge3=?charge3, charge4=?charge4, charge5=?charge5" _
& " WHERE acct='?acct';"
Pcomm.CommandText = SQLstr
If IsNumeric(txtCharge1.Text) Then Pcomm.Parameters.AddWithValue("?charge1", CDbl(txtCharge1.Text))
If IsNumeric(txtCharge2.Text) Then Pcomm.Parameters.AddWithValue("?charge2", CDbl(txtCharge2.Text))
If IsNumeric(txtCharge3.Text) Then Pcomm.Parameters.AddWithValue("?charge3", CDbl(txtCharge3.Text))
If IsNumeric(txtCharge4.Text) Then Pcomm.Parameters.AddWithValue("?charge4", CDbl(txtCharge4.Text))
If IsNumeric(txtCharge5.Text) Then Pcomm.Parameters.AddWithValue("?charge5", CDbl(txtCharge5.Text))
Pcomm.Parameters.AddWithValue("?acct", txtAcct.Text)
MsgBox(SQLstr)
Try
PConn.Open()
Pcomm.ExecuteNonQuery()
PConn.Close()
PConn.Dispose()
Catch ex As MySqlException
MsgBox(ex.Message.ToString())
PConn.Close()
End Try
I have deliberately place error in the the code and it would return an error message.
can some one help me with this.
Thanks
Do not enclose a parameter placeholder with single quotes
" WHERE acct=?acct;"
Enclosing the parameter placeholder in single quotes trasform its name in a literal value. So you query is searching a record where the acct column contains the literal value '?acct'.
Of course it finds nothing and nothing is updated
By the way, once a parameter placeholder is present in the query string, you should supply a parameter for it. If you forget to add the parameter an error occurs when you execute the command stating that an expected parameter is missing.
You place a test for IsNumeric and only if it succeds you add the parameter. I think you should test this error condition before and abort the update if something is not correct in your charge parameters.
We recently made some changes to our site to prepare it for pre-production:
Moved to a load-balanced architecture
Now use memcache/memcached to maintain session data
Enabled APC
Now, everything was working until we made some change that we cannot recall that has caused the database to not load schema properly. Here is an output of some debug:
Warning (512): SQL Error: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 [CORE/cake/libs/model/datasources/dbo_source.php, line 684]
Query: SHOW FULL COLUMNS FROM
Warning (2): Invalid argument supplied for foreach() [APP/models/datasources/dbo/dbo_mysql.php, line 127]
Warning (2): array_keys() expects parameter 1 to be array, boolean given [CORE/cake/libs/model/datasources/dbo_source.php, line 1968]
Notice (8): Trying to get property of non-object [CORE/cake/libs/model/datasources/dbo_source.php, line 812]
Query: SHOW FULL COLUMNS FROM
Query: SHOW FULL COLUMNS FROM
Query: SHOW FULL COLUMNS FROM
Query: SHOW FULL COLUMNS FROM
Query: SHOW FULL COLUMNS FROM
Query: SHOW FULL COLUMNS FROM
As you can see, it is not loading the table names.
The other problem we noticed, is that when the query is generated, it is generated like this:
SELECT Project.id FROM AS Project WHERE 1=1
Notice that there is no table name, it simply tries to create the alias on a blank table name.
Any thoughts?
We recently made some changes to our site to prepare it for pre-production:
Thankfully you version-control your code changes and can simply roll back until you find a working version and compare to find the breaking change. With git this is easily done using git bisect.
No? Well..
Debug and identify the cause
As with any error - step one should be to look at where the error is coming from:
// cake/models/datasources/dbo/dbo_mysql.php
$cols = $this->query('SHOW FULL COLUMNS FROM ' . $this->fullTableName($model));
foreach ($cols as $column) { // #127
What should be clear here, is that Cake is unable to determine the full table name for your model.
You're trying to query a model with no table
Looking at the source for fullTableName:
// cake/libs/model/datasources/dbo_source.php
function fullTableName($model, $quote = true) {
if (is_object($model)) {
$table = $model->tablePrefix . $model->table;
} elseif (isset($this->config['prefix'])) {
$table = $this->config['prefix'] . strval($model);
} else {
$table = strval($model);
}
if ($quote) {
return $this->name($table);
}
return $table;
}
It should be clear that the model has no table according to cake.
Common causes:
The model property useTable is set to false
No describe permissions
Given the info in the question - it's most likely the first is the reason.