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


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





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;
    }




View Complete Forum Thread with Replies

Related Forum Messages:
Geocoding / Radius
We have a listing of professionals and we're looking to have a user enter a zip code and find all the professionals within a radius of 100 miles of the user's zip code.
We have an existing table containing all the zip codes, counties, and cities in the US.
We also have zip codes for the physical locations of each of the professional listings.
When a user enters a zip code and radius, we need to somehow know which zip codes are within that radius.

View Replies !
Query Which Gets Rows Based On A Radius, Lon And Lat Doesn't Work?
I have found this query which gets rows based on a radius. I need this for zip codes based on lon and lat's.

$sql2 = "SELECT * FROM table as z WHERE (SQRT( (69.1 * (".$userLat." - z.lat)) * (69.1 * (".$userLat." - z.lat)) + (53.0 *(".$userLong." - z.lon)) * (53.0 *(".$userLong." - z.lon))) <= ".$userRadius." )";
return $sql2;
$res = mysql_query($sql2, $connDB) or die(mysql_error());
$row = mysql_fetch_assoc($res);
based on a test zip code gives a result like


SELECT * FROM table as z WHERE (SQRT( (69.1 * (52.399834 - z.lat)) * (69.1 * (52.399834 - z.lat)) + (53.0 *(4.840762 - z.lon)) * (53.0 *(4.840762 - z.lon))) <= 100 )
the lat and lon of the test zip code are right. As you can see z.lat and z.lon don't get any value. And these would be every lat and lon in table.

In my db table lon and lat are decimal(10,6) type with a default value of 0.000000

View Replies !
Zip Code Column Set As Integer... Removes Extra 0 If Zip Code Ends In A 0
put my zip code column as an integer and not varchar, so now if the rows have a zip code that ends with a 0 it will discard it (for example zip code 64840 will get stored as 6484).

What query can I run to fix this problem to add a zero if the zip code column has 4 digits?

View Replies !
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?

View Replies !
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.

View Replies !
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`,' ');

View Replies !
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.

View Replies !
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

View Replies !
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

View Replies !
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?

View Replies !
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?

View Replies !
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?

View Replies !
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?

View Replies !
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.

View Replies !
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?

View Replies !
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?

View Replies !
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.

View Replies !
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)

View Replies !
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"

View Replies !
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.

View Replies !
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 */;


View Replies !
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?

View Replies !
Order By Zip Code
I really just have a simple question about this. i have the search engine i'm working on and when people search for a zipcoded say 75075 ( plano tx ) it still pulls up 75073, 75074, 75075, 75076 all plano zipcodes. i'm wanting to do some kind of order by where it shows 75075 first then the rest after that. is this possible or am I chasing pandoras box. I've been looking everywhere I just can't find it. thnx.

basic php sql for the code:

PHP Code:

if ($zipcode == "yes") {
$ordrby = "Zip";
} else {
$ordrby = "name"; // this is what it orders by when they search by city/state
}

// Removed code //

mysql_query("SELECT DISTINCT * FROM $tabledad WHERE City = '$city' AND (Name = '$name' or $q) GROUP BY Address ORDER BY $odrby");

this is just basicly what it says. I don't feel it's necessary to post a bunch of code that's not really part of what i'm asking.

View Replies !
Area Code Lookup
I'm looking for a table with area codes and states for the USA and Canada.
To be used for validation in signup forms.

View Replies !
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.

View Replies !
Formatting Airport Code
I have a string of airport codes formatted like this

KWIMAACCJTRZ

Every 3 letters is a complete airport code. i would like to know how I might format this so that I can query the database with one airport code at a time and return the result. The strings vary in length from one code to over 200 airport codes so I cant put them in a field each. so how might I do this also i need it so that I can creatte a dropdown menu with the results (just formatted in a way that I can do this via php as i already know how to do the dropddown menu). This is really complicated for me and I cant find any help on the internet for this so you are my last hope.

View Replies !
Edit This Object Code
Code:

$s_groups = $db->selectObjects("db_direct","1 ORDER BY sid");


I have to add "WHERE sid < 10" in this code. I tried
$s_groups = $db->selectObjects("db_direct","1 WHERE sid <10 ORDER BY sid"); which didn't help

View Replies !
Equivelent To A PEAR:DB Code
if (DB::isError($check) || $check->numRows() == 0) {

I would like this in mysql syntax

i got the first bit: mysql_error($check)

but I cant get the second one

View Replies !
Create 5,050 Lines Of Code
Small problem, and probably a quick solution.
(but I have little background in programming)
I need to create 5,050 different lines of code for inserting data into one table. I have various large number sets I need to generate and place into every row under one particular column value...
(basically, there's one particular field that has 100 values)
I'm looking for a way to write a script to generate these numbers for me that I can either copy and paste, or generate to a .txt file.

View Replies !
Simple Code Needed
Just need a little code to transfer a user to a custom error page if connection to the database fails.
Like:
If(no connect){
header("location: error.php");
}

Just need the "no connect" part I guess.

View Replies !
Stupid Zip Code Fields
I have two zip code fields, for example 34214-2243
zip zipx

For my mysql table its
zip smallint(5) unsigned not null
zipx smallint(4) unsigned not null

--------
Now when I enter a value into these fields , lets say
34214 and 2243 --------it works fine!! fine! it stores those EXACT values.
BUTT now lets say I enter 02445 and 0145 it doesn't work!
it only stores the values 2445 and 145
Why does it knock off the 0?!?!
I've been stumped on this problem for the last hr or so and I can't seem to find it anywhere, not even in the mysql doc

View Replies !
Does Table Exist Code?
I ran across this code to check if a table exists. I'm thinking there has to be a better way...maybe something like DoesTableExist("MyTable") = true or false.

Comments?

global $exists;
$exists = 0;
$dataset = mysql_query('SHOW TABLES') ;
while( $row = mysql_fetch_row($dataset) )
{
if ( $row[0] == "mos_tbd_tags" ) {
$exists = 1;
break;
}
}

View Replies !
Separate Area Code
Is it possible in MySQL to separate the area code from a field that has the complete phone number?

phone
666.666.6666

I'd like to have the fields as
area
666

phone
666.6666

View Replies !
Generate A Unique Code
Did someone know how to generate a unique code with Mysql custom function?
ex: a1254174, b41514741.

I'm plan design a shop site with PHP.
I wanna try to generate a Product Code with Mysql not use PHP.

View Replies !
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.

View Replies !
How To Find Percentage Of Code In Sql
There are 17 codes with 30000 records.Want to know the % of each code occurence.

View Replies !
I Need To SQL Code To Add Permission To A User
I want to add permission to both create, alter and execute store procedures to a user that don't have this permissions.

View Replies !
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?

View Replies !
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?

View Replies !
Code To Determine Date?
ive been using code to extract info from a database at the end of each week, and it works fine. the only issue is i have to go in at the end of every week and change the dates before i run the code, i would love to have it automated so that it would pick up that i needed the info from the past 7 days...

heres the code that im using

SELECT
(SUM(t1.timespent) /60) ,
(SUM(t1.timebillable) /60 ) ,
MAX(t4.title) ,
FROM_UNIXTIME(t1.dateline)
FROM swtickettimetrack AS t1
LEFT JOIN swtickets AS t2 ON (t1.ticketid = t2.ticketid)
LEFT JOIN swusers AS t3 ON (t2.userid = t3.userid)
LEFT JOIN swusergroups AS t4 ON (t3.usergroupid = t4.usergroupid)
LEFT JOIN swstaff AS t5 ON (t1.forstaffid = t5.staffid)
WHERE t1.dateline >= UNIX_TIMESTAMP('2008-07-01') and t1.dateline <= UNIX_TIMESTAMP('2008-07-31') AND t4.title<>''
GROUP BY t4.usergroupid

View Replies !
Error Code 2002
I am taking an online course and the first thing to do is to download mysql. I followed the instructions, but when it came time to choose which version of mysql to download for your computer, I really didn't know which one to pick, so I sort of guessed. I have a mac book pro and when i go into "about this mac" on my computer it says I have a mac os x 10.5.5 running on a 2.4 GHz Intel Core 2 Duo Processor. I'm not even sure which version I clicked on to download since I wasn't sure between the 32 bit and the 64 bit but I had problems running the MySQL Administrator program (kept closing out on me during certain tasks) so I assume I downloaded the wrong version.

Here's where things get kooky: I tried to delete the version of mysql that I had on my computer stupidly by running a search and pretty much trashing everything that said "mysql" on it from the xampp folder. But mySQL was still there in my computer's system preferences, only now it refuses to run, obviously because I deleted all the files. I've tried following the instructions and downloading again but I keep getting error code 2002 when I go to open mySQL admin saying "mySQL could not connect local host. Error can't connect to local mySQL server through socket". I am at my wits end and I haven't even started yet!! How do I download the CORRECT version of mySQL and do a complete reinstall,

View Replies !
Code Coverage Tool
I am working on MySQL as well Oracle database. But I did not find any code coverage tool for mysql. In oracle, we use DBMS_PROFILER to get the code coverage.

Is any similar tool available in MySQL or not?

View Replies !
Status Code: 0 Error
I have been using mysql on my localhost wamp server for a while. After modifying some php files with new mysql queries, I occasionally get the following error message, even though the data is retrieved without problem from the database:

“problem retrieving data from server, status code: 0â€Â

View Replies !
Error Code : 1064
I am trying to create procedure in MySql4.1.22 but it is throwing the below error
Error Code : 1064
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 'PROCEDURE simpleproc (IN param int,OUT param1 INT)

For creating procedure i am using below syntax. Please help me on this issue.

CREATE PROCEDURE simpleproc (IN param int,OUT param1 INT)
BEGIN
END;

View Replies !
CHANGE CODE FOR SEARCH
I have a search box on my site which works fine but I would like to improve.
at the moment it will not return a result for a two word search unless those words are adjacent ie red box but not for return for red big box
I would like to make it give results for multiple word searches when the

words are found
In this order

all words in search adjacent
all words in search (not neccesarily adjacent)
any of the words

I assume the following tells it what to look for and how to display results (I hope so any way)

if ($_GET["page"]=='search')
{
$sql="SELECT C.category_description,C.category_name,A.article_title,A.article_author,A.article_snippet,A.article_category_id,A.article_id,A.article_views FROM article_master A,category_master C where A.article_category_id=C.category_id and C.category_status=1 and A.article_status=1 and (A.article_title like '%".$_GET["q"]."%' OR A.article_snippet like '%".$_GET["q"]."%' OR A.article_summary like '%".$_GET["q"]."%')order by A.article_title asc";
$cmdartcat = mysql_query($sql);
$metatitle="Search Results For ".$_GET["q"]; .

View Replies !
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?

View Replies !
Error In SQL Syntax Code
My code

<?php

include ("includecon.php");

$tg= $_POST['id'];
$names= $_POST['nama'];
$adds= $_POST['adda'];
$tels= $_POST['tela'];
$emails= $_POST['emaila'];

$db = mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db ($db_name) or die ("Cannot connect to database");

$query = "UPDATE addressbook SET name='$names', add='$adds', tel='$tels', email='$emails' WHERE id = '$tg'";
mysql_query($query) or die ("Error in query: $query. " . mysql_error());


mysql_close($db);
echo "OK";
?>


and i'm getting this error :
Error in query: UPDATE addressbook SET name='fgsfgs', add='tyu', tel='245646', email='dadgadgadg' WHERE id = '2'. You have an error in your SQL syntax near 'add='tyu', tel='245646', email='dadgadgadg' WHERE id = '2'' at line 1

View Replies !
Import Logic Code
I have been using PHPmyadmin to do daily imports...

1. empty the table...
2. import the text file

I'd like to FTP all my files up and then create a statement that will

do this for several tables...

This will both automate the process and enable to deal with a SSH ftp connection instead of the 'clear' phpmyadmin...

Can anyone point me to a resource for this logic OR a way to grab what PHPmyadmin is doing????

View Replies !
Adding Table With PHP Code ?
If I use a constant rather than a variable, it works. Can anyone tell me why this doesn't work? I'm running this on a RH9.0 with PHP 4 and MYSQL 3.23.54. Code:

View Replies !
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.

View Replies !
Code To Pull Amount
I'm certain there is a function to do this but I forget what it is...
Say I am pulling values from the database, but I only want to pull like the first 10 chars of the value.. how do I do that?

View Replies !

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