-
Loading a MySQL Dump File via PHP NOT the mysql command line
Date: 11/18/05
(PHP Community) Keywords: php, mysql, sql
I've searched and searched and haven't found anything, so any help or direction would be greatly appreciated.
I have mysql dump files, that are very large, some close to 100 megs (ok large in my opinion), the contain the MySQL statements to dump the table if exists, create, then load the data. I had a daily routine where I would use the mysql command line to load them, but a server issue happened that caused the mysql command to not load due to a segment error (libs were upgraded that shouldn't have been - long story) however the mysql "service" works, and PHP connects to it just fine. What I would like to do is use a PHP script to load these dump files. I tried some script examples on php.net, but they failed, and I wanted to know if anyone else had done this successfuly? And how?
Thanks!
Source: http://www.livejournal.com/community/php/369639.html
-
Any PHP Gurus wanna answer a question for me?
Date: 11/26/05
(Computer Geeks) Keywords: php, programming, mysql, browser, html, database, asp, sql
I've done plenty of ASP.NET programming but this is my first foray into the wonderful land of PHP and I've got a question about how often you hit the database in a normal page load... basically I have tags like:
within the front end page and listing.php goes something like
$database = mysql_connect("localhost", "your_database_user_id", "your_database_password");
mysql_select_db("your_database_name", $database);
switch($type){
case 'thumbnail':
header("Content-type: image/jpeg"); // act as a jpg file to browser
$query = "SELECT thumbnail
FROM your_table
WHERE id = $id";
$result = mysql_query($query, $database);
$row = mysql_fetch_array($result);
$jpg = $row["thumbnail"];
echo $jpg;
break;
case 'address':
header("Content-type: text/html"); // act as an html file to browser
$query = "SELECT address
FROM your_table
WHERE id = $id";
$result = mysql_query($query, $database);
$row = mysql_fetch_array($result);
$address = $row["address"];
echo $address;
break;
}
Now if I understand this correctly, anytime the parser hits a tag (or w/e) it will connect to and select from the database. So on a page with 5 tags that pull from listings.php, the scripts will connect to, select from and disconnect from the database 5 times right? Is this is proper way to do things? It kinda makes me uncomfortable to make so many database hits but this seems to be the average way php developers do it.
Source: http://www.livejournal.com/community/computergeeks/824527.html
-
Undesireable sticky form
Date: 11/25/05
(PHP Community) Keywords: php, mysql, sql
This is a first for me and I wonder if anyone else has ran into this problem. The code is really long and consists of several files so I'm not going to list it all. But I'll explain what it does and see if anyone has ever had this problem:
The "main" page runs a MySQL query. If they've never filled out the form, their data is not in MySQL, therefore the $_SESSION variable will not be set. The code that does this is near the top of the script (after including required files, etc.).
When the form is filled out and submitted, it calls the same page and also includes another file that processes the form.
Now with the information submitted and entered into MySQL, it runs back through the "main" page. The code that sets that $_SESSION variable runs a query looking for their entry and then sets the $_SESSION variable to true:
if ($characters) {
$_SESSION['characters'] = $characters;
$_SESSION['character_initialized'] = 1;
}
I've tested it with "echo debugs" and it is indeed within the if statement.
The only way the form is supposed to be shown is if $_SESSION['character_initialized'] is not set. The following calls the form:
if (!isset($_SESSION['character_initialized'])) {
include_once ($root_dir . 'content/create_character.php');
}
What happens is when the form is submitted, the form comes right back up! But any other click to a link then presents the page the way it's supposed to be. If you try to fill out the form again, it's just going to give back a message that you've already filled out the form.
So, am I missing something? I might want to add that the $_SESSION variables are within a function. Am I maybe having a variable scope issue? But then, if I am, I would think that the $_SESSION variable would NEVER get set and the second click on the page would just give me back the form again.
I have never had this problem before and have tried this script literally 30 different ways to find the problem.
Source: http://www.livejournal.com/community/php/370941.html
-
Help :/
Date: 11/29/05
(PHP Community) Keywords: php, sql
I've been working on a random sql row script, but I am sort of stumped at the last part...
Since I am not familiar with php, I have been trying to learn by reading up on the functions, and looking at the code for different scripts that sort of do what I want, and seeing if I can merge them together to fully do what I want (I apologise if this is a bad thing, but it helps me learn ... u_u)
Anyway, the script is pretty much a "random cast"... Similar to how the Livejournal Quizzes are (only this will be used with vBulletin). Type in how many fields you want, type in the name of the characters/whoever, select their gender, and it results in randomly selecting a person from the appropriate table. I have the first two, but I haven't attempted to do the gender specification yet -- however, the last one is what gives me trouble. It will display a random entry, but it will be the same entry for all the fields, like this:
Boogeyman is played by: Name#1
Scarecrow is played by: Name#1
Dorothy is played by: Name#1
I found a way to display three different entries, however, it will display the three different entries beside just one name/custom field like this (as an example):
Boogeyman is played by: Name#1Name#2Name#3
Scarecrow is played by:
Dorothy is played by:
I apologise if this seems vague, but since I am not very knowledgable I'd feel stupid trying to explain myself like I'm an expert D: I have been trying to figure this out on my own for a few days and seem to keep hitting the same dead ends. Does anyone have any ideas?
I appreciate any help. Thank you in advance. :)
Source: http://www.livejournal.com/community/php/371094.html
-
Windows XP Programming and Gaming Users
Date: 11/29/05
(Asp Dot Net) Keywords: programming, sql, web
Ok this is a weird question that may not be appropriate here but here's my situation: I'll be getting a new computer for Xmas that will be a powerful machine that will be used for 2 primary functions: Programming and Gaming. Thing is that basically I do alot of web programming so I'm going to have VS 2003 and 2005, SQL Server (possibly 2000 AND 2005), and IIS. As you know gaming requires alot of system resources and memory and I don't want to have to go to task manager everytime I boot up to play a game to close off all the programming and server programs. So what I'm wondering is whether or not I should:
A: Set up 2 user accounts on my computer (this is an XP Pro machine) with one for programming and one for gaming that has a modified startup script to disable everything (which i have no experience in writing BTW). I also don't know if this would even free up all the memory that I'd want.
B: Install 2 instances of XP Pro and use a dual boot configuration with one config with all the server and programming tools and one without. HD space isnt' really an issue since I will have a 250 gig hard drive (and likely will be adding more at a later date.) However I'm not very experienced with this sort of setup. I do plan on installing Windows XP 64-bit as well, so I'd have to do the 2 32-bit installations first and then do the 64-bit one. I'm not very keen on dealing with multiple partitions for all my programs, especially if they can't talk to one another (although I bet there's tools that allow you to view on the parttions, like I said I don't have much experience with this.) I know the 64 will require its own partition.
Sorry if this is really "out there" or inappropriate for this community. If someone knows a more appropriate one please let me know. I just figured since there appears to be a decent number of intelligent computer users here that perhaps there'd be someone here who could help me as well. Thanks alot.
Source: http://www.livejournal.com/community/aspdotnet/49429.html
-
"insert into" сразу в две таблицы
Date: 11/29/05
(MySQL Communtiy) Keywords: php, mysql, sql
Уважаемые mysql-гуру,
никак не могу найти решение для (как мне казалось) простой задачи.
Ситуация такая: на сайт загружается графический файл. Его название и номер объекта, к которому относится этот файл, заносятся в таблицу.
При этом мне те же значения ('$id','$filename') нужно занести в ещё в одну таблицу.
Можно ли сделать это за один прогон?
Мне не знаком вариант insert с двумя таблицами.
Может вы что-то подскажете?
спасибо!
upd
sorry, a wrong community (or a wrong lanuage for the rihgt community)
the question was if it’s possible to insert values into two tables at once – I
upload a file and insert information about this file into two tables
(PHP&MySQL).
I’d like to know if there is a way to do it with one insert
only …
Source: http://www.livejournal.com/community/mysql/74109.html
-
Sending a weekly email based on predefined search criteria
Date: 11/29/05
(PHP Community) Keywords: mysql, database, sql, web
Need some tech help and pointers.
My client is asking to send users an email every week, automatically. I have no clue how to do this.
The content of that email will be created by doing a search of a MySQL database.
If anyone knows how to do this or can point me some where useful, I'd appreciate the help.
[UPDATE you guys are making me laugh, relieving a lot of stress]
I could set up an event to run from my iCAL that loads a web page!
Source: http://www.livejournal.com/community/php/371609.html
-
Question...
Date: 11/30/05
(MySQL Communtiy) Keywords: php, sql, web
I'm pretty new to db design. I had a class on MS Access/SQL back at PSU, but never really used it. So, I'm familiar, but I still don't know how to figure things out very well.
Anyway, here is my problem: I am attempting to make a db for the upcoming college bowl season. Every year, my family picks the bowl games and whoever wins gets a special prize. I want to make it into a db this year, though, so that you can view any pickset without having to see ALL of them (there are 28 bowls + at least 10 people, so you can see that is a ton).
I tried making a table with the bowls in it like this:
ID | Name | Winner
------------------------------
1 | Bowl 1 | Team 1
2 | Bowl 2 | Team 2
then tried making a table with the picks in it like this:
ID | Name | Pick
-------------------------
1 | Jim | Team 1
2 | Tony | Team 2
but as you can see that doesn't work out, because each person only gets one pick in the table.
So the next thing I tried was making a seperate table for each person's picks with just the bowl name and the pick in it. It seems like that will amount to a ton of tables, though, so I'd rather try something more compact.
The next thing I toyed around with was making a table like so:
Table: Pickset
ID | Name | Bowl 1 | Bowl 2 | Bowl 3
--------------------------------------------------------
1 | Jim | Pick 1 | Pick 2 | Pick 3
2 | Tony | Pick 1 | Pick 2 | Pick 3
But I can't figure out how to relate it to the other table. Maybe I don't need to? I will be using PHP to display it on the web, by the way.
Basically I want the page to say:
Display Picksets:
Jim [ ]
Tony [ ]
SUBMIT
So that whatever you check off will display in a nice table.
Can anyone help me out here..?
Source: http://www.livejournal.com/community/mysql/74483.html
-
Dumb SQL Server Query question
Date: 12/01/05
(Asp Dot Net) Keywords: database, sql
I'm writing a program that does queries on a database, and we just converted to a code-table format (instead of whole strings going in the DB we just put in numbers that reference another table which has all the definitions. Note that these tables are NOT connected (sadly.)) Anyways I'm writing this program that returns data from the database into a datagridview. I've been told that I can't do the conversion on the DataSet or the DGV side and that SQL server needs to do it, so basically I need to write a query that will get all the records that match the request, and then in a particular column, instead of putting in the number that is in teh database, have it look at the code table, find the matching id, and have THAT be displayed instead.
Here's conceptually what I'm going for (this is NOT SQL compliant and my SQL knowledge isn't that great. Hell if it was I wouldn't be here asking this question which I know any standard SQL DB user will likely know the answer to):
SELECT * FROM Table1, Table2
In Table1.Column,
instead of showing the code in it,
WHERE Table1.Column = Table2.Column(id),
Display in Table1.Column the info in Table2.Description.
I realize this is sort of hard to describe in text vs speech. I know there's an easy way to do this with an Inner Join, but that simply adds the info from the 2nd table to the end of the first (and displayed) table.
Here's the SQL code
SELECT * FROM sfrf_request
INNER JOIN sfrf_request_type
ON CONVERT(int,sfrf_request.request_type)=sfrf_request_type.id
WHERE sfrf_request.id = ddl1.SelectedIndex
BTW the CONVERT function is used because the column has string data in it still and thus I can't reference it as an integer.
Any help would be greatly appreciated.
Source: http://www.livejournal.com/community/aspdotnet/49681.html
-
Me, again ^_^
Date: 12/01/05
(Web Development) Keywords: sql, web
Anyone know of a webhost that will allow the locking of tables in SQL?
Source: http://www.livejournal.com/community/webdev/274960.html
-
CMS for Windows SQL Server
Date: 12/01/05
(Web Development) Keywords: cms, sql
Would anyone happen to have suggestions for a CMS which can run on a Windows SQL server? This is for a small company so I don't need anything huge, but something with support and ease of use would be great. Thanks.
Source: http://www.livejournal.com/community/webdev/275467.html
-
CMS for Windows SQL Server
Date: 12/02/05
(WebDesign) Keywords: cms, sql
x-posted
Would anyone happen to have suggestions for a CMS which can run on a Windows SQL server? This is for a small company so I don't need anything huge, but something with support and ease of use would be great. Thanks.
Source: http://www.livejournal.com/community/webdesign/1024932.html
-
stored procedures
Date: 12/02/05
(MySQL Communtiy) Keywords: mysql, sql
So MySQL 5.0 has stored procedures.. Could someone touch on why I would want to use these in an environment developed around 4.1?
Source: http://www.livejournal.com/community/mysql/74834.html
-
SqlDataSource UpdateParemeters
Date: 12/06/05
(Asp Dot Net) Keywords: database, sql
Hey gang,
I'm in the process of fixing an application a former programmer slap together. We found the database design went against company standards, so our DBA went through to fix her up. Now I'm working on the task of fixing the UI code to interact properly with the new changes.
However, I've ran in to a strange behavior with UpdateParameters within my SqlDataSource.
Originally, the Stored Proc calls for the following parameters:
@id int = 0,
@original_id int = 0,
@original_division_id int = 0,
@division int = 0,
@division_id int = 0,
@revenue_type varchar(100) = '',
@revenue_num int = 0
Our DBA changed to:
@original_id int = 0,
@original_division_id int = 0,
@division int = 0,
@division_id int = 0,
@revenue_type varchar(100) = '',
@revenue_num int = 0
The difference? @id has been removed. (Original programmer wasn't even friggin using it!)
Now I've updated my SqlDataSource UpdateParameters to reflect changes, only to find when running SQL Profiler that my stored proc is being executed with 1 added parameter... @id!!
exec updRevenueType @original_id = 15, @original_division_id = 2, @division = 2, @division_id = 2, @revenue_type = N'Broadcast Designeeee', @revenue_num = 4020, @id = 15
Does SqlDataSource do some weirdness on the background I'm unaware of that looks at the database scheme or something and add it's own parameters? This is rather frustrating trying to find out where this stray parameter is coming from! Anyone else run in to similar behavior?
More info: I'm using C# on .NET 2.0
Source: http://www.livejournal.com/community/aspdotnet/50533.html
-
PHP form problem
Date: 12/05/05
(PHP Community) Keywords: mysql, sql, security
I was just asked to take a look at a form here at work. The purpose of it is to allow people to sign up for a mailing list: first name, last name, email. It takes the details from the form and just adds it to a MySQL db without doing any error checking. The client has just said that they're getting all kinds of weird entries. What's showing up look like pieces from email headers. I just took a look at the script (which I didn't write) and there doesn't seem to be any security on it to restrict access to the form script to just the client's domain. All of the weird entries seem to be coming from the same email address (onemoreaddress@hotpop.com)
My guess is that someone is submitting info to the form through another domain or otherwise hacking the form/db. Has anyone had a problem like this before or have any other opinions on what might be causing it?
I'm going to add in some error checking and see if I can set up something to only allow the form to be processed if submitted on the client's domain. Anything else I should think about?
Source: http://www.livejournal.com/community/php/374052.html
-
I think I'm in serious trouble.
Date: 12/06/05
(MySQL Communtiy) Keywords: php, mysql, sql
I have a DB. Had RedHat 9.0. Went to Ubuntu (I love it). I've been setting everything back up. Before wiping the drive, I copied my entire DB folder (had mysql folder and my db folder). I thought that was sufficient to back it up. Upon installing Ubuntu, I apparently have a newer version of MySQL.
I usually use phpmyadmin to manage the db. It's going crazy with errors not being able to find tables (mainly .frm files).
I think I made a serious mistake. Was I supposed to use some kind of export command before making it portable? Is there any way of even getting my tables into a normal view? At this point, I don't even mind manually entering everything as long as I can get it viewed!
I guess what I'm asking... Am I screwed??????
Source: http://www.livejournal.com/community/mysql/75091.html
-
Another question...
Date: 12/06/05
(MySQL Communtiy) Keywords: php, mysql, sql, linux
It's me again.
Got this message through phpmyadmin:
Warning: Your privilege table structure seems to be older than this MySQL version!
Please run the script mysql_fix_privilege_tables that should be included in your MySQL server distribution to solve this problem!
I'm on Linux (Ubuntu). where is this function/module and how do you call it? Through mysqladmin?
Source: http://www.livejournal.com/community/mysql/75435.html
-
Accessing controls from a GridView EmptyDataTemplate
Date: 12/07/05
(Asp Dot Net) Keywords: css, asp, sql
Anyone know how I can access controls within the EmptyDataTemplate of my GridView?
<asp:GridView ID="grdProjectHours" DataSourceID="sqlModifyProjectHours"
PageSize="15" AllowPaging=true AllowSorting=true
AutoGenerateColumns=false GridLines="Both"
ShowFooter=true BorderWidth="2" BorderColor="#000000"
runat=server Width="100%"
OnDataBound="grdProjectHours_OnDataBound"
OnRowUpdating="grdProjectHours_OnRowUpdating"
EditRowStyle-VerticalAlign="top">
...
<Columns>
<asp:TemplateField HeaderText="Project" SortExpression="project">
...
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="gridHeader"><asp:Label ID="lblEmptyProject" runat="server" Text="Project" /></td>
<td class="gridHeader"><asp:Label ID="lblEmptyHours" runat="server" Text="Hours" /></td>
<td class="gridHeader"><asp:Label ID="lblEmptyWorkDate" runat="server" Text="Date of Work" /></td>
<td class="gridHeader"><asp:Label ID="lblEmptyChangeNumber" runat="server" Text="Change Order" /></td>
<td class="gridHeader"><asp:Label ID="lblEmptyComments" runat="server" Text="Comments" /></td>
<td class="gridHeader"></td>
</tr>
<tr>
<td colspan="7" height="2"></td>
</tr>
<tr>
<td colspan="7" bgcolor="#cccccc"></td>
</tr>
<tr>
<td colspan="7" height="1"></td>
</tr>
<tr>
<td class="gridContent"><asp:DropDownList ID="cboNewProject" Width="225" runat="server" DataSourceID="sqlProject" DataTextField="project" DataValueField="id" OnDataBound="cboNewProject_OnDataBound" /></td>
<td class="gridContent"><asp:TextBox ID="txtNewHours" Width="50" runat="server" /></td>
<td class="gridContent"><asp:TextBox ID="txtNewWorkDate" Width="50" runat="server" /></td>
<td class="gridContent"><asp:TextBox ID="txtNewChangeNumber" MaxLength="10" Width="50" runat="server" /></td>
<td class="gridContent"><asp:TextBox ID="txtNewComments" MaxLength="155" Width="100" runat="server" /></td>
<td class="gridContent" align="right"><asp:LinkButton ID="btnAddProjectHours" runat="server" CommandName="insert" Text="add" OnClick="btnAddProjectHours_OnClick" /></td>
</tr>
<tr>
<td class="gridContent"><asp:RequiredFieldValidator ID="reqNewProject" ControlToValidate="cboNewProject" ErrorMessage="Project" CssClass="ErrorMessage" EnableClientScript="false" Display="Dynamic" runat="server" /></td>
<td class="gridContent"><asp:RequiredFieldValidator ID="reqNewHours" ControlToValidate="txtNewHours" ErrorMessage="Hours" CssClass="ErrorMessage" EnableClientScript="false" Display="Dynamic" runat="server" /></td>
<td class="gridContent"><asp:RequiredFieldValidator ID="reqNewWorkDate" ControlToValidate="txtNewWorkDate" ErrorMessage="Date of Work" CssClass="ErrorMessage" EnableClientScript="false" runat="server" /><asp:RangeValidator id="rngWorkDate" runat="server" CssClass="ErrorMessage" ControlToValidate="txtNewWorkDate" MaximumValue="1/1/2100" MinimumValue="1/1/1900" Type="Date" EnableClientScript="false" ErrorMessage="Date of Work (mm/dd/yyyy)" Display="dynamic" /></td>
<td class="gridContent"></td>
<td class="gridContent"></td>
<td class="gridContent" align="right"></td>
</tr>
</table>
</EmptyDataTemplate>
</asp:GridView>
Source: http://www.livejournal.com/community/aspdotnet/50872.html
-
When you think you know more than the code...
Date: 12/07/05
(PHP Community) Keywords: php, mysql, sql
Some may find this amusing :)
First, a little preface for those that keep up with this journal. I was running on RedHat 9.0, way outdated. And when I tried to update PHP, it was a mess. So I decided that it was time to just upgrade the entire OS. Went to Fedora 4... even worse nightmare. Then I found Ubuntu... redemption.
After getting everything setup and modified: The core, PHP, http, postfix, MySQL, SSH, FTP (yeah, thank God for Ubuntu!), everything finally returned to normal Monday morning around 3:00 AM.
The whole reason for updating was due to a bug I read about a long time ago in v 4.2.2. The bug was with the sort() function. I just remembered reading about it in my O'Reilly PHP Cookbook. Most of my sorting has always been done via MySQL. So I've never had a use for sort() until this one line of code. So I'm thinking after coding and it not working "ah, this is that bug".
So I went back to that line. After all this headache, I just immediately had to know if it worked now:
$options = ksort($this->allowable_commands());
I almost got sick to my stomach. The right answer?
$options = $this->allowable_commands();
ksort($options);
So only NOW do I go back to try to find what the bug actually was that PHP Cookbook talked about (page 98):
The sort() function doesn't preserve the key/value association between elements. Instead, entries are reindexed starting at 0 and going upward. (The one exception to this rule is a one-element array; its lone element doesn't have its index reset to 0. This is fixed as of PHP 4.2.3)
My usage wasn't even CLOSE to this bug! I thought sort() returned the re-sorted array.
That's what I get for overthinking. Go ahead, you can laugh at me. I did.
Source: http://www.livejournal.com/community/php/375336.html
-
Problems creating tables with UTF8 for 5.0 INNOdb databases
Date: 12/08/05
(MySQL Communtiy) Keywords: mysql, rss, software, database, sql, linux
Any ideas?
CREATE TABLE `LAD_RSSDB_FEEDSTER_CORE` (
`RSS_ID` int NOT NULL auto_increment,
`SITE` varchar(64) DEFAULT 'rssdb' NOT NULL,
`ACCOUNT_ID` int DEFAULT -2 NOT NULL,
`URL` varchar(900) NOT NULL,
`CHANGED` tinyint DEFAULT 1 NOT NULL,
`STATUS` tinyint DEFAULT 0 NOT NULL,
`LAST_PINGED` datetime DEFAULT '1970-01-01 00:00:00' NOT NULL,
`LAST_DOWNLOADED` datetime DEFAULT '1970-01-01 00:00:00' NOT NULL,
`TIMESTAMP` timestamp NOT NULL,
`PING_INTERVAL` bigint DEFAULT 144000 NOT NULL,
`CRC32` int DEFAULT 0 NOT NULL,
`STRIKES` int DEFAULT 0 NOT NULL,
`FIRST_CREATED` datetime NOT NULL,
`CREATED_BY` varchar(50) DEFAULT 'unknown' NOT NULL,
`NM_PROCESSED` int DEFAULT 0 NOT NULL,
`NM_CUMUL` int DEFAULT 0 NOT NULL,
UNIQUE KEY `RSSDB_FEEDSTER_CORE_IND1` USING BTREE (`RSS_ID`),
KEY `RSSDB_FEEDSTER_CORE_IND2` USING BTREE (`URL`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;
and I got the following error message:
#HY000Can't create table './rss/LAD_RSSDB_FEEDSTER_CORE.frm' (errno: 139)
Machine is l00nix and build is:
root@mosdef [6:43pm]:86:/data# mysqladmin version -p
Enter password:
mysqladmin Ver 8.41 Distrib 5.0.16, for pc-linux-gnu on i686
Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license
Server version 5.0.16-log
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /tmp/mysql.sock
Uptime: 5 days 1 hour 57 min 29 sec
Threads: 7 Questions: 11430901 Slow queries: 0 Opens: 0 Flush tables: 1 Open tables: 34 Queries per second avg: 26.036
The production version of this will be on FreeBSD - is this a locale issue? Do I need to recreate databases and/or recompile?
Source: http://www.livejournal.com/community/mysql/75539.html