This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of Succeeding with AI and have Veljko Krunic on-line!
See this thread for details.
Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger
  • Frits Walraven

Syntaxerror in SQL only recognised in PHP-file, but not by phpMyAdmin

Posts: 27
Netbeans IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,

I'm having a strange issue with some PHP/SQL-code. I couldn't decide on whether I should put it in the PHP or the Database-Forum, so sorry, if I was wrong.

My problem is, that the PHP-code below doesn't create the table and prints this:

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 'USE Test_db; CREATE TABLE IF NOT EXISTS Test_tbl ' at line 2

The database, however, is created properly. The really strange thing about this is, that if I paste the SQL-part in phpMyAdmin, it works perfectly, without throwing any errors. So I have no clue, where the syntax-error is and why phpMyAdmin doesn't recognise it. My only theory is, that I screwed something up in the PHP-part :/

I'm testing this on a XAMPP local server, so I just pasted the PHP-file into htdocs, called "localhost" in Firefox (44.0) and selected the project there. I'm using Mac OS X 10.10.5.

Can anyone help me out?

What are your superhero powers? Go ahead and try them on this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic