Jump to content
View in the app

A better way to browse. Learn more.

GTAGames.nl - De Nederlandse Grand Theft Auto Community!

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Goedemorgen,

Ik ben bezig met een CMS, alleen nu wil ik een prefix instellen. Code:

mysql_query("DROP TABLE IF EXISTS `".cms."news`");

mysql_query("CREATE TABLE `".PREFIX."news` (

`id` longtext NOT NULL,

`title` VARCHAR(50) NOT NULL,

`content` TEXT NOT NULL,

PRIMARY KEY(id)

)");

Wat ik dus wil is voor news cms krijgen dus dit resultaat:

cms_news

Dus hoe moet ik dat invoegen in de hele code?

mysql_query("DROP TABLE IF EXISTS `".cms."news`");

mysql_query("CREATE TABLE `".PREFIX."news` (

`id` longtext NOT NULL,

`title` VARCHAR(50) NOT NULL,

`content` TEXT NOT NULL,

PRIMARY KEY(id)

)");

Ik heb cms_ al geprobeerd, .cms. zoals je nu ziet en gewoon cms.

Alvast bedankt :Y

EDIT: Dit is de melding die ik krijg in phpMyAdmin:

#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 'mysql_query("DROP TABLE IF EXISTS `".cms."news`")' at line 1

Edited by xgaming

Featured Replies

Je moet gewoon ergens in het begin van je PHP bestand zetten:

define("PREFIX", "cms_");

Dan doe je:

mysql_query("SELECT * FROM " . PREFIX . "table ORDER BY id DESC");

In phpmyadmin zelf moet je natuurlijk gewoon het volgende typen aangezien je in de querys daar geen variabelen kan definieëren:

SELECT * FROM cms_table ORDER BY id DESC

Hopelijk was dat wat je bedoelde want je was nogal vaag in je bericht. :Y

  • Author

Sorry :$,

maar hoe moet ik dat dan in deze code 'inbouwen' ?

mysql_query("DROP TABLE IF EXISTS `".PREFIX."news`");
mysql_query("CREATE TABLE `".PREFIX."news` (
`id` longtext NOT NULL,
`title` VARCHAR(50) NOT NULL,
`content` TEXT NOT NULL,
PRIMARY KEY(id)
)");

Is deze code dan goed?

Je moet gewoon ergens in het begin van je PHP bestand zetten:

define("PREFIX", "cms_");

Bijvoorbeeld _mysql.php? (Die wordt in index.php geinclude, links zijn index.php?req=blabla. Dus dat wordt automatisch bij elke pagina gedaan).

<?

// MySQL information
$host = "localhost"
$user = "user"
$pass = "pass"
$db = "db" 

// Prefix
define("PREFIX", "cms_");

?>

In ieder geval bedankt :tu::Y

Edited by xgaming

Kan je dat soort mysql opdrachten niet beter invoeren en testen in PHPMyAdmin. Dat werkt namelijk veel makkelijker en verteld nadat je wat simpele handelingen doet gewoon welke MySQL code erbij hoort.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Recently Browsing 0

  • No registered users viewing this page.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.