mysql

getting wrong IP address in php

i have following php code to get vistor ip function VisitorIP() { if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $TheIp=$_SERVER['HTTP_X_FORWARDED_FOR']; else $TheIp=$_SERVER['REMOTE_ADDR']; return trim($TheIp); } $Users_IP_address = VisitorIP(); but every time i execute this script on my localhost i got ::1 as IP how c...

Delete a Crashed Innodb table

Hi, I cannot delete/drop a crashed Innodb table. I get the following error: ERROR 1051 (42S02): Unknown table ‘accounts’ And if I want to create it I get the following error: ERROR 1005 (HY000): Can’t create table ‘accounts’ (errno: -1) This happens on my server after an accidental power failure. Regards ...

Question about Database structure

I am creating a simple customer support tracking system with PHP/MySQL Fuctions are followings. An admin can CRUD an customer. An admin can add points/credits.: 60points (60min) etc An admin can enter the work details, date, time duration, points and display these and point(time) remaining. The question is how to structure the table...

MySql Full text Search

In my Job listings site, I need to show jobs which have similar titles to the one which is being viewed. I am trying the following query, but its not working: SELECT *, MATCH(title) AGAINST "Sales Coordinator" as relevance FROM jobs WHERE MATCH(title) AGAINST "Sales Coordinator" ORDER BY relevance DESC LIMIT 100 Also, can this b...

Need help writing a SQL query

Im an SQL noob. Heres my situation. I have the following tables. Customer_table Customer_ID | Last name | First Name | City_ID | Region_ID | Country_ID Country_table Country_ID | Country Region_table Region_ID | Region | Country_ID City_table City_ID | City | Region_ID | Country_ID I need to find the number of cus...

Session questions

Hi, I am having trouble in understanding of how I need to do this: Have list of items on my home page and when users click on that, I take them to a page where i ask for name and email id(both are optional fields) and when users hit submit, I will take them to other page where they get to see all the details. the reason for that name ...

set permissions on users mysql with wildcard?

normally one would say: GRANT ALL PRIVILEGES ON . TO 'monty'@'%' Can we use a wildcard where we can target specific databases only like this: GRANT ALL PRIVILEGES ON SHOP%.* TO 'monty'@'%' We would like to give insert privileges to a user on databases that start with prefix "SHOP" ...

Perl/MySQL "Query was empty" error, probably multithreading-related

I am writing a program to extract data from a bunch of text files and stuff it into DB. All of my commands currently have the form similar to this (with different queries): $query = "INSERT INTO relations (relation_type_id, confidence) VALUES ($reltypeid, $conf)"; print "$query\n"; $result = $conn->query($query); $relid = $result->inser...

How To Programmatically Create MySQL Databases on Shared Linux Hosting Plans

Is there a sort of reliable way to programmatically create MySQL databases and MySQL users on shared Linux hosting plans from a PHP page? For instance, accessing cpanel or phpmyadmin through an API or hook if I know my cpanel access information and/or my FTP information? Occasionally I see this with some sites and products but don't kno...

Neither LOAD DATA LOCAL..REPLACE or INSERT..ON DUPLICATE are working. Something wrong with my table structure?

I'm loading files into a table with php. I create a table like this: CREATE TABLE IF NOT EXISTS $table ( `id` INT AUTO_INCREMENT PRIMARY KEY, `order` INT DEFAULT 0, `data` VARCHAR(200) UNIQUE KEY, `cur_timestamp` TIMESTAMP DEFAULT NOW())" And fill it from a text file like this: LOAD DATA LOCAL INFILE '".$file ."' REPLACE INTO TABLE...

Copying Mysql data to a remote server

I am running mysql server on my computer.I would like to copy the databases i have created and their tables to a remote server,and that is my website.Is there a software(a windows software) that can help me copy my databases to a remote server?. ...

Streamline and make form/crud operations more efficient in web applications?

Hi everybody, When looking back at last weeks work (identical to many others), I've found myself spending the major part of my time putting together forms of which POST-data are used to perform database CRUD operations through my MVC-models. When reflecting over this, it becomes a bit worrying. It's not really appropriate to spend the ...

Creating custom "html"-tags for CMS?

Hi everybody, I am working with a CMS for a web app in PHP, that has the needs of shortening the process for inserting (embedding) stuff, like a video from youtube or vimeo by wroting the following, which are stored in the database: <youtube id="wfI0Z6YJhL0" /> Which would output the following after some sort of replace: <!-- Custom...

How to filter (or replace) unicode characters that would take more than 3 bytes in UTF-8?

I'm using Python and Django, but I'm having a problem caused by a limitation of MySQL. According to the MySQL 5.1 documentation, their utf8 implementation does not support 4-byte characters. MySQL 5.5 will support 4-byte characters using utf8mb4; and, someday in future, utf8 might support it as well. But my server is not ready to upgrad...

Error Code 1064 MySQL

I need to know what i am doing wrong right now in this. Can someone tell me how to fix it? mysql>host/"localhost"; mysql>port=3306; database=ml username=**** password=******** clientamount=30; I need to know how to fix the first line can anybody tell me? ...

Help with sql query

Have 2 table 1st {id_city,name } 2nd table {id_ctz,name,sname,age,id_city} need selected full information (name(city),name,sname,age) people with same name accending by age? Have tried: select city.name,citizen.name,age from citizen,city where city.id_city = citizen.id_city and citizen.name = '%s' order by age asc input vari...

How to update a counter for a resultset

Hi, i'm creating something similar to an advertising system. I would like to show, for example, 5 ads (5 record) from a given database table. So i execute something like SELECT * FROM mytable ORDER BY view_counter ASC LIMIT 5 ok, it works. But, how can contextualy update the "view_counter" (that is a counter with the number of sh...

Need to add LF to thousands of MySQL MEDIUMTEXT fields

I need to add a \n or LF or ASCII(x'0A') or however you want to encode it to the end of several thousand MySQL MEDIUMTEXT fields. I tried update wp_posts set post_content = concat(post_content,ASCII(x'0A')); but nothing is modified in the field as far as I can see. I suspect this is a limitation of MEDIUMTEXT/LONGTEXT fields, but it wo...

Validate status of URLs in a mysql Database using CURL and shell script.

Good day, I have a simple MySQL database with 1 table and 3 fields Table: LINKS Fields: ID URL STATUS The table has about 3 millions links. I would like to check all the URLs and post their returned status in the status field so that I can remove the dead links later. This would probably require a shell script because it will nee...

Hibernate 3.5.1, JPA2.0 & MySQL - Alternate behaviour within 2 diff dbs / same server

I am running a MySQL 5.1 server and Hibernate 3.5.1 / JPA2 for ORM. Everthing seems fine until I drop some tables manually. From then on, unit tests fail with Hibernate no longer creating certain tables. Changing the jdbc url from url=jdbc:mysql://localhost:3306/dbjava?createDatabaseIfNotExist=true to url=jdbc:mysql://localhost:3306...