I just want to ask how to convert the data I'm getting from database in Title case, its giving me an error:
Syntax error or access violation: 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
I'm just using UCASE and LEFT, here's my code,
DB::raw('GROUP_CONCAT(DISTINCT " " ,
CONCAT(UCASE(LEFT(ru.firstname, " ", ru.lastname, 1)))) AS relates_to')
The output I want for example is "user name" into "User Name", oh and I'm using the latest MySQL Workbench just to inform you
Hope you can help me and notice me, thank you so much in advance.
The LEFT function only takes two parameters, so this alone would cause your current code to fail. You may try reworking it as follows:
DB::raw("GROUP_CONCAT(DISTINCT ' ' , LEFT(UCASE(CONCAT(ru.firstname, ' ', ru.lastname)), 1)) AS relates_to")
I don't know what your logic is exactly trying to achieve, but the above should at least run without error.
Related
Hello I try do a Update like this
$sql = "UPDATE info SET YES/NO = '$_POST[value]' WHERE ID = '$_POST[id]'";
I am getting this error:
Error updating record: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '/NO = 'YES' WHERE ID = '5'
I think this can be error from use SLASH on my database, If it is the problem how can i solve it?, thanks and i cant find any on google working for it.
Usualy, anything different than alphanumeric and underscore is not recommended.
Indeed, it is not a good practice to name a colomn like you did.
I will recommend you to rename the colomn yes_no otherwise, you will get the same error again, again and again.
I am trying to update my database with php and for that I have written the following query :
$query = " UPDATE users SET username = '$username' , password = '$password' WHERE id = $id ";
and the error is shown as :
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use
near '' at line 1
can you please help..
“syntax to use near ‘something’” shows the first few characters after the last part of the query that MySQL could parse. When ‘something’ is a zero-length string like in this case, it means the query ended before it was complete. That points to $id being an empty string.
You didn’t ask for comments on whether your query has other severe problems that will certainly lead to cybercreeps pwning your web site, so I won’t offer any such comments. :-)
Need your advice about my PHP MySQL syntax. I work hard with that, but still facing problem with the query and the error is:
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 '$bagianWhere = ""' at line 1: $bagianWhere = ""
You can see my demo here
If "bagianWhere" is empty, the SQL query becomes invalid with an orphan "WHERE" at the end. You can do
$bagianWhere = "1 = 1";
at the top to counter for that.
Also get rid of "$bagianWhere .= " and make it "$bagianWhere = "
Also the error you are mentioning here is from SQL Fiddle, as you have put in PHP code in there. Can you run the PHP on your web server and show us the error you get.
Struggling with a simple insert command, i'm getting the error
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 'All In:
The Poker Movie, tells the story of poker focusing on why one of our nat'
at line 2"
Basically passing film information into a table, here is the code -
$query1 = "INSERT INTO Films_Info (Films_ID,FilmName, FilmRelease, Synopsis,Poster,CritScore,AudScore,Director,Studio,IMDB,date_added_db)
VALUES ('',$Film_Name', '$Film_Release','$filmsynopsis','$film_image','$film_critic','$film_audience','$film_director','$film_studio','$film_imdbID','')";
$runquery1 = mysql_query($query1)or die(mysql_error());
Thanks guys
It looks like that you are missing an ' before $Film_Name. Can you add the missing apostrophe?
If you have phpmyadmin enabled on you server, you can paste the code into the SQL-Field to get syntax highlighting on the SQL query.
Since some time ago I have been programming in php with oracle, and I've always liked the function oci_error() because the function can give me the byte position of the error in the query (offset) and then I can make a function to show the error with a flag indicating where is the error in the query.
Well I'm making a similar function but with mysql:
I have the mysql_error() which gives me the "message".
I have the mysql_errno() which gives me the "code".
The "sqltext" I can get it with the function itself.
But, How can I get the offset value of the error in the query?
MySQL errors are usually of the type
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...
Following the "near" keyword is the part of the query where the error occurred. You could search for this string using strpos() in your query and use that as the offset.