mysql

Php Echo Concatenation

I have a huge table to put in the while loop, but i'm finding it difficult to concatenate it. How can I add multilines with more ? <?php $dbhost = 'xxxx'; $dbuser = 'xxxx'; $dbpass = 'xxxx'; $dbname = 'xxxx'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname, $conn); $resul...

What does MySQL do when auto incrementing IDs overflow?

I have a django app that uses MySQL as the database backend. It's been running for a few days now, and I'm up to ID 5000 in some tables already. I'm concerned about what will happen when I overflow the datatype. Is there anyway to tell the auto increment to start over at some point? My data is very volatile, so when I do overflow the ...

Split data into two columns using CSS

What I wanna create is page that fetches results from my DB and display them into two columns like this using CSS (unless theres a better way)... Row 1 | Row 6 Row 2 | Row 7 Row 3 | Row 8 Row 4 | Row 9 Row 5 | Row 10 The second column should be empty if theres no more than 5 rows. ...

Installing python-mysql with wamp's mysql

Hello, (I'm not sure if this should be asked here or SU.. but seeing this question on SO, I am asking it here...) I have wamp (mysql-5.1.33) server setup on my vista machine, and I am trying to install python-mysql 1.2.3c1 to use the mysql version provided by wamp. At first, when I ran python setup.py install, I got an error saying it...

MySQL update a sorting index column to move items

If I have the following table & data to allow us to use the sort_index for sorting: CREATE TABLE `foo` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `bar_id` INT(11) DEFAULT NULL, `sort_index` INT(11) DEFAULT NULL, PRIMARY KEY (`id`) ); INSERT INTO `foo` (`bar_id`, `sort_index`) VALUES (1,1),(1,2),(1,3),(1,4), (2,1),(2,2),(2,3),(2...

how to convert query result to formatted string for google chart API

Hi all I have the results of a query on a wordpress site. The query results are::- h COUNT( * ) 0 7 1 5 2 2 The query is something like this this:- $sql = 'SELECT HOUR( `post_date` ) AS h, COUNT( * )' . ' FROM `wp_7tv8g5_posts`' . ' WHERE DATE( `post_date` ) = DATE( NOW( ) ) AND `guid`like \'%/questions/%\'' ...

correlated subquery update

I have decided in my table that I no longer want to record start and finish times, but rather just a start time and a duration in minutes. How can I update my table so that my new column has its values inserted based on the existing data? my attempt below yields the error: You can't specify target table 'lesson' for update in FROM c...

MySQL: Can stored procedure information be extracted from the information schema?

Is it possible to retrieve stored procedure information like name, parameter nane/position/type from the Information Schema in MySQL or possible in some other way? ...

I like the 70's, but that's just not right (PHP Time question)

So I'm storing a hidden-field time() call with each entry to my DB. The only problem is, they all come out as: 16777215 which is from 1970. I can't tell why that number, because it's not the beginning or end of the current timestamp, and it's the same for every entry. It's going into a mediumint(50) MySQL column, and the field looks as...

MySQL: is checking for new records by values of auto_increment column bad?

I'm making a web application which also includes notification functionality - a user may get one or more notifications (messages) from the system or other users at any time. When there are new (unread) messages they will be displayed to the user in a popup window. The messages will be short (most of the time one sentence each, and only ...

mysql trigger stored trigger is already used by statement which invoked stored trigger

Hi, I want to set up a trigger so that if on an update the prediction field is = 3 then the trigger changes the value to 4 and saves it in the database. The trigger is below. For some reason I keep getting an error saying: "#1442 - Can't update table 'tzanalytic_forecast_cached' in stored function/trigger because it is already used by...

sql query - calculating commission over 12 months

I'm trying to write a query to work out how much commission that my client's company earns in a month as below SELECT (rate * SUM(duration) / 180) as commission FROM teacher, person, lesson WHERE person.id = teacher.person_id AND lesson.teacher = person.id AND MONTH(start_time) = MONTH(NOW()) ...

How do I parse XML responses from google checkout?

I have seen the XML response from google checkout when an order is processed here. I have also seen the google responsehandlerdemo.php file which I've copied below. I cannot figure out where I am supposed to insert the code that I will use to update the inventory levels on my shop. Can someone point me there? I also am not quite sure h...

Friend relationship query

I have the following tables: USERS table id username email password status FRIENDS table id user_id friend_id created To find a users friends, I use: SELECT f.friend_id, u.username FROM friends f JOIN friends m ON m.user_id = f.friend_id AND m.friend_id = f.user_id JOIN users u ON u.user_id = f.fr...

mysql syntax error

I wrote this simple query statement: INSERT INTO merchants ('firstName','lastName') VALUES ('Bob','Smith') Sounds very simple but I keep getting this error: `#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 ''firstName','lastName' ) VALU...

How to check if a value is listed in a database using MySQL and PHP?

I was wondering how can I check to see if a web page is listed in a database and if its not add it to the database. How can I do this using PHP and MySQL. Sorry if I'm vague I'm new to PHP and MySQL. ...

PHP MySQL inserting data to multiple tables

Hi, I'm trying to make an experimental web application which minimises redundant data. I have three example tables set up like so: Table one ID | created_at (unix timestamp) | updated_at (unix timestamp) Table two ID | Foreign Key to table one | Title Table three (pages) ID | Foreign Keys to both table one and two | Content | Metadata...

Apache, PHP and MySQL portable?

Hi, can I run Apache, PHP and MySQL on a External HD? I need this because I work in diferent computers, and sometimes I don't have installed and configured all aplications for use. ...

PHP and MySql hitcounter problem?

Okay I'm new to php and mysql I tried to build a web page hit counter but my page counter dosen't update correctly and it gets the following warnings listed below. Warning: mysqli_query() expects at least 2 parameters, 1 given in Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in Here is the php code ...

problem with $_SERVER['PHP_SELF']

I have a link in one of my php pages where the friends of the logged in user are shown and there is a link like below for each of user's friends like this in this page: echo "<a href='profile.php?id=$row[friend_id]'>$friend_row[name]</a>"; and as you can see the friend's ID is passed to the profile page and in profile page the user ca...