So I’ve been trying to insert sql into this one specific table for the past three hours and I think I’m starting to go insane. I’ve isolated things I think could be the problem, although if you want more information feel free to ask
Essentially I currently have two sql tables: concepts and FUideas (I got really frusturated with it) which are stored in the same database. When I run the following code:
$con = mysql_connect('localhost', 'username', 'password');
mysql_select_db("my_db", $con);
$sql = "INSERT INTO `concepts` (description) VALUES ('HAI THAR')";
mysql_query($sql,$con);
It inserts a row into concepts, but when i run this code:
$con = mysql_connect('localhost', 'username', 'password');
mysql_select_db("my_db", $con);
$sql = "INSERT INTO `FUideas` (description) VALUES ('HAI THAR')";
mysql_query($sql,$con);
It does nothing. And just to further mess with your head: if you execute this in phpMyAdmin tab:
INSERT INTO `FUideas` (description) VALUES ('HAI THAR')
it works!?!?!
PLEASE ANY IDEAS, CODE, HACKS? I’M DESPERATE! If you have any hunch or clues tell me and I’ll try it and report back with the results
EDIT
PHP Myadmin dump of how to create tables:
-- phpMyAdmin SQL Dump
-- version 3.3.9
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jul 04, 2011 at 11:21 AM
-- Server version: 5.0.91
-- PHP Version: 5.2.9
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
/*!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 */;
CREATE TABLE concepts (
id int(10) unsigned NOT NULL auto_increment,
title tinytext NOT NULL,
`user` tinytext NOT NULL,
`date` int(10) unsigned NOT NULL default '0',
summary tinytext NOT NULL,
description text NOT NULL,
tags tinytext NOT NULL,
ip tinytext NOT NULL,
appreciates tinyint(3) unsigned NOT NULL default '4',
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- phpMyAdmin SQL Dump
-- version 3.3.9
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jul 04, 2011 at 11:23 AM
-- Server version: 5.0.91
-- PHP Version: 5.2.9
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
/*!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 */;
--
-- Table structure for table 'FUideas'
--
CREATE TABLE FUideas (
id int(10) unsigned NOT NULL auto_increment,
`user` tinytext NOT NULL,
`date` int(10) unsigned NOT NULL default '0',
description text NOT NULL,
upvotes text NOT NULL,
downvotes text NOT NULL,
appreciated tinyint(3) unsigned NOT NULL default '0',
ip tinytext NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
FINAL UPDATE
For anyone else looking at this problem, it turns out that I had old code running at the same time which was creating the errors and inconsistencies.
Try thiS:
If there is a problem with the query (syntax error, or a key violation, etc…), then the die() call will spit out the error message describing the problem.