Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    MYSQL




PHP MySQL Code Generators


I'm looking for a PHP code generator that will support forms that access data from lookup tables, sometimes two or three levels deep.

All of the generators I've seen are very simple single table lookups. Which is no use to me. DBDesigner's simple frontend goes to one level but my design goes further.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Code Generators
Is there a FREE code generator program that will generate forms and listings and maybe a complete set of updates and edits forms?

Code Generators
Is there a FREE code generator program that will generate forms and
listings and maybe a complete set of updates and edits forms?

Access SQL Code > MySQL Code (INNER JOINs)
I've basically created the following tables / queries as part of my first mySQL project :

Candidates
---------------
Candidate_ID (autonumber)
Name (text)
...

1, Iain
2, Fi
3, Rob


Vacancies
--------------
Vacancy_ID (autonumber)
Vacancy (text)
...

1, Cartographer
2, Gardener
3, Occupational therapist
4, Web designer
5, Recruitment manager


Profiles
-----------
Profile_ID (autonumber)
Profile (text)
...

1, Map making
2, Web design
3, Gardening
4, Hand therapy
5, Recruitment
6, Aviation
7, Sport
8, Travel


VacancyProfiles
----------------------
Vacancy_ID (number)
Profile_ID (number)
...

1,1
1,2
4,2
2,3
3,4
5,5
5,6

CandidateProfiles
--------------------
Candidate_ID (number)
Vacancy_ID (number)
...

1,1
1,2
1,7
1,8
2,3
2,4
2,8
3,5
3,6
3,7

and from there created two queries

CandidatesQuery
--------------------

SELECT Candidates.Candidate_ID, Candidates.Name, Profiles.Profile_ID, Profiles.Profile
FROM Profiles INNER JOIN (Candidates INNER JOIN CandidateProfiles ON Candidates.Candidate_ID = CandidateProfiles.Candidate_ID) ON Profiles.Profile_ID = CandidateProfiles.ProfileID;

1, Iain, 1, Map making
1, Iain, 2, Web design
1, Iain, 7, Sport
1, Iain, 8, Travel
2, Fi, 3, Gardening
2, Fi, 4, Hand therapy
2, Fi, 8, Travel
3, Rob, 5, Recruitment
3, Rob, 6, Aviation
3, Rob, 7, Sport

and

Vacancies_Query
-------------------

SELECT Vacancies.Vacancy_ID, Vacancies.Vacancy, Profiles.Profile_ID, Profiles.Profile
FROM Profiles INNER JOIN (Vacancies INNER JOIN VacancyProfiles ON Vacancies.Vacancy_ID = VacancyProfiles.VacancyID) ON Profiles.Profile_ID = VacancyProfiles.ProfileID;
...

1, Cartographer, 1, Map making
1, Cartographer, 2, Web design
2, Gardener, 3, Gardening
3, Occupational therapist, 4, Hand therapy
4, Web designer, 2, Web design
5, Recruitment manager, 5, Recruitment
5, Recruitment manager, 6, Aviation

Trouble is, I come from an Access background, and I think the syntax of mySQL SQL is different to Access SQL - in the case here for the INNER JOINs - could anyone help out with the syntax for the queries above in mySQL friendly SQL, as I'm a bit unsure of what it should be.

Update Several Columns In A Row - Postal Code Or Zip Code
Ok - I have 125 records. They all have different postal codes. I have a column named "Region". I want to update all postal codes starting with "V" to region "WST".

How can I do this? I know how to update on MASS based on the column, but can I what I need to do?

Java Code Or Pseudo Code For "Outer Join"
I want to implement the "outer join" functionality in Java. Can
somebody explain the pseudo code for the same. OR what needs to be done
to extend the hash-join Java code of equijoin.

MySQL Code
I am scripting In ASP and with a DSN connection to mysql. I need a script which can query the database to see if two fields (username or email address) which are both submitted by a user exist anywhere in the database.I have tried various scripts so far, but none seem to work.

PATH> User submits (joebloggs, joebloggs@hissite.com) > Check DB to see if either of these exist anywhere in the file.

Connection String :

'Init the DB Connection
on error resume next
dim adoConnstep
dim adoRSstep
dim strQuerystep
set adoConnstep = Server.CreateObject("ADODB.Connection")
adoConnstep.Open "DSN=mydsn"

I Cannot Get Php And Mysql To Talk, Help Please! My Code Is Below
Im on windows xp using mysql server 5.0, apache http server 2.0.59 and php 5.2.1.1 When I load the page it appears completely blank with just a white background. My code is below can anyone help please?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Our List of Jokes</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<?php
// Connect to the database server
$dbcnx = @mysql_connect('localhost', 'root', 'root');
if (!$dbcnx) {
exit('<p>Unable to connect to the ' .
'database server at this time.</p>');
}

// Select the jokes database
if (!@mysql_select_db('ijdb')) {
exit('<p>Unable to locate the joke ' .
'database at this time.</p>');
}

?>
<p>Here are all the jokes in our database/p>
<blockquote>
<?php

// Request the text of all the jokes
$result = @mysql_query('SELECT joketext FROM joke');
if (!$result) {
exit('<p>Error performing query: ' . mysql_error() . '</p>');
}

// Display the text of each joke in a paragraph
while ($row = mysql_fetch_array($result)) {
echo '<p>' . $row['joketext'] . '</p>'
}

?>
</blockquote>
</body>
</html>

Is It Safe To Just Code For MySQL 4.1?
Is it safe to concentrate on just MySQL 4.1 in software that you offer for download / sell? Or should I still support MySQL 3.xx versions?
If 4.1 went into production status in october 2004 then most hosters should have updatet their servers by now, but I cannot be sure about that.

I never really looked at the new features 4.1 introduced up until now like Subqueries which are really useful and I would like to write just one DB driver.

Mysql Zip Code Database
Does anyone know where I can find an open source mysql zip code database

Converting To Code MySQL
DROP TABLE VENDOR
DROP TABLE PRODUCT

CREATE TABLE VENDOR(
VENDOR_CODE CHAR(2) NOT NULL CHECK(VENDOR_CODE IN('AR', 'MS', 'WW')),
VENDOR_NAME VARCHAR(20) NOT NULL,
VENDOR_ADDRESS VARCHAR(15) NOT NULL,
VENDOR_CITY VARCHAR(15) NOT NULL,
VENDOR_STATE CHAR(2) NOT NULL CHECK(VENDOR_STATE IN('WI', 'SD', 'WV')),
VENDOR_ZIP_CODE CHAR(10) NOT NULL CHECK(VENDOR_ZIP_CODE LIKE'[0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]'),
VENDOR_PHONE_NUMBER CHAR(12) NOT NULL CHECK(VENDOR_PHONE_NUMBER LIKE '[0-9][0-9][0-9]-[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]'),
PRIMARY KEY(VENDOR_CODE)
)

CREATE TABLE PRODUCT(
PRODUCT_NO CHAR(4) NOT NULL PRIMARY KEY,
PRODUCT_NAME VARCHAR(30) NOT NULL,
PRODUCT_ON_HAND INTEGER DEFAULT 0,
PRODUCT_COST MONEY DEFAULT 0,
SELLING_PRICE MONEY DEFAULT 0,
PRODUCT_VENDOR_CODE CHAR(2) NOT NULL
CHECK(PRODUCT_VENDOR_CODE IN('AR', 'MS', 'WW')) REFERENCES VENDOR(VENDOR_CODE)
)

INSERT INTO PRODUCT VALUES('CHO4','CHESS SET',11,26.75,28.90,'WW');
INSERT INTO PRODUCT VALUES('DI24','DINOSAURS',14,3.75,4.95,'MS');
INSERT INTO PRODUCT VALUES('GL18','GLOBE',2,27.50,29.95,'MS');
INSERT INTO PRODUCT VA...........

MySQL Password In PHP Code
I am not sure using md5 is correct in the code below:

[CODE]
<?php
$Host ="localhost";
$User = "root";
$Password =md5("secretl");
$DBName="NewDatabase";
$TableName="Feedback";

$Link = mysql_connect($Host, $User, $Password)
or die("Couldn't make connection: " . mysql_error()); //on failiure, post error message

if($db = mysql_select_db($DBName, $Link))
{
print "connected to NewDatabase";
}
else
{
die("Couldn't select database:" . mysql_error());
}
?>
[/CODE]

The error message is as follows:
Couldn't make connection: Client does not support authentication protocol requested by server; consider upgrading MySQL client.

Separating Mysql From Code
I have an exorbitant amount of data that I would like to put into a MySQL database and eventually put into a LAMP-based CMS (by a professional developer) and eventually uploaded onto a website for all people to access.

Is it possible to load information into MySQL before any coding is performed by a developer, before any parts of the CMS are scripted? Can MySQL operate on its own as a database independent from any coding or do I need a developer to set it up before data can be loaded onto MySQL?

If this is possible, is there any sort of language I would need to be fluent in or can it be done using a graphic interface?

Beginning To Code MySQL
I'm teaching myself php/mysql for a specific purpose and I'm wondering if there's anything special I should look out for in my studies. Basically what I'm trying to accomplish is developing a page that will display a pre-populated list of video games and allow users to sort them by things such as title, release date, genre, ESRB rating, developer, etc; and in addition to those fields there will be another field with a short explanation of the game.As for updating the DB, I'm not sure yet if I'll just do it through phpmyadmin, or if I'd want to develop a front end for that on the site - in a password protected area or some such.

Forum Code Using MySQL/PHP
I am currently working on coding a forum for my website. I am fairly new to this coding stuff so i apologise if if this is something really easy.
The way i have coded the forum so far is that one page will display a list of all the topics within that forum. It also displays the unique ID of that topic. The topic headings are set up as a link which when clicked i want it to search the database for all the replies that link to that topic. I have linked the replies to the topics using simply the topic ID.
The problem i am having is i cant work out how to pass the ID variable along in my link, or how to code the link so it will find the replies for that particular topic.
Maybe i have gone about it all totally wrong and need to start from scratch.

How To Speed Up Mysql Query/php Code
I have a table in a mysql database. with 5 fields and the field ID as the primary key.

There are about 220 records in the database and the field 'Mediumimage' contains the file paths for the images to be dispalyed on the page.

the PHP code for the query is shown below. Im just wondering why it takes quite a while to process the pictures which are of a small size.

$query_handsets = "SELECT Handsets.Manufacturer, Handsets.Model, Handsets.Mediumimage, Handsets.`Handset Url`
FROM Handsets
WHERE Handsets.Manufacturer LIKE'". mysql_real_escape_string($_GET['manu'])."'";
$hansets = mysql_query($query_hansets, $Mobilecomparsion) or die(mysql_error());
$totalRows_hansets = mysql_num_rows($hansets);

<?php
$i = 0;
while ($row_hansets = mysql_fetch_array($hansets)) {
if ($row_hansets['Manufacturer'] != $lastManufacturer) {
if ($i == 0) {

echo '<img src="images/handsets/logos/'. $row_hansets['Manufacturer'].'.gif" /><br/>'
echo "<table cellspacing=&#3910;'><tr>";
$lastManufacturer = $row_hansets['Manufacturer'];
} else {
echo "</tr></table>";
echo '<img src="images/handsets/logos/'. $row_hansets['Manufacturer'].'.gif" /><br/>'
echo "<table cellspacing=&#3910;'><tr>";
$lastManufacturer = $row_hansets['Manufacturer'];
$i = 0;
}
} elseif ($i % 13 == 0) {
echo "</tr><tr>";
}

echo "<td align='center'><font face='Ariel' size=&#391;'>";
echo "<img src='images/4x4.gif' width=&#3960;' height=&#391;'><br/>";
echo '<img src="images/handsets/'.$row_hansets['Mediumimage'].'" /><br/>'
echo $row_hansets['Model'];
echo '</td>'

$i++;
}
echo '</tr></table>'
?>

MySQL Keeps Going Long After Code Stops
When some queries are executed on a server I have setup MySQL will continue to use up CPU cycles 5-10 minutes after the PHP code that executed the query has long since stopped. The browser page will be loaded and no further PHP code will be active on the entire server that could call MySQL into usage, yet MySQL will continue to use upwards of 80-90% of the available CPU processing power for that 5-10 minutes afterward. In fact, if the PHP page only takes a couple of seconds to load with next to no CPU usage then after it has finished loading MySQL will start utilizing the CPU for all it is worth as if it is trying to complete some task that only it knows about. This is on an isolated server so I know I am the only one using it.

This seems to happen most often when a LEFT JOIN is executed, though the query itself is very quick and returns the data in less than a second.

I am running MySQL 5.0.15 with Apache 2.0.54 and PHP 5.0.4 on Windows XP SP2.

I know this is terribly obscure sounding, but if anyone has any ideas where I could start to look for the source of the problem I would appreciate it. I know it is not in the code because if I run the code on a Linux server this doesn't happen, not to mention the fact that, as I said, the PHP code itself finishes without a hitch.

MySQL Automatically Formatting Code
Is there a way to tell a MySQL server to stop reformatting my code in views? It just drives me crazy that when I create view like that:

mysql> CREATE VIEW SYS_V_ActiveUsers AS
-> SELECT UserID, Login, Email FROM Users
-> WHERE Activate IS NULL;
And what I get in DB is:

select `Users`.`UserID` AS `UserID`,`Users`.`Login` AS `Login`,`Users`.`Email` AS `Email` from `Users` where isnull(`Users`.`Activate`)

And frankly, I hate it. I don't know why it does so, maybe to optimize the code, maybe for other reasons, but I'd like it to stop, at least for my development phase. Is there a switch or something like that to tell MySQL server to stop reformatting my code?

MySQL Error Code 1064:K@N@!:
I suspect that this is some kind of issue with privileges. However, the =
account I am using has been given 'ALL' privileges to the database I am =
trying to insert to. Am I save to assume that ALL includes insert =
privileges? Code:

Running Mysql Code Within A Php File?
I have been given a some mysql code that I have to run within a website - I am familiar with mysql in terms of insert info and querying a database but I at a loss as to how to make this work.

the mysql code works in mysqladmin, but how do I call it into my php code?

BTW the mysql code creates a new record in the database .......

Also, I need to tweak the code so it runs in a loop for different variables - in php I would run a FOREACH query, how do I do it in mysql?

What The Best Language Code To Connect MySQL --> C , C++ , Php,VB,Delphi?
What the best language code to connect MySQL --> C , C++ , php,VB,Delphi?

---- Speed
---- Stable
---- Security

Can anyone compare C , C++ , php4,php5 ,vb ,delphi to connect to MySQL ?

I need to know how about c++. now , i use php to connect to mysql in Web Application Dev.

Recover ECCN Code Of Mysql Release
Is it possible to recover ECCN code (Export Control Code Number) of a mysql distribution (or another identificatio product code if not possible).

Problem Create New Mysql User W/ Php Code
trying to create new mysql user w/ php code as below, but always got error message "Error, insert query failed". Please, point out what I did wrong and how to fix it.


<?php
$connect = mysql_pconnect('localhost', $AdminName, $AdminPass)
or die('Error, login db failed');
mysql_select_db(mysql) or die('Error, open db failed');

$query = "INSERT INTO user(Host, User, Password)
VALUES('localhost', '$UserName', '$UserPass')";
mysql_query($query) or die('Error, insert query failed');
$query = "FLUSH PRIVILEGES";
mysql_query($query) or die('Error, flush query failed');
?>


And even tried it w/ this code
[
$query = "INSERT INTO user
(Host, User, Password, Select_priv, Insert_priv, Update_priv)
VALUES ('localhost', $UserName, PASSWORD($UserPass), 'Y', 'Y', 'Y')";


Already searched but not successful, so if this problem was posted here, please post the link here.

Linking Stores With Products (was "MySQL Dificult Code")
I have a MySQL database dificult (for me anyway..).
I have a ecommerce site with a table of products.
Now I want to create a new table with a list of stores where clients can find near home those products. In a limit situation I can have a list of all products indexed in one store (and the products list is increasing everyday, the same with the list of store...). I want this feature to be capable of introdution of new products in a store that already as several products.
My idea is to develop 3 tables:

Products
+----+-----------+--------------+
| id | name | description |
+----+-----------+--------------+
| 1 | xxxxx | aasa... |
| 2 | vvvvvv | asasasasas... |
+----+-----------+--------------+


Stores
+----+-------------------+-----------+
| id | store | address |
+----+-------------------+----------+
| 1 | aaaaa | street1... |
| 2 | bbbbbb | street2... |
+----+-------------------+-----------+



Linking stores with products
+----+-------------------+-------------+
| id | store id | products id |
+----+-------------------+-------------+
| 1 | 1 | 1;2 |
| 2 | 2 | 2 |
+----+-------------------+-------------+

Can I implement this in MySQL? I mean how can (if I can) place several ids in a field? and how can I do the query in order to list the products inside a store?
Hope that I made my self clear. If not please do not hesitate to request further information.




Zip Code
Here is what I am trying to do. Maybe it's not possible, but I have a database for employees that I have created. It includes a name, photo, title and the zip code. Without bothering with selecting a state, I want to be able to type in a five digit number and if the number they search with is 200 or 300 numbers less than or greater than a zip code I have specified for an employee it retrieves the data.

SP Code
I am a SQL Server user and I tried to get a stored procedure to work with several iterations.

Here is what i tried first:

delimiter //
g
create procedure P()
begin
select * from ips_transactions;
end
//
g


This is what it returned:
Failed to execute SQL : SQL delimiter // g create procedure P() begin select * from ips_transactions; end // g failed : Unknown command ''.


Then I tried:

delimiter //
create procedure P()
begin
select * from ips_transactions;
end
//

And got this, which I thought my be a confirmation that the procedure was created:

Output from SQL command delimiter // create procedure P() begin select * from ips_transactions; end // .. No data returned

I tried to call it
call P()

and got this:
Failed to execute SQL : SQL call P() failed : PROCEDURE dev-demoasp3.P does not exist

What am I doing wrong? I have a client that wants all of my SQL server SP moved over, but I cannot even do a slect statement much less create temp tables and the such

Zip Code
I have the zip codes from the USPS in an Access 2000 database available for
immediate download for $2.50 via PayPal. Visit
http://www.digital-recovery.com/zip_code_database.htm for additional info
and to download a demo of the database.

Php Code
I have some fields that contain both text and some php code which is activated using the eval command.
I need to search and replace this php code with nothing, I want to get rid of it from mysql fields, however, because I am submiting an item of php within this sql command it seems to be getting upset...

[code]
update `articles` set `content`='[php]<?php
include('./1.php');
?>' (`content`,' ');

Help Cleaning Code?
I'm not too familiar with MySQL code, I was hoping someone could help clean this code to make it importable in PHPMyAdmin, in it's current form, it produces an extreme amount of errors when I attempt to import it in PHPMyAdmin.
— MySQL dump 10.9
–
— Host: localhost Database: meneame
— ——————————————————
— Server version 4.1.11-Debian_4sarge2

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=’NO_AUTO_VALUE_ON_ZERO’ */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

–
— Table structure for table `blogs`
–

DROP TABLE IF EXISTS `blogs`;
CREATE TABLE `blogs` (
`blog_id` int(20) NOT NULL auto_increment,
`blog_key` varchar(35) collate utf8_spanish_ci default NULL,
`blog_type` enum(’normal’,'blog’) collate utf8_spanish_ci NOT NULL default ‘normal’,
`blog_rss` varchar(64) collate utf8_spanish_ci NOT NULL default ‘’,
`blog_rss2` varchar(64) collate utf8_spanish_ci NOT NULL default ‘’,
`blog_atom` varchar(64) collate utf8_spanish_ci NOT NULL default ‘’,
`blog_url` varchar(64) collate utf8_spanish_ci default NULL,
PRIMARY KEY (`blog_id`),
UNIQUE KEY `key` (`blog_key`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;

–
— Table structure for table `categories`
–

DROP TABLE IF EXISTS `categories`;
CREATE TABLE `categories` (
`category__auto_id` int(11) NOT NULL auto_increment,
`category_lang` varchar(4) collate utf8_spanish_ci NOT NULL default ‘es’,
`category_id` int(11) NOT NULL default ‘0&#8242;,
`category_parent` int(11) NOT NULL default ‘0&#8242;,
`category_name` varchar(64) collate utf8_spanish_ci NOT NULL default ‘’,
PRIMARY KEY (`category__auto_id`),
UNIQUE KEY `category_lang` (`category_lang`,`category_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;

–
— Table structure for table `comments`
–

DROP TABLE IF EXISTS `comments`;
CREATE TABLE `comments` (
`comment_id` int(20) NOT NULL auto_increment,
`comment_randkey` int(11) NOT NULL default ‘0&#8242;,
`comment_parent` int(20) default ‘0&#8242;,
`comment_link_id` int(20) NOT NULL default ‘0&#8242;,
`comment_user_id` int(20) NOT NULL default ‘0&#8242;,
`comment_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`comment_karma` smallint(6) NOT NULL default ‘0&#8242;,
`comment_nick` varchar(32) collate utf8_spanish_ci default NULL,
`comment_content` text collate utf8_spanish_ci NOT NULL,
PRIMARY KEY (`comment_id`),
UNIQUE KEY `comments_randkey` (`comment_randkey`,`comment_link_id`,`comment_user_id`),
KEY `comment_link_id_2` (`comment_link_id`,`comment_date`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;

–
— Table structure for table `friends`
–

DROP TABLE IF EXISTS `friends`;
CREATE TABLE `friends` (
`friend_id` int(11) NOT NULL auto_increment,
`friend_from` bigint(20) NOT NULL default ‘0&#8242;,
`friend_to` bigint(20) NOT NULL default ‘0&#8242;,
PRIMARY KEY (`friend_id`),
UNIQUE KEY `friends_from_to` (`friend_from`,`friend_to`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;

–
— Table structure for table `languages`
–

DROP TABLE IF EXISTS `languages`;
CREATE TABLE `languages` (
`language_id` int(11) NOT NULL auto_increment,
`language_name` varchar(64) collate utf8_spanish_ci NOT NULL default ‘’,
PRIMARY KEY (`language_id`),
UNIQUE KEY `language_name` (`language_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;

–
— Table structure for table `links`
–

DROP TABLE IF EXISTS `links`;
CREATE TABLE `links` (
`link_id` int(20) NOT NULL auto_increment,
`link_author` int(20) NOT NULL default ‘0&#8242;,
`link_blog` int(20) default ‘0&#8242;,
`link_status` enum(’discard’,'queued’,'published’,'abuse’,'duplicated’) collate utf8_spanish_ci NOT NULL default ‘discard’,
`link_randkey` int(20) NOT NULL default ‘0&#8242;,
`link_votes` int(20) NOT NULL default ‘0&#8242;,
`link_karma` decimal(10,2) NOT NULL default ‘0.00&#8242;,
`link_modified` timestamp NOT NULL default CURRENT_TIMESTAMP,
`link_date` timestamp NOT NULL default ‘0000-00-00 00:00:00&#8242;,
`link_published_date` timestamp NOT NULL default ‘0000-00-00 00:00:00&#8242;,
`link_category` int(11) NOT NULL default ‘0&#8242;,
`link_lang` int(11) NOT NULL default ‘1&#8242;,
`link_url` varchar(200) collate utf8_spanish_ci NOT NULL default ‘’,
`link_url_title` text collate utf8_spanish_ci,
`link_title` text collate utf8_spanish_ci NOT NULL,
`link_content` text collate utf8_spanish_ci NOT NULL,
`link_tags` text collate utf8_spanish_ci,
PRIMARY KEY (`link_id`),
KEY `link_author` (`link_author`),
KEY `link_url` (`link_url`),
KEY `link_date` (`link_date`),
KEY `link_published_date` (`link_published_date`),
FULLTEXT KEY `link_url_2` (`link_url`,`link_url_title`,`link_title`,`link_content`,`link_tags`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;

–
— Table structure for table `trackbacks`
–

DROP TABLE IF EXISTS `trackbacks`;
CREATE TABLE `trackbacks` (
`trackback_id` int(10) unsigned NOT NULL auto_increment,
`trackback_link_id` int(11) NOT NULL default ‘0&#8242;,
`trackback_user_id` int(11) NOT NULL default ‘0&#8242;,
`trackback_type` enum(’in’,'out’) collate utf8_spanish_ci NOT NULL default ‘in’,
`trackback_status` enum(’ok’,'pendent’,'error’) collate utf8_spanish_ci NOT NULL default ‘pendent’,
`trackback_modified` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`trackback_date` timestamp NULL default NULL,
`trackback_url` varchar(200) collate utf8_spanish_ci NOT NULL default ‘’,
`trackback_title` text collate utf8_spanish_ci,
`trackback_content` text collate utf8_spanish_ci,
PRIMARY KEY (`trackback_id`),
UNIQUE KEY `trackback_link_id_2` (`trackback_link_id`,`trackback_type`,`trackback_url`),
KEY `trackback_link_id` (`trackback_link_id`),
KEY `trackback_url` (`trackback_url`),
KEY `trackback_date` (`trackback_date`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;

–
— Table structure for table `users`
–

DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
`user_id` int(20) NOT NULL auto_increment,
`user_login` varchar(32) collate utf8_spanish_ci NOT NULL default ‘’,
`user_level` enum(’normal’,’special’,'blogger’,'admin’,'god’) collate utf8_spanish_ci NOT NULL default ‘normal’,
`user_modification` timestamp NOT NULL default CURRENT_TIMESTAMP,
`user_date` timestamp NOT NULL default ‘0000-00-00 00:00:00&#8242;,
`user_pass` varchar(64) collate utf8_spanish_ci NOT NULL default ‘’,
`user_email` varchar(128) collate utf8_spanish_ci NOT NULL default ‘’,
`user_names` varchar(128) collate utf8_spanish_ci NOT NULL default ‘’,
`user_lang` int(11) NOT NULL default ‘1&#8242;,
`user_karma` decimal(10,2) default ‘10.00&#8242;,
`user_url` varchar(128) collate utf8_spanish_ci NOT NULL default ‘’,
PRIMARY KEY (`user_id`),
UNIQUE KEY `user_login` (`user_login`),
KEY `user_email` (`user_email`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;

–
— Table structure for table `votes`
–

DROP TABLE IF EXISTS `votes`;
CREATE TABLE `votes` (
`vote_id` int(20) NOT NULL auto_increment,
`vote_type` enum(’links’,'comments’) collate utf8_spanish_ci NOT NULL default ‘links’,
`vote_date` timestamp NOT NULL default CURRENT_TIMESTAMP,
`vote_link_id` int(20) NOT NULL default ‘0&#8242;,
`vote_user_id` int(20) NOT NULL default ‘0&#8242;,
`vote_value` smallint(11) NOT NULL default ‘1&#8242;,
`vote_ip` varchar(64) collate utf8_spanish_ci default NULL,
PRIMARY KEY (`vote_id`),
KEY `user_id` (`vote_user_id`),
KEY `link_id` (`vote_link_id`),
KEY `vote_type` (`vote_type`,`vote_link_id`,`vote_user_id`,`vote_ip`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci PACK_KEYS=0;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;


Zip Code Radius
I am using the following function from phpclasses.org.

How can I gues this to return also the distance for each zip code?

PHP

function inradius($zip,$radius)
    {

        $query2="SELECT * FROM zips WHERE zip='$zip'";
        $row = $db->get($query2);

            $lat=$row["lat"];
            $lon=$row["lon"];
            $query2="SELECT zipcode FROM zips WHERE (POW((69.1*(lon-"$lon")*cos($lat/57.3)),"2")+POW((69.1*(lat-"$lat")),"2"))<($radius*$radius) ";
            $result = $database->query($query2);
            if($result->count()<>0) {
                while($row = $result->fetch()) {
                    $zips[$i]=$row["zipcode"];
                    $i++;
                }
            }
        }else{
            return array();
        }
     return $zips;
    }

How Do I Code This In The WHERE Clause?
I have a form where people can click on checkboxes for their ethnicity. When they click on search it will take all those ethnicity id's and compare it to others in a database and pull out all members that have the same ethnicity.

In the database when a user has put in their own ethnicity it puts all the ethnicity id's in one field (seperated by commas). So how do I code it so that I can take an array of ids and compare it to a field of ids in the databse?

Zip Code Query
Ok when using this I have it so even planners can find racers. The Racers opt to be searched and how far they are willing to travel to race amoung other things.

When an event planner searches for Potential Racers he type in her zip code and I want it to find all racers that are willing to travel to his zip code.

What I thought of for a solution is when the racer makes herself searchable to populate a TEXT Column with all the Zips that are in her radius.

The problem with this is that there could be around 900 zip codes thats around 5,400 charaters. To me that seems like a lot.

Is this still the best solution and if so when I get a list of all the zip codes in her radius how can I combine all the Rows to a single row so I can enter in into a single field.

Foreign Key Code
I'm trying to reference the two primary keys in the "choise" table in "clicklist" but just can't get it to work. I have tried one of them up to this point, but it doesn't work either. :(

CREATE TABLE `Choice` (
`productID` int(11) NOT NULL,
`Nickname` varchar(32) NOT NULL,
`Quantity` int(11) NOT NULL,
`TimeOfSelection` datetime NOT NULL,
PRIMARY KEY (`productID`,`Nickname`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

create table `clicklist` (
`Nick` varchar(32) not null,
`productID int(11) not null default '0',
key `productID` (`productID`),
constraint `productID` foreign key (`productID`) references `Choice`
(`productID`))
engine = InnoDB default charset = latin1;

ERROR (HY): Can't create table '.perlacasa/Clicklist.frm' (errno: 150)

Need Help Revising Some Old Code
Alright, I found this code in a much older post:

PHP Code:





 $sql = mysql_query ( 'SELECT FOUND_ROWS() FROM table_name' );
    $max = mysql_result ( $sql, 0 );

    $sql = mysql_query ( 'SELECT * FROM table_name ORDER BY id ASC LIMIT ' . ( $max - $get ) . ', ' . $get );

    while ( $t = mysql_fetch_assoc ( $sql ) )
    {
        echo $t['id'] . '<br />';
    } 

It's basically supposed to the newest 7 entries in a table in descending order for mysql versions that don't support sub-queries, like mine doesn't.

I was wondering if someone could get this to work properly. First off, I'm not sure what value $get is supposed to have, because it was never made, and I'm also unsure why $max is set to 0.

Error Code 127
Where do I go to find out the meaning of this ( or err codes in general ) message.
What is the solution to this problem - any ideas ?

One Line Of Code
First here is the line of code Im getting an error on...

$q2 = MYSQL_QUERY("SELECT *, DATE_FORMAT(Date, '%M-%D-%Y') AS newdate FROM usercars WHERE User = '$user' AND Active = "T"")
or die ("SQL Error");
Before I tried to add the Date_format the lines worked fine and read as follows.
$q2 = MYSQL_QUERY("SELECT* FROM usercars WHERE User = '$user' AND Active = "T"")
or die ("SQL Error");
Second, when working will this force the date to be
02-24-2005 or
02-24-05 ?
I would prefer the second option, any idea how to force that format?

SIC Code List
I'm working on an app that needs to reference SIC codes. They basically map numbers to industry categories, making it easy to categorize businesses. I've spent plenty of time googling, and have only come up with SIC lookups, not full lists. The one list I did find only went out to 6 digits, and I need a list containing 8-digit codes. Does anybody here have a list of SIC codes in either a mysql database or csv file? Or have any idea where I can find one?

Zip Code Locator
Let's see the brain childs work this one out!
I have a table that has a whole bunch of customers in there. One field that I am interested in is customer_zipcode. With that all of our customers have their zipcode listed.Now, what if I want our managers to be able to put the store zip code in a box and then they define how many miles they want to travel such as 25 miles (hard code if you need to make it easier is fine).
Then what I would like to have returned is something similar to:
customer_id | customer_fname | customer_lname

How would I go about doing that? I figured that I would have to use a LEFT JOIN customers ON customers.zipcode = zip_code.zip_code .... but the rest I am kinda clueless on.

Error Code 28
I'm getting this error all the time, among others..
So I guess that I had run out of diskspace, so I did a "SHOW VARIABLES" to see where my data was stored, and found them to be:
bdb_home /var/db/mysql/
bdb_tmpdir /var/tmp/
datadir /var/db/mysql/

so, next was to do a df to see if /var was all down..
heres my result:
/dev/ad0s1e 257998 78556 158804 33% /var

I can't seems to find out what is wrong here.. From what I can see the shoulb be 33% space left on this device..?
How come MySQL gives me a error saying no space left?

Error Code 28
mySQL started to return error code 28 whenever I try to insert any data, create tables, etc.
I used 'perror' on 28 and it returned:
Code:
No space left on device

I then used 'dd' on the drive and it said that all partitions have at least 20% space left on it.
What can I do to fix this?

Zip Code Column
I am capturing zip codes in my database. In the table, I have the type set to "int(5)". I am running into problems where a given zip code starts with a "0" (ex. 06539) in that the leading "0" is being stripped.I've got a workaround in place now but I'm wondering what the "right" way to fix this would be. Should I change the type of the zip code field to something like varchar?

Change The Code
when i put data in my mysql table on mine local webserver it appears only
when i change the html code of the page that contains the php code.
I already put the meta-tag 'no-chache' on mine site but it doesn't seams to
work

How I Can DROP The Database Using PHP Code
I use this script to add database, this script successful to ceate the database fox

<?
$my_db = "fox";
mysql_create_db("$my_db");
?>
-------------------------------------------------------------------------------

When I use this script to drop database, this script fail to drop the database fox

<?
$my_db = "fox";
mysql_drop_db("$my_db");
?>
-------------------------------------------------------------------------------

How i can DROP the database fox?

Yet Another Zip Code Related Question
I'm new to MySQL and proximity searches so forgive my ignorance.

I have the following query which works perfectly (which I got from a post here thank you very much)

SELECT zip
FROM zipcodes
WHERE degrees(acos(
sin( radians(zipcodes.latitude) )
* sin( radians(33.727807))
+ cos( radians(zipcodes.latitude))
* cos( radians(33.727807))
* cos( radians(zipcodes.longitude - -84.41983) )
) ) * 69.09 < 5
This returns a list of zipcodes

Now I want to find every bookstore in that list.

SELECT * FROM bookstores WHERE zipcode IN (
SELECT zip
FROM zipcodes
WHERE degrees(acos(
sin( radians(zipcodes.latitude) )
* sin( radians(33.727807))
+ cos( radians(zipcodes.latitude))
* cos( radians(33.727807))
* cos( radians(zipcodes.longitude - -84.41983) )
) ) * 69.09 < 5)
This gives me a syntax error.

Need Help With Code Plz - Unkown Error
<?php
$username ="ictcranfor";
$password="s29698";
$database ="ictcranfor";

mysql_connect ('mysql4.streamline.net',$username, $password) or die ("Unable to connect".mysql_error());
mysql_select_db ($database);

$licencenumber_submitted=$_POST['licencenumber'];
$title_submitted=$_POST['title'];
$firstname_submitted=$_POST['firstname'];
$surname_submitted=$_POST['surname'];
$age_submitted=$_POST['age'];
$gender_submitted=$_POST['gender'];
$address_submitted=$_POST['address'];
$postcode_subm.............................................................

Need Server To Test Code
Does anyone have a server where the dates can be tweaked to see if some code works. I need to see if the dates crossover into the next month when it gets close to the end of the month and we are looking a week out.

Date Code Conversion
I have a data set that I inherited that was exported into a text CSV file, apparently from a MYSQL database. The file contains date code values that I would like to convert into date strings.

What is the algorithm that MYSQL uses to create the date code? ie, how can I convert the value 1086066000 into "Jan 28, 2004"? I'd prefer to do it in something like Matlab that I'm fluent in, rather than MYSQL where I'd be starting from total zero.

Transaction Secure Code
When executing a specific query, I need to lock the db to ensure that no data is altered while the query executes.

My question is: Do I need to take a ROLLBACK on the db to release the lock, or is it enought just to set autocommit=1 again?

Simplified example of how I do it now:
SET AUTOCOMMIT=0
BEGIN
SELECT .......bla bla bla <execute some php code based on the result>
ROLLBACK
SET AUTOCOMMIT=1

Example of how I want it to be:
SET AUTOCOMMIT=0
BEGIN
SELECT .......bla bla bla <execute some php code based on the result>
SET AUTOCOMMIT=1

Are there any downsides by not using ROLLBACK in the second example? The database has not been altered in any way.

Creating A User From Code
Does anyone know if it's possible and how to create a user account from code on MySQL 4.1.5?

HTML-code Storage?
When I insert HTML-code in a varchar or text field the < and > characters get surrounded by spaces. For example <b> is stored as < b > instead. What am I doing wrong?


Copyright © 2005-08 www.BigResource.com, All rights reserved