Using a .sql file in Database manipulation with PHP - php

I am kinda new to the whole development side, but I want to be good.
In database creation, I used to do this via PHPMyAdmin --> Wamp Server.
I got to learn how to use MySQL Workbench, and I am liking the experience.
The problem is, when I have the .sql file created via use of Work Bench, e.g. data.sql, I cannot import it to PHPMyAdmin, so as to continue in a my developments (web-related) as there are many errors comming up e.g. #1146.
It is really frustrating since I have to do double work and create what I did in Work Bench in PHP MyAdmin.
Is there a simpler way?
Like can I just connect to a .sql file (as the database) and continue with execution of my projects? (Its a bit stupid, but I have been reduced to that.)
Please help.
Thanks in advance.

This post seems like it might help you out, did you check the default encoding of the dump and make sure mysql expects the right type of encoding?
http://forums.mysql.com/read.php?103,275798,275798
Also: Please read the policies of the board before asking your question. It states to do some research before asking questions like this... I googled "mysql workbench dump to phpmyadmin" and the very first item that popped up was a video explaining this EXACT situation. :)

Related

Need some pointers on adapting a php/mysql pagination script for use with odbc .mdb access database

Im working on a little web based application using php/html and an odbc database. Im trying to figure out how to implement pagination into the application im making, but the only examples I could find were made with mysql and not odbc. I've tried for hours to adapt them, but have come up empty handed so far.
I've replaced every instance of mysql from the script with odbc and dreamweaver is picking them up as valid functions (color highlighting) but the script is producing nothing.
The script I was working off of is located here:
http://www.developphp.com/view_lesson.php?v=289
I appreciate any help, even if its just a link... Been kicking myself in the head over this for too long.
You might find this tutorial useful.
http://www.shotdev.com/php/php-access/php-access-odbc-and-paging-pagination/

php mysql: Duplicate entry on production but not on dev

Oke, i've been busting my head on this one.
I'm gonna try and keep things short, however, if you need more info, don't hesitate to ask.
I've written an import repo for an external firm, so we can import their data into our service.
quick overview of implemented logic?
ftp, grab xml file, parse it with simple_xml and do db stuff using laravel eloquent component.
on my dev machine,
every run gets parsed fully and all data is inserted correctly into the database.
problem
when i try the same thing on my production server.
I'm receiving a duplicate entry error, always on the same exact record. (unless i'm using another file)
pre script setup to help detect the error
on each run i do the following:
make sure i'm using the exact same files on both dev and prod
environment... (i've disabled the ftpgrab and uploaded manually to
the correct location)
truncate all the related tables so i'm always
starting with empty! tables.
i've manually triple-zillion checked for duplicates in the xml, but they're not in there.... and the fact that
my dev machine parses the file correctly confirms this.
what i tried
at this point, i've got no more clues as to how i'm supposed to debug this properly.
by now, i've checked so many things (most of them i can't even remember), all of which seemed pretty unrelated to me, but i had to try them.
those things include:
automatic disconnects due to browser
mysql wait timeouts
php script timeouts
memory settings
none of them seem to help (which was exactly what i was expecting)
another fact
my php version on my dev is 5.4.4 and the version on the production server is 5.3.2 (i know this is bad practise, but i'm not using any new features, it's really dead easy code, though it has quite a few lines :-) )
i've been suspecting this to be the cause, but
i've now switched to 5.3.14 on my dev... still the import runs without an issue
the changes from 5.3.2 to 5.3.14 are probably pretty minor
i've tried to manually compile the exact same php version, but i'm to inexperienced to properly do this. moreover, it probably wouldn't have the exact same specs anyway (i think it's pretty impossibly to ./configure exactly the same, considering the use of MacOs vs Ubuntu? especially for a noob like me)
So i've abandoned this path.
I've tried to find the differences in the php versions, but i can't seem to stumble upon anything that might be the cause to all this.
there was a change related to non-numeric keys in arrays (or strings for that matter) in version 5.4.4 (i think) but since i've now come to the conclusion that 5.3.14 also works, this definitely is not the issue. --- looking around insecurely hoping not having said anything downright stupid ---
quick thought while writing this:
the thing is, even though i'm getting the duplicate error statement.
The record did get inserted into the database.
moreover, the error gets triggered when having processed about 2700 (of total 6000) records.
the bound data to the query is actually the data of the second record in the xml file.)
I'm sincerely hoping anyone could put me on the right track for this issue :(
If you made it this far, but don't have a clue about what's going on, thx for reading and sticking to it.
If you might have clue, please enlighten me!

Why does my MySQL database tables only exist on my Workbench?

I am developing my first php-MySQL system, but have a minimum of database experience. I have successfully created a schema with aproximately 10 tables, and the testings have so far worked fine.
My problems started when i created a dump of the database, as copy for my laptop, so I could continue to test new web pages and new queries even when I am not at home, and still use a localhosted database.
I have successfully imported the dump, and created the schema in my workbench, and it is visible from the command-line prompt "show databases".
However, both my web application, and the command-line prompts are unable to locate the underlying tables. THe problem is at least not directly in my php-code, as it works perfectly on another computer, with another, but assumably identical localhosted database. I have researched the matter online for what feels like a decade, but without any relevant results.
Command-line prompts are able to find tables from every other schema, like the sakila examples. I have tried to compare the two's settings, but they all seem to be identical, for instance they are both InnoDB.
I realise that I am not giving enough information for a direct solution here, but I would greatly appreciate if anyone could hguide me to finding the right questions to ask, so I can solve this matter, and get on with my php-learning.
(SOLVED)
I discovered that the list of open tables had references to an additional Schema. I thereafter realised that I had installed the XAMPP bundle server before I installed MySQL Workbench. In other words, i already had an existing database, with all of the regular examples included in another instance, which were running on port 3306. It also happpened to have an identical, but empty scheme, of the name that I tried to access.
My newly added SQL installation was ported to 3307, and so I am now able to access it. THis issue was just one of several issues I have been able to work around, but they have all been caused by the same mistake. Thanks everyone for trying to help.

XML with PHP instead of MySQL for first time

I've always used MySQL with PHP and on my site I added a chat system that uses MySQL which as you would know is VERY database heavy so I think I'm going to switch it over to XML files for each user just for the chat system to take all the load off of the DB.
I have never used XML with PHP before so I was looking for information, and found that the queries are pretty similar to MySQL.
Here are my questions:
Is it the client writing to the file or the server writing to the file?
Do I have to chmod them as 777?
Do I also have to chmod the XML file as 777?
If I do have to set the permissions to 777, does that drastically decrease security and is there any way to tighten that up?
Does anyone have any tutorials they would recommend me to as well? Most of the stuff I found is from 2003 - 2005. Don't know how much has changed in it.
Hope it's cool I ask this question here.
Thanks a bunch
-Sal
First off, it seems like a very bad idea to do something that is very database intensive in xml, it is going to be a lot more intensive that way.
To answer your question; It is always the server writing to the server filesystem. you only need to provide write access to the user running apache (and consequently php).
I suggest you stick with mysql for chat but look into DOMDocument to learn more about xml

SQL Compact database with PHP

I have been given 2 files .DB and .sdf to work with. I have googled it a little and found out that its SQL Compact database format. I really have no idea how to work with these database files.
I have found here on stackoverflow some 3rd party tools, bud they were all for windows (I am on Mac).
I have also tried to open it in SQLite but no success.
I need this data in my web app written in PHP. So conversion to MySQL or Postrge seems to be an ideal solution. Any ideas?
You can use MSSQL extension in PHP to work with these databases

Categories