Jump to content

Fatal error: Uncaught mysqli_sql_exception:


phpsane

Recommended Posts

I'll probably regret saying this, but I'd love to see some code of yours that queries a db without using SQL.  You could win a prize with it!

 

Well, to be fair, there are frameworks that allow a developer to work with a database through classes without directly using SQL. The actual queries are done with derived SQL in the class, but the developer does not need to "know" or write SQL at all. But, yeah, I didn't understand his statement about running queries in "sql lang" and "php lang" because, from his code, he is not using a 3rd party class/framework and is creating normal SQL queries. Although, I will give him credit for using stored procedures. Personally, I don't typically use classes/frameworks to do the actual queries because I find them limiting. I can do so much more writing my own SQL.

 

 

Ooops! I already deleted all the entries.

Thanks for that line of sql query, though!

 

So rather than take a moment to think about the problem and determine the appropriate solution (delete only the duplicates) you made a knee jerk decision to delete all the data.

Link to comment
Share on other sites

Queries are done using the SQL language.  Period.  Yes - there are some subtle differences between various database implementations of SQL but basically they are all the same.

 

PHP does not talk to databases.  The selected database interface (MySqlI or PDO) does the talking for PHP by submitting an SQL statement.  PHP uses functions to reach the db and those functions are issuing sql commands, not php code.  You need to understand this.

 

And we don't all write code from the tops of our heads.  Those of us that are unfamiliar with certain aspects of coding RELY ON THE MANUAL to refresh our memories or to clarify certain uses of various parts of the PHP language.  Those that write code full-time probably, over time, do have the entire syllabus memorized.  Those that don't do it full time (like this retired guy) have managed to memorize the parts that are used the most but then have to quickly leaf thru the manual for the proper syntax of those functions that don't come up that often.   A newbie like you will need to keep the manual close by but gradually can rely on it less as you (hopefully) pick up the necessary language skills required in whatever project you are working on.

 

I'll probably regret saying this, but I'd love to see some code of yours that queries a db without using SQL.  You could win a prize with it!

 

Yes, but when you talk about php functions then that is php code. Right ? When I say php code, I don't mean just the lines of codes we programmers write that make-up our php scripts. I meant the functions and stuffs too of php. They are parts of php. Yes, you will regret saying this because now you are gonna lose the bet.

 

(Psssst! This is your Guardian Angel here! I've frozen PhpSane for 1 min to give you this messg. Just tell PhpSane that you did not understand his personal terminology and so the bet is invalid. Then get Psycho to give him a lecture to use the right or BETTER learn the right php terminology and not make-up his own!).

(Sedo, your Guardian Angel is telling me to tell you not to bother giving any lecture to use the right terminology. Psycho's already done that and he'd be a real one (Psycho that is) to waste time giving it again. Anyay, 1 min is nearly over, PhpSane will be out of his frozen state any second. He'll carry-on in any sec not aware he was frozen).

 

I just added an entry (INSERT) via php myadmin and it is showing sql query like this:

 

INSERT INTO `users` (`ids`, `names`, `emails`);

 

So, you will write the sql query like that in your mysql terminal.

I, however, would write the php code like the following. It is familar to any php developer. Therefore, why bother learning the native sql language, which I showed above ?

I know that, this "php code" converted to the native sql lang. Do not worry, I know these basic common sense things.

I was gonna build a .exe tool myself where you type basic english commands that get converted to the native sql lang. But then I found .exe tools online that were similar (like php myadmin) and so I did not bother. I might build one though here basic english commands get converted to php code like you a in the above example. Build a gui tool here you click buttons and it yields php code to qury the mysql db.

<?php
 
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "db_name";
 
$conn = new mysqli($servername,$username,$password,$dbname);
 
if($conn->connect_error)
{
    die($conn->connect_error);
}
 
$sql = "INSERT INTO user(id,name,email) VALUES('1','name','email@email.com')";
 
if($conn->query($sql)===TRUE){
   echo "inserted data!";
    }else{ 
        echo "failed!";
}
        
$conn->close();
 
?>
Edited by phpsane
Link to comment
Share on other sites

There were typos on my post 29 on the final paragraph. Should have read like this:

 

"I was gonna build a .exe tool myself where you type basic english commands that get converted to the native sql lang. But then I found .exe tools online that were similar (like php myadmin) and so I did not bother. I might build one though where basic english commands get converted to php code like you see in the below example. Build a gui tool where you click buttons and it yields php code to query the mysql db."

 

Anyway, I use a gui tool to build .exe bots. Not sold any yet. That is all I know about programming.

Now learning php, I am going to build web versions of these bots or browser automation tools. :)

Edited by phpsane
Link to comment
Share on other sites

Well, to be fair, there are frameworks that allow a developer to work with a database through classes without directly using SQL. The actual queries are done with derived SQL in the class, but the developer does not need to "know" or write SQL at all. But, yeah, I didn't understand his statement about running queries in "sql lang" and "php lang" because, from his code, he is not using a 3rd party class/framework and is creating normal SQL queries. Although, I will give him credit for using stored procedures. Personally, I don't typically use classes/frameworks to do the actual queries because I find them limiting. I can do so much more writing my own SQL.

 

 

 

So rather than take a moment to think about the problem and determine the appropriate solution (delete only the duplicates) you made a knee jerk decision to delete all the data.

 

Planning on building a .exe tool where you type basic lang like english and it gets converted to php code. If it gets popular then will hassle the official php guys to use my on invented syntax (english like lang) and ditch php's current complicated syntaxes. You guys would then have to learn my syntax. Only joking! But that would be not such a bad dream. Now would it ?

Planning to one day get hold of a programmer ho knows Assembly language and then get him to build my on interpreter that uses my on english like lang that I mentioned above.

Get a compiler built too based on my on english like lang. Highest level lang compiler & interpreter. That is my dream.

Edited by phpsane
Link to comment
Share on other sites

 


$sql = "INSERT INTO user(id,name,email) VALUES('1','name','email@email.com')";

 

What part of your twisted philosophy on learning to program cannot see the SQL language in the above statement from your very own code?

 

I have no idea why are you being so difficult, so childish, so distracted and so out and out silly.  What?  Are you only 14 years old?  

 

Those of us here on the forum take this stuff very seriously and are trying to help other serious people get over the learning hurdles that come with their efforts.  Helping you out is becoming a futile exercise and shortly I think that everyone is going to get tired of your behavior on this forum.  

 

I quit once again.  And I'm not going to even read your posts any more.  There is something wrong with you.

Link to comment
Share on other sites

What part of your twisted philosophy on learning to program cannot see the SQL language in the above statement from your very own code?

 

I have no idea why are you being so difficult, so childish, so distracted and so out and out silly.  What?  Are you only 14 years old?  

 

Those of us here on the forum take this stuff very seriously and are trying to help other serious people get over the learning hurdles that come with their efforts.  Helping you out is becoming a futile exercise and shortly I think that everyone is going to get tired of your behavior on this forum.  

 

I quit once again.  And I'm not going to even read your posts any more.  There is something wrong with you.

 

Ok, I gave you a bad example. But on other sql queries the native sql lang seems more complicated than the php version.

Link to comment
Share on other sites

Well, to be fair, there are frameworks that allow a developer to work with a database through classes without directly using SQL. The actual queries are done with derived SQL in the class, but the developer does not need to "know" or write SQL at all. But, yeah, I didn't understand his statement about running queries in "sql lang" and "php lang" because, from his code, he is not using a 3rd party class/framework and is creating normal SQL queries. Although, I will give him credit for using stored procedures. Personally, I don't typically use classes/frameworks to do the actual queries because I find them limiting. I can do so much more writing my own SQL.

 

 

 

So rather than take a moment to think about the problem and determine the appropriate solution (delete only the duplicates) you made a knee jerk decision to delete all the data.

 

I deleted them after reading Sepodati's advice that came before your post. Only read your post after the deletion. It had only about 7 test entries.

Link to comment
Share on other sites

IT IS THE SAME LANGUAGE IN ALL PLACES.  PHPADMIN.  PHP.   SQL IS SQL!!!!!!!!

 

SLOW DOWN AND LEARN WILL YOU!

 

You take it easy too Grand Pops!

Was reading this. You read it too. Interesting for you pros:

http://erlycoder.com/69/php-mysql-prepared-sql-statement-vs-sql-statement

Googled:

https://www.google.com/search?q=php+to+query+mysql+and+native+sql+comparison&ei=HaW5WeeGBYWGvQSWiq_wDw&start=20&sa=N&biw=1093&bih=510&dpr=1.25

Hardly any good results.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.