MYSQL ERROR when trying a dump - php

I am trying to install an older version of Joomla 1.5 on my server, my host has worked with me to allow 1.5 to install without error, however one of the issues is i need to do a mysql dump of the database, when i attempt to dump the database into the website i get the following error.
Error SQL query:
CREATE TABLE `jos_banner` ( `bid` int(11) NOT NULL auto_increment, `cid` int(11) NOT NULL default '0', `type` varchar(90) NOT NULL default 'banner', `name` text NOT NULL, `alias` varchar(255) NOT NULL default '', `imptotal` int(11) NOT NULL default '0', `impmade` int(11) NOT NULL default '0', `clicks` int(11) NOT NULL default '0', `imageurl` varchar(100) NOT NULL default '', `clickurl` varchar(200) NOT NULL default '', `date` datetime default NULL, `showBanner` tinyint(1) NOT NULL default '0', `checked_out` tinyint(1) NOT NULL default '0', `checked_out_time` datetime NOT NULL default '0000-00-00 00:00:00', `editor` varchar(150) default NULL, `custombannercode` text, `catid` int(10) unsigned NOT NULL default '0', `description` text NOT NULL, `sticky` tinyint(1) unsigned NOT NULL default '0', `ordering` int(11) NOT NULL default '0', `publish_up` datetime NOT NULL default '0000-00-00 00:00:00', `publish_down` datetime NOT NULL default '0000-00-[...]
MySQL said: Documentation
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 'TYPE=MyISAM AUTO_INCREMENT=6' at line 29
Can anyone help me so i may correctly import the data?
Thanks again stackers.

Probably your MySQL version is new enough that it doesn't recognize the older "TYPE" keyword and is instead expecting "ENGINE". Try editing your SQL file and replacing TYPE with ENGINE in that line and see if it imports (or, at least, the error message changes). You can make that change in a text editor (which hopefully has good search-and-replace functionality to make it easy to find any other occurrences -- but don't just blindly replace them all in case your data contains the term).
As Action Dan requested, knowing the MySQL version would help. It's displayed on the main phpMyAdmin page.
Also, just a little note, "dump" is when you export from a database; as far as I know there's no analogous term for importing (but you don't dump in to a database, only out).

Try this code the mistake you have done is you have defined default value 0 in like this '0'
CREATE TABLE `jos_banner`(
`bid` int(11) NOT NULL auto_increment primary key,
`cid` int(11) NOT NULL default 0,
`type` varchar(90) NOT NULL default 0, `name` varchar(255) NOT NULL ,
`alias` varchar(255) NOT NULL default 0, `imptotal` int(11) NOT NULL default 0,
`impmade` int(11) NOT NULL default 0, `clicks` int(11) NOT NULL default 0,
`imageurl` varchar(100) NOT NULL default 0, `clickurl` varchar(200) NOT NULL default 0, `date` datetime default NULL, `showBanner` tinyint(1) NOT NULL default 0,
`checked_out` tinyint(1) NOT NULL default 0, `checked_out_time` datetime NOT NULL default '0000-00-00 00:00:00', `editor` varchar(150) default NULL, `custombannercode` varchar(255), `catid` int(10) unsigned NOT NULL default 0, `description` text NOT NULL, `sticky` tinyint(1) unsigned NOT NULL default 0, `ordering` int(11) NOT NULL default 0, `publish_up` datetime NOT NULL default '0000-00-00 00:00:00', `publish_down` datetime NOT NULL default '0000-00-00 00:00:00')

Related

mysql query error on my live server which I don't get on my test version of MySQL

Error
Could not successfully run query (SELECT * FROM prior_approval WHERE id = \'187\') from DB:
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 '\'187\'' at line 2
PHP code:
$sql9 = "UPDATE prior_approval SET approved = 1, rejected = 0 WHERE id= '" . mysql_real_escape_string($app_id) . "'";
$result9 = mysql_query($sql9) or die(mysql_error());
The test MySQL version is 5.6 and the live version is 5.1. An error message on the ISP's control panel says that the mysql version should be updated.
I have used mysqli as well but that failed so I reverted to mysql
using mysqli code:
$app_id = $_SESSION['app_id'];
$conn = mysqli_connect('localhost',$username,$password,$database);
$sql9 = "UPDATE prior_approval SET approved = 1, rejected = 0 WHERE id= (?)";
$stmt = $conn->prepare($sql9);
$stmt->bind_param('i',$app_id);
$result9 = $stmt->execute();
Resulting error:
Could not successfully run query (SELECT * FROM prior_approval WHERE id = \'187\') from DB: 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 '\'187\'' at line 2
New error including vardump:
string(7) "\'187\'"
Could not successfully run query (SELECT * FROM prior_approval WHERE id = \'187\') from DB: 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 '\'187\'' at line 2
Table create:
CREATE TABLE IF NOT EXISTS `prior_approval` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`approv_id` int(6) DEFAULT NULL,
`dist_code` varchar(30) DEFAULT NULL,
`dealer_code` varchar(30) DEFAULT NULL,
`reporter` varchar(50) DEFAULT NULL,
`report_date` date DEFAULT NULL,
`job_kind` int(1) DEFAULT NULL,
`attach` int(1) DEFAULT NULL,
`reply` tinyint(1) DEFAULT NULL,
`engine_oil` int(1) DEFAULT NULL,
`nature_code` varchar(50) DEFAULT NULL,
`model` varchar(10) DEFAULT NULL,
`causal_code` varchar(50) DEFAULT NULL,
`part_code` varchar(20) DEFAULT NULL,
`part_descr` varchar(20) DEFAULT NULL,
`op_code` varchar(20) DEFAULT NULL,
`subject` varchar(50) DEFAULT NULL,
`reg_no_1` varchar(20) DEFAULT NULL,
`vin_1` varchar(17) DEFAULT NULL,
`engine_1` varchar(10) DEFAULT NULL,
`reg_date_1` date DEFAULT NULL,
`km_reading_1` varchar(10) DEFAULT NULL,
`repair_date_1` date DEFAULT NULL,
`repl_no_1` varchar(20) DEFAULT NULL,
`complaint_nature` varchar(1000) DEFAULT NULL,
`sub_repair` varchar(1000) DEFAULT NULL,
`corr_action` varchar(1000) DEFAULT NULL,
`act_result` varchar(1000) DEFAULT NULL,
`recommend` varchar(1000) DEFAULT NULL,
`compl_period` varchar(10) NOT NULL,
`compl_number` int(11) NOT NULL,
`compl_freq` int(11) NOT NULL,
`while_stopped` tinyint(1) NOT NULL,
`during_braking` tinyint(1) DEFAULT NULL,
`during_acc_coast` tinyint(1) DEFAULT NULL,
`during_forward_rev` tinyint(1) DEFAULT NULL,
`during_turn` tinyint(1) DEFAULT NULL,
`turn_speed` int(11) DEFAULT NULL,
`during_rough` tinyint(1) DEFAULT NULL,
`rough_gear` varchar(10) DEFAULT NULL,
`during_decl_incr` tinyint(1) DEFAULT NULL,
`during_any_speed` tinyint(1) DEFAULT NULL,
`during_decel_coast` tinyint(1) DEFAULT NULL,
`using_brake` tinyint(1) DEFAULT NULL,
`using_ac` tinyint(1) DEFAULT NULL,
`using_defog` tinyint(1) DEFAULT NULL,
`using_steer` tinyint(1) DEFAULT NULL,
`using_wwash` tinyint(1) DEFAULT NULL,
`using_starter` tinyint(1) DEFAULT NULL,
`using_clutch` tinyint(1) DEFAULT NULL,
`using_radio` tinyint(1) DEFAULT NULL,
`using_other` tinyint(1) DEFAULT NULL,
`engine_idle` tinyint(1) DEFAULT NULL,
`engine_hot` tinyint(1) DEFAULT NULL,
`engine_start` tinyint(1) DEFAULT NULL,
`engine_cold` tinyint(1) DEFAULT NULL,
`engine_warm_up` tinyint(1) DEFAULT NULL,
`vary_car_speed` tinyint(1) DEFAULT NULL,
`vary_engine_speed` tinyint(1) DEFAULT NULL,
`vary_load` tinyint(1) DEFAULT NULL,
`vary_trunk_load` tinyint(1) DEFAULT NULL,
`how_always` tinyint(1) DEFAULT NULL,
`how_after` tinyint(1) DEFAULT NULL,
`after_speed` int(11) DEFAULT NULL,
`attach1` varchar(100) DEFAULT NULL,
`attach2` varchar(100) DEFAULT NULL,
`attach3` varchar(100) DEFAULT NULL,
`date_created` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`date_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`approved` tinyint(1) NOT NULL,
`rejected` tinyint(1) DEFAULT NULL,
`rejected_reason` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=186 ;
I had to convert the $app_id string to integer like this:
//$app_id = $_SESSION['app_id'];
$remove[] = "'";
$remove[] = "\\";
$app_id = (int)str_replace($remove,"", $_SESSION['app_id']);
The later version of MySQL seems to convert automatically.

MySQL indexes stop working

I am working on News website, the table (news) contain about 200,000 rows.
I use Zend framework 1.
the website was working very good, but from a week ago, I have found some errors in data retrieve from the queries.
I use zend paginator, like this:
$paginator = Zend_Paginator::factory($select);
$paginator->setItemCountPerPage(10);
$pageCounter = $paginator->count();
so $pageCounter return 0,
when I try to debug the error, I have tried to drop the indexes from the database table and create the index again, then the problem was resolved the website back to work again.
but every couple days this problem back again.
the tables I use is:
CREATE TABLE `news` (
`news_id` int(11) NOT NULL AUTO_INCREMENT,
`category_id` int(11) DEFAULT NULL,
`news_type` enum('text','photo','video') DEFAULT 'text',
`news_title` varchar(255) NOT NULL,
`news_url` varchar(255) NOT NULL,
`news_date` datetime NOT NULL,
`news_image` varchar(255) DEFAULT NULL,
`video` varchar(255) DEFAULT NULL,
`news_source` int(11) NOT NULL DEFAULT '0',
`author_id` int(11) NOT NULL DEFAULT '0',
`news_brief` text,
`news_content` mediumtext,
`meta_title` varchar(255) NOT NULL,
`meta_description` varchar(255) DEFAULT NULL,
`meta_keywords` varchar(255) DEFAULT NULL,
`status` tinyint(2) NOT NULL DEFAULT '1',
`news_read` int(11) DEFAULT '0',
`old_id` int(11) DEFAULT NULL,
`old_section_id` int(11) DEFAULT NULL,
`old_section` varchar(50) DEFAULT NULL,
`lang` varchar(10) DEFAULT NULL,
`featured` int(11) NOT NULL DEFAULT '0',
`in_timeline` tinyint(2) NOT NULL DEFAULT '0',
`is_highlight` tinyint(2) NOT NULL DEFAULT '0',
`home_exclusive` tinyint(2) NOT NULL DEFAULT '0',
`home_articles` tinyint(4) NOT NULL DEFAULT '0',
`home_articles_selected` tinyint(4) NOT NULL DEFAULT '0',
`home_mostread` tinyint(4) NOT NULL DEFAULT '0',
`video_featured` tinyint(4) NOT NULL DEFAULT '0',
`photos_featured` tinyint(4) NOT NULL DEFAULT '0',
`party_featured` tinyint(4) NOT NULL DEFAULT '0',
`party_activity` tinyint(4) NOT NULL DEFAULT '0',
`sport_featured` tinyint(4) NOT NULL DEFAULT '0',
`fnoun_featured` tinyint(4) NOT NULL DEFAULT '0',
`special_reports` tinyint(4) NOT NULL DEFAULT '0',
`mainnav` tinyint(4) NOT NULL DEFAULT '0',
PRIMARY KEY (`news_id`),
KEY `News_Category_idx` (`category_id`),
KEY `News_Type` (`news_type`),
KEY `News_Date` (`news_date`),
KEY `News_Read` (`news_read`),
KEY `old_id` (`old_id`),
KEY `Sources` (`news_source`),
KEY `Authors` (`author_id`),
KEY `Featured` (`featured`),
KEY `Articles` (`home_articles`),
KEY `Mostread` (`home_mostread`),
KEY `video_featured` (`video_featured`,`photos_featured`),
KEY `party_activity` (`party_activity`),
KEY `sport_featured` (`sport_featured`,`fnoun_featured`),
KEY `old_section_id` (`old_section_id`),
KEY `old_section` (`old_section`),
KEY `old section id` (`old_section_id`),
KEY `old section` (`old_section`),
KEY `articles_selected` (`home_articles_selected`),
KEY `URL` (`news_url`),
KEY `special_reports` (`special_reports`),
KEY `mainnav` (`mainnav`),
KEY `status` (`status`),
KEY `in_timeline` (`in_timeline`),
KEY `is_highlight` (`is_highlight`),
KEY `home_exclusive` (`home_exclusive`),
KEY `party_featured` (`party_featured`),
FULLTEXT KEY `news_title` (`news_title`)
) ENGINE=InnoDB AUTO_INCREMENT=167614 DEFAULT CHARSET=utf8
the columns (status - featured - in_timeline - is_highlight) type was (ENUM) but I have changed to (tinyint)
It works for a few days, but the problem come back again.
so I have to drop the indexed and create it again.
I don't know what is the problem?
can anyone help, please.
The Explain Query, it's the same when the problem happen and after I drop the indexes and create it again.
SQL query: Explain SELECT `N`.`news_id`, `N`.`news_title`, `N`.`news_url`, `N`.`news_image`, `N`.`news_type`, `N`.`news_date`, `N`.`is_highlight`, `N`.`news_brief`, `C`.`category_name`, `C`.`category_url`, `C`.`category_color`, `NT`.*, GROUP_CONCAT(T.tag_name separator ",") AS tags, GROUP_CONCAT(T.tag_url separator ",") AS `tags_urls` FROM `news` AS `N` INNER JOIN `news_categories` AS `C` ON C.category_id = N.category_id AND C.status = "1" LEFT JOIN `news_tags_relation` AS `NT` ON NT.news_id = N.news_id LEFT JOIN `news_tags` AS `T` ON T.tag_id = NT.tag_id WHERE (N.status = "1" AND N.category_id = "22") GROUP BY `N`.`news_id` ORDER BY `N`.`news_date` DESC;
Rows: 4
This table does not contain a unique column. Grid edit, checkbox, Edit, Copy and Delete features are not available.
the table in the attached images

MySQL Stored Procedure [Copy table 1 -> table 2]

My knowledge of MySQL/ SQL apart from the simple CRUD operations is basic.
If I had to use a stored procedure to move certain attributes (not in a specific order) to another table how could it be done?
These are the following tables. I want to move from the 1st to the 2nd table.
As you can see the datatype sizes are different for certain columns.
CREATE TABLE IF NOT EXISTS `source_cdr` (
`callstart` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`src` varchar(80) NOT NULL DEFAULT '',
`dst` varchar(80) NOT NULL DEFAULT '',
`accountcode` varchar(50) NOT NULL,
`uniqueid` varchar(100) NOT NULL,
`ID` int(11) NOT NULL AUTO_INCREMENT,
`callanswer` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`callend` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`disposition` varchar(50) NOT NULL,
`cdr_id` int(11) unsigned NOT NULL DEFAULT '0',
`pin_code` varchar(4) NOT NULL,
`provider` int(11) NOT NULL,
PRIMARY KEY (`ID`),
KEY `calldate_idx` (`callstart`) USING BTREE,
KEY `idx_acc_code_calldate` (`accountcode`,`callstart`) USING BTREE,
KEY `uniqueid` (`uniqueid`),
KEY `cdr_id` (`cdr_id`),
KEY `idx_uniqueid_cdr_id` (`uniqueid`,`cdr_id`)
) ENGINE=MyISAM;
--
CREATE TABLE IF NOT EXISTS `destination_cdr` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`calldate` datetime NOT NULL,
`source` varchar(80) NOT NULL,
`destination` varchar(80) NOT NULL,
`account_code` varchar(30) DEFAULT NULL,
`pincode` varchar(45) NOT NULL,
`duration_call` bigint(20) NOT NULL DEFAULT '0',
`duration_talk` bigint(20) NOT NULL,
`disposition` varchar(255) NOT NULL,
`clid` varchar(80) DEFAULT NULL,
`cdr_id` bigint(20) DEFAULT NULL,
`vxcdr_id` bigint(20) DEFAULT NULL,
`provider` int(11) NOT NULL DEFAULT '0'
PRIMARY KEY (`id`)
) ENGINE=MyISAM;
EDIT 1
An example of a row
('2012-03-18 20:54:49', '5796', '0761100866', '103f0124ad510516f33cab132c0a695b', 'call-F1884808-6753-2F10-181C-3A#10.217.164.33', 308006367, '2012-03-18 20:55:05', '2012-03-18 20:55:51', '200 OK', 2, '', 0),
Thanks
You can use MySQL: INSERT ... SELECT Syntax to copy data from one table to the other.
Decide common fields in both and copy the same.
Example:
INSERT INTO TABLE2( COL1, COLx, ... ) SELECT colM, colY FROM TABLE1;
If the column sizes mismatch, data truncation takes place, and you can't overcome that but redefine the destination table columns.

Issue when updating date in db table

I'm working on a codeigniter project and I'm trying to troubleshoot a sql issue. I have a query that updates a date field in my table and it's not updating it at all.
I have this table
CREATE TABLE `Customer` (
`customer_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`first_name` varchar(55) NOT NULL DEFAULT '',
`last_name` varchar(55) NOT NULL DEFAULT '',
`city` varchar(255) DEFAULT '',
`state` char(2) DEFAULT '',
`zip` int(5) DEFAULT NULL,
`title` varchar(255) NOT NULL DEFAULT '',
`image` varchar(255) DEFAULT '',
`blurb` blob,
`end_date` date DEFAULT NULL,
`goal` int(11) DEFAULT NULL,
`paypal_acct_num` int(11) DEFAULT NULL,
`progress_bar` enum('full','half','none') DEFAULT NULL,
`page_views` int(11) NOT NULL DEFAULT '0',
`total_pages` int(11) NOT NULL DEFAULT '0',
`total_conversions` int(11) NOT NULL DEFAULT '0',
`total_given` int(11) NOT NULL DEFAULT '0',
`conversion_percentage` int(11) NOT NULL DEFAULT '0',
`avg_contribution` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`customer_id`)
) ENGINE=MyISAM AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;
and when I run this query to insert data, it runs fine and sets the date to 2012-11-01
INSERT INTO `Customer` (`first_name`, `last_name`, `end_date`) VALUES ('John', 'Smith2', '2012-11-01');
Then I get the customer_id and try to run this query
UPDATE `Customer` SET `end_date` = '2012-14-01' WHERE `customer_id` = '18';
and it sets the date end_date field to 0000-00-00.
Why is it changing the end date to 0000-00-00 rather than 2012-14-01?
2012-14-01 is first day of fourteenth month :)
(so its invalid date, thus casted to 0000-00-00 and Data truncated for column 'end_date' at row 1 warning was returned by mysql, which you can see by querying SHOW WARNINGS to mysql immediately after badly behaving query)
2012-01-14 is 14th of January.
use this:
UPDATE `Customer` SET `end_date` = date('Y-m-d') WHERE `customer_id` = '18';
Use date function to update this field.

MySQL table doesn't update, can't find the error message

My knowledge level here is like zilch, but please bear with me.
I have a site built in PHP/MySQL that uses the Smarty template engine. There's a registration form that, for some reason, isn't posting the data to the DB. Here's the function:
$u = new H_User;
$u->setFrom($p);
$smarty->assign('user', $u);
$val = $u->validate();
if ($val === true) {
$temp = new H_User;
$temp->orderBy('user_id desc');
$temp->find(true);
$next_id = $temp->user_id + 1;
$u->user_id = $next_id;
$u->user_password = md5($p['user_password']);
$u->user_regdate = mktime();
$u->user_active = 0;
$u->insert();
$hash = md5($u->user_email . $u->user_regdate);
$smarty->assign('hash', $hash);
$smarty->assign('user', $u);
$smarty->assign('registration_complete', true);
$d = new H_Demographic;
$d->setFrom($p);
$d->insert();
How can I figure out what's wrong here? I don't get any PHP errors and I don't know how to get MySQL to display the errors that might indicate what's wrong with that syntax.
MORE INFO AS PER REQUESTS
#
# Table structure for table `user`
#
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`user_id` mediumint(8) NOT NULL default '0',
`user_active` tinyint(1) default '1',
`username` varchar(25) NOT NULL default '',
`user_password` varchar(32) NOT NULL default '',
`user_session_time` int(11) NOT NULL default '0',
`user_session_page` smallint(5) NOT NULL default '0',
`user_lastvisit` int(11) NOT NULL default '0',
`user_regdate` int(11) NOT NULL default '0',
`user_level` tinyint(4) default '0',
`user_posts` mediumint(8) unsigned NOT NULL default '0',
`user_timezone` decimal(5,2) NOT NULL default '0.00',
`user_style` tinyint(4) default NULL,
`user_lang` varchar(255) default NULL,
`user_dateformat` varchar(14) NOT NULL default 'd M Y H:i',
`user_new_privmsg` smallint(5) unsigned NOT NULL default '0',
`user_unread_privmsg` smallint(5) unsigned NOT NULL default '0',
`user_last_privmsg` int(11) NOT NULL default '0',
`user_emailtime` int(11) default NULL,
`user_viewemail` tinyint(1) default NULL,
`user_attachsig` tinyint(1) default NULL,
`user_allowhtml` tinyint(1) default '1',
`user_allowbbcode` tinyint(1) default '1',
`user_allowsmile` tinyint(1) default '1',
`user_allowavatar` tinyint(1) NOT NULL default '1',
`user_allow_pm` tinyint(1) NOT NULL default '1',
`user_allow_viewonline` tinyint(1) NOT NULL default '1',
`user_notify` tinyint(1) NOT NULL default '1',
`user_notify_pm` tinyint(1) NOT NULL default '0',
`user_popup_pm` tinyint(1) NOT NULL default '0',
`user_rank` int(11) default '0',
`user_avatar` varchar(100) default NULL,
`user_avatar_type` tinyint(4) NOT NULL default '0',
`user_email` varchar(255) default NULL,
`user_icq` varchar(15) default NULL,
`user_website` varchar(100) default NULL,
`user_from` varchar(100) default NULL,
`user_sig` text,
`user_sig_bbcode_uid` varchar(10) default NULL,
`user_aim` varchar(255) default NULL,
`user_yim` varchar(255) default NULL,
`user_msnm` varchar(255) default NULL,
`user_occ` varchar(100) default NULL,
`user_interests` varchar(255) default NULL,
`user_actkey` varchar(32) default NULL,
`user_newpasswd` varchar(32) default NULL,
`first_name` varchar(40) NOT NULL default '',
`last_name` varchar(40) NOT NULL default '',
`level` int(10) unsigned NOT NULL default '0',
`disabled` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`user_id`),
KEY `user_session_time` (`user_session_time`)
) TYPE=MyISAM;
I'm still trying to figure this out and dump this in as a comment vs. an answer so I apologize if this shows up as an answer because it is not. Try putting the following code to spit out your errors:
error_reporting(E_ALL);
ini_set('display_errors', '1');
You may want to look at your php.ini file to allow displaying errors as well.
Do you have access to your server error log? That should show MySQL errors, I think. But as Pekka said, this isn't really enough info to go on.
MySQL connections all have a way to access the last errors thrown by them. It depends on which method you're using to connect to the DB. For instance, I use mysqli class. Therefore, as an example directly from PHP's website:
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
if (!$mysqli->query("SET a=1")) {
printf("Errormessage: %s\n", $mysqli->error);
}
is how I could connect and then retrieve an error if it was thrown. How are you sending data to the DB? Do you have an example of the code that injects the data into the DB?
put
trigger_error(mysql_error());
after
$d->insert();
Edit:
As Marc B pointed out, you would need to use
trigger_error(mysqli_error());
instead for mysqli_ functions. PHP can be lame sometimes.

Categories