Title

07/04/2012 13:38 eBay Advertising#1
PHP Code:
<title>

<?php 

 
include('config/database.php');
 
$title "SELECT title FROM index";
 
$title2 mysql_query($title) or die ("Anfrage nicht erfolgreich.");
 
$row mysql_fetch_object($title2);
 
 echo 
$row

?>  

</title>
Was ist daran falsch er gibt im Header an das die Anfrage nicht erfolgreich aus...? Ist das Script so richtig?
07/04/2012 14:04 NotEnoughForYou#2
Als 1.
wird die db verbindung in der config aufgebaut?

Als 2. Du hast einen fetch_object greifst aber nicht auf das objekt zu ... richtig wäre --> $row->title;
07/04/2012 14:14 eBay Advertising#3
PHP Code:
<title>

<?php 

 
include('database.php');
 
$title "SELECT title FROM index";
 
$title2 mysql_query($title) or die ("Anfrage nicht erfolgreich.");
 
$row mysql_fetch_object($title2);
 
 echo 
$row->title

?>  

</title>

PHP Code:
<?php

$mysqlhost
="localhost"

$mysqluser="*******"

$mysqlpass"****"

$mysqldbase="******"

 

$connection=mysql_connect($mysqlhost$mysqluser$mysqlpass) or die

(
"Verbindung nicht moeglich.");

 

mysql_select_db($mysqldbase$connection) or die("Datenbank konnte nicht gewaehlt werden.");

?>
Geht nicht.
07/04/2012 14:16 NotEnoughForYou#4
lass dir mal den mysql_error ausgeben
07/04/2012 14:19 eBay Advertising#5
Wo soll ich mir den ausgeben lassen im Header?
07/04/2012 14:21 NotEnoughForYou#6
mach
PHP Code:
$title2 mysql_query($title) or die (mysql_error()); 
da stoppt es ja anscheinend
07/04/2012 14:24 eBay Advertising#7
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 'index' at line 1
07/04/2012 14:25 NotEnoughForYou#8
index ist ein reserviertes sql wort... db umbennen dann müsste es eigentlich gehen weil sonst kein fehler drin ist
07/04/2012 14:30 eBay Advertising#9
Ok geht danke :D
07/05/2012 10:56 Fratyr#10
Quote:
$title = mysql_query("SELECT title FROM `ìndex`") or die ("Anfrage nicht erfolgreich.");
Escaped quasi reservierte Wörter in SQL Querys. Hört doch bitte auf unnötig Variablen für SQL Querys anzulegen, ist ja nicht so als ob das irgentwelche Vorteile hätte sondern frisst auf Dauer einfach nur immens Performance. Das kann ich mir garnicht ansehn.