<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>WordPress DK Forum Tag: mysql table wpdb - Recent Topics</title>
		<link>http://wp-danmark.dk/forum/tags/mysql-table-wpdb</link>
		<description>WordPress DK Forum Tag: mysql table wpdb - Recent Topics</description>
		<language>da-DK</language>
		<pubDate>Fri, 31 Jul 2026 01:01:42 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.1</generator>
		<textInput>
			<title><![CDATA[Søg]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://wp-danmark.dk/forum/search.php</link>
		</textInput>
		<atom:link href="http://wp-danmark.dk/forum/rss/tags/mysql-table-wpdb/topics" rel="self" type="application/rss+xml" />

		<item>
			<title>Emil Ellerbek om "Problem: CREATE TABLE $table_name"</title>
			<link>http://wp-danmark.dk/forum/topic/problem-create-table-table_name#post-35087</link>
			<pubDate>ons, 29 feb 2012 11:27:39 +0000</pubDate>
			<dc:creator>Emil Ellerbek</dc:creator>
			<guid isPermaLink="false">35087@http://wp-danmark.dk/forum/</guid>
			<description>&#60;p&#62;Sidder og arbejder på et plugin, hvortil jeg skal have lavet en tabel i databasen. Problemet er, at jeg får en fejlmelding om, at tabellen ikke eksisterer. Min kode er taget fra &#60;a href=&#34;http://codex.wordpress.org/Creating_Tables_with_Plugins&#34; rel=&#34;nofollow&#34;&#62;http://codex.wordpress.org/Creating_Tables_with_Plugins&#60;/a&#62;.&#60;/p&#62;
&#60;p&#62; Koden til at lave tabellen ser ud som følgende:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;global $volsch_db_version;&#60;br /&#62;
$volsch_db_version = &#34;1.0&#34;;&#60;/p&#62;
&#60;p&#62;$table_name = $wpdb-&#38;gt;prefix . &#34;volsch_db&#34;;&#60;/p&#62;
&#60;p&#62;function volsch_db_create () {&#60;br /&#62;
	global $wpdb;&#60;br /&#62;
	global $volsch_db_version;&#60;/p&#62;
&#60;p&#62;   $table_name = $wpdb-&#38;gt;prefix . &#34;volsch_db&#34;;&#60;/p&#62;
&#60;p&#62;	$sql = &#34;&#60;br /&#62;
		CREATE TABLE $table_name (&#60;br /&#62;
			id mediumint(9) NOT NULL AUTO_INCREMENT,&#60;br /&#62;
			adate datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,&#60;br /&#62;
			username tinytext NOT NULL,&#60;br /&#62;
			UNIQUE KEY id (id)&#60;br /&#62;
		);&#60;br /&#62;
	&#34;;&#60;/p&#62;
&#60;p&#62;	require_once(ABSPATH . 'wp-admin/includes/upgrade.php');&#60;br /&#62;
	dbDelta($sql);&#60;/p&#62;
&#60;p&#62;	add_option(&#34;volsch_db_version&#34;, $volsch_db_version);&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;function volsch_install_data() {&#60;br /&#62;
	global $wpdb;&#60;br /&#62;
	$volsch_adate = '2222-22-22';&#60;br /&#62;
  	$volsch_id = '2';&#60;br /&#62;
	$volsch_username = 'Emilo';&#60;/p&#62;
&#60;p&#62;  	$rows_affected = $wpdb-&#38;gt;insert( $table_name, array( 'id' =&#38;gt; $volsch_id, 'adate' =&#38;gt; $volsch_adate, 'username' =&#38;gt; $volsch_username) );&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;register_activation_hook(__FILE__,'volsch_db_create');&#60;br /&#62;
register_activation_hook(__FILE__,'volsch_install_data');&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;Hvis jeg prøver at fiske noget frem fra tabellen, får jeg en fejlmeddelelse.&#60;/p&#62;
&#60;p&#62;&#60;blockquote&#62;WordPress database error: [Table 'gadecafeen_dk.$volsch_db' doesn't exist]&#60;br /&#62;
SELECT * FROM $volsch_db&#60;br /&#62;
&#60;/blockquote&#62;&#60;/p&#62;
&#60;p&#62;	&#60;code&#62;global $wpdb;&#60;br /&#62;
	global $table_name;&#60;br /&#62;
	$table_name = $wpdb-&#38;gt;prefix . 'volsch_db';&#60;br /&#62;
	$volsch_db_get = $wpdb-&#38;gt;get_results('SELECT * FROM $table_name');&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;Nogen der kan gennemskue, hvorfor min tabel ikke bliver lavet?&#60;br /&#62;
På forhånd tak :)
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
