XML: Geen resultaat

Gestart doorRemcoboy20 reacties49 weergaven

21 berichten · pagina 1 van 2

Remcoboy

Lid · Topicstarter

Berichten
4.749
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik ben aan het proberen om uit mijn databasetabel tvb_dalytipdata de value van tip_text te selecteren wanneer de shown_data vandaag is.Reeds gelukt.

Huidige code:
Spoiler tonen
[COLOR= #0000BB]<?php[/COLOR]

[URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Content-Type: text/xml"[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #FF8000]//set the content type to xml
// Initialize the xmlOutput variable[/COLOR]
[COLOR= #0000BB]$xmlBody[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]<?xml version="1.0" encoding="UTF-8" ?>[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]//je wilt eigenlijk altijd met utrf8 werken, tenzij dat problemen lijkt te geven.[/COLOR]
[COLOR= #0000BB]$xmlBody[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"<XML>"[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #0000BB]$html[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR]


[COLOR= #0000BB]$con[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"swienink_besp"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"*"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][COLOR= #0000BB]$con[/COLOR][COLOR= #007700])
 {[/COLOR]
  [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Could not connect: [/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());
  }[/COLOR]
 [COLOR= #0000BB]$db_selected[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]swienink_besp[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$con[/COLOR][COLOR= #007700]);[/COLOR]

        [COLOR= #0000BB]$today[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Y-m-d"[/COLOR][COLOR= #007700]);[/COLOR]            [COLOR= #FF8000]//2001-03-10 [/COLOR]
        
        [COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT tip_text FROM tvb_dailytipdata WHERE shown_date = 2013-02-03"[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]);[/COLOR]

        [COLOR= #FF8000]//if (!$result) {
        //$message  = Invalid query:  . mysql_error() . "
";
        //$message .= Whole query:  . $query;
           // die($message);
        //}
        //echo "" . $result[tip_text];[/COLOR]



            [COLOR= #0000BB]$xmlBody[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]
            <item> 
                <title>[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]tip_text[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]</title> 
            </item>[/COLOR][COLOR= #007700];[/COLOR]                        

        [COLOR= #0000BB]$xmlBody[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"</XML>"[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$xmlBody[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// output the xml[/COLOR]

[URL="http://www.php.net/mysql_close"]mysql_close[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$con[/COLOR][COLOR= #007700]);[/COLOR]
?>
- Hoe kan ik nu gebruikmaken van de wordpress database instellingen? Nu moet ik namelijk altijd de connectiegegevens neerrzetten..
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Fout 1: Je gebruikt geen MySQLi
Fout 2: Geen SimpleXML
Fout 3: Je echod de query.. Dat kan natuurlijk niet yummie Als je $result = mysql_fetch_assoc($query); niet commented had kon je doen:
$result[tip_text]
Fout 4: Stop het in een while loop
Fout 5: mysql_select_db?
aah
0
Remcoboy

Lid · Topicstarter

Berichten
4.749
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb nu code:
Spoiler tonen
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Content-Type: text/xml"[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #FF8000]//set the content type to xml
// Initialize the xmlOutput variable[/COLOR]
[COLOR= #0000BB]$xmlBody[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]<?xml version="1.0" encoding="UTF-8" ?>[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]//je wilt eigenlijk altijd met utrf8 werken, tenzij dat problemen lijkt te geven.[/COLOR]
[COLOR= #0000BB]$xmlBody[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"<XML>"[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #0000BB]$html[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR]


[COLOR= #0000BB]$con[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"swienink_besp"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"*"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][COLOR= #0000BB]$con[/COLOR][COLOR= #007700])
  {[/COLOR]
  [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Could not connect: [/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());
  }[/COLOR]

        [COLOR= #0000BB]$today[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Y-m-d"[/COLOR][COLOR= #007700]);[/COLOR]            [COLOR= #FF8000]//2001-03-10 [/COLOR]
        
        [COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT tip_text FROM tvb_dailytipdata WHERE shown_date = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$today[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #FF8000]//echo "$result";[/COLOR]



            [COLOR= #0000BB]$xmlBody[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]
            <item> 
                <title>[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]</title> 
            </item>[/COLOR][COLOR= #007700];[/COLOR]                        

        [COLOR= #0000BB]$xmlBody[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"</XML>"[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$xmlBody[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// output the xml[/COLOR]

[URL="http://www.php.net/mysql_close"]mysql_close[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$con[/COLOR][COLOR= #007700]);[/COLOR]
?>
Met de fout:
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in * on line 19
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Content-Type: text/xml"[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #FF8000]//set the content type to xml
// Initialize the xmlOutput variable[/COLOR]
[COLOR= #0000BB]$xmlBody[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]<?xml version="1.0" encoding="UTF-8" ?>[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]//je wilt eigenlijk altijd met utrf8 werken, tenzij dat problemen lijkt te geven.[/COLOR]
[COLOR= #0000BB]$xmlBody[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"<XML>"[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #0000BB]$html[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR]


[COLOR= #0000BB]$con[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"swienink_besp"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"*"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][COLOR= #0000BB]$con[/COLOR][COLOR= #007700])
  {[/COLOR]
  [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Could not connect: [/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());
  }[/COLOR]

        [COLOR= #0000BB]$today[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Y-m-d"[/COLOR][COLOR= #007700]);[/COLOR]            [COLOR= #FF8000]//2001-03-10 [/COLOR]
        
        [COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT tip_text FROM tvb_dailytipdata WHERE shown_date = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$today[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #FF8000]//echo "$result";[/COLOR]



            [COLOR= #0000BB]$xmlBody[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]
            <item> 
                <title>[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]tip_text[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]</title> 
            </item>[/COLOR][COLOR= #007700];[/COLOR]                        

        [COLOR= #0000BB]$xmlBody[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"</XML>"[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$xmlBody[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// output the xml[/COLOR]

[URL="http://www.php.net/mysql_close"]mysql_close[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$con[/COLOR][COLOR= #007700]);[/COLOR]
?>
0
Remcoboy

Lid · Topicstarter

Berichten
4.749
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dylanh schreef:
Spoiler tonen
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Content-Type: text/xml"[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #FF8000]//set the content type to xml
// Initialize the xmlOutput variable[/COLOR]
[COLOR= #0000BB]$xmlBody[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]<?xml version="1.0" encoding="UTF-8" ?>[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]//je wilt eigenlijk altijd met utrf8 werken, tenzij dat problemen lijkt te geven.[/COLOR]
[COLOR= #0000BB]$xmlBody[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"<XML>"[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #0000BB]$html[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR]


[COLOR= #0000BB]$con[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"swienink_besp"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"*"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][COLOR= #0000BB]$con[/COLOR][COLOR= #007700])
  {[/COLOR]
  [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Could not connect: [/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());
  }[/COLOR]

        [COLOR= #0000BB]$today[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Y-m-d"[/COLOR][COLOR= #007700]);[/COLOR]            [COLOR= #FF8000]//2001-03-10 [/COLOR]
        
        [COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT tip_text FROM tvb_dailytipdata WHERE shown_date = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$today[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #FF8000]//echo "$result";[/COLOR]



            [COLOR= #0000BB]$xmlBody[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]
            <item> 
                <title>[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]tip_text[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]</title> 
            </item>[/COLOR][COLOR= #007700];[/COLOR]                        

        [COLOR= #0000BB]$xmlBody[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"</XML>"[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$xmlBody[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// output the xml[/COLOR]

[URL="http://www.php.net/mysql_close"]mysql_close[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$con[/COLOR][COLOR= #007700]);[/COLOR]
?>
Zelfde error.
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT tip_text FROM tvb_dailytipdata WHERE shown_date = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$today[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
?>
0
Remcoboy

Lid · Topicstarter

Berichten
4.749
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dylanh schreef:
[COLOR= #0000BB]<?php
$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT tip_text FROM tvb_dailytipdata WHERE shown_date = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$today[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
?>
Code:
Spoiler tonen
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Content-Type: text/xml"[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #FF8000]//set the content type to xml
// Initialize the xmlOutput variable[/COLOR]
[COLOR= #0000BB]$xmlBody[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]<?xml version="1.0" encoding="UTF-8" ?>[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]//je wilt eigenlijk altijd met utrf8 werken, tenzij dat problemen lijkt te geven.[/COLOR]
[COLOR= #0000BB]$xmlBody[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"<XML>"[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #0000BB]$html[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR]


[COLOR= #0000BB]$con[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"swienink_besp"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"*"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][COLOR= #0000BB]$con[/COLOR][COLOR= #007700])
  {[/COLOR]
  [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Could not connect: [/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());
  }[/COLOR]

        [COLOR= #0000BB]$today[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Y-m-d"[/COLOR][COLOR= #007700]);[/COLOR]            [COLOR= #FF8000]//2001-03-10 [/COLOR]
        
        [COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT tip_text FROM tvb_dailytipdata WHERE shown_date = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$today[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #FF8000]//echo "$result";[/COLOR]



            [COLOR= #0000BB]$xmlBody[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]
            <item> 
                <title>[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]</title> 
            </item>[/COLOR][COLOR= #007700];[/COLOR]                        

        [COLOR= #0000BB]$xmlBody[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"</XML>"[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$xmlBody[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// output the xml[/COLOR]

[URL="http://www.php.net/mysql_close"]mysql_close[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$con[/COLOR][COLOR= #007700]);[/COLOR]
?>
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in * on line 19

toevoeging op 3 februari 2013, 10:58:41:
Invalid query: No database selected
Spoiler tonen
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Content-Type: text/xml"[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #FF8000]//set the content type to xml
// Initialize the xmlOutput variable[/COLOR]
[COLOR= #0000BB]$xmlBody[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]<?xml version="1.0" encoding="UTF-8" ?>[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]//je wilt eigenlijk altijd met utrf8 werken, tenzij dat problemen lijkt te geven.[/COLOR]
[COLOR= #0000BB]$xmlBody[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"<XML>"[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #0000BB]$html[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR]


[COLOR= #0000BB]$con[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"swienink_besp"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"*"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][COLOR= #0000BB]$con[/COLOR][COLOR= #007700])
  {[/COLOR]
  [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Could not connect: [/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());
  }[/COLOR]

        [COLOR= #0000BB]$today[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Y-m-d"[/COLOR][COLOR= #007700]);[/COLOR]            [COLOR= #FF8000]//2001-03-10 [/COLOR]
        
        [COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT tip_text FROM tvb_dailytipdata WHERE shown_date = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$today[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]);[/COLOR]

        [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700]) {[/COLOR]
        [COLOR= #0000BB]$message[/COLOR]  [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]Invalid query: [/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]() .[/COLOR] [COLOR= #DD0000]"n"[/COLOR][COLOR= #007700];[/COLOR]
        [COLOR= #0000BB]$message[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]Whole query: [/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$query[/COLOR][COLOR= #007700];[/COLOR]
            [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$message[/COLOR][COLOR= #007700]);
        }[/COLOR]
        [COLOR= #FF8000]//echo "$result";[/COLOR]



            [COLOR= #0000BB]$xmlBody[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]
            <item> 
                <title>[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]</title> 
            </item>[/COLOR][COLOR= #007700];[/COLOR]                        

        [COLOR= #0000BB]$xmlBody[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"</XML>"[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$xmlBody[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// output the xml[/COLOR]

[URL="http://www.php.net/mysql_close"]mysql_close[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$con[/COLOR][COLOR= #007700]);[/COLOR]
?>
0
Berichten
3.112
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nielsie schreef:
Fout 1: Je gebruikt geen MySQLi
Fout 2: Geen SimpleXML
Fout 3: Je echod de query.. Dat kan natuurlijk niet yummie Als je $result = mysql_fetch_assoc($query); niet commented had kon je doen:
$result[tip_text]
Fout 4: Stop het in een while loop
Fout 5: mysql_select_db?
aah
0
Remcoboy

Lid · Topicstarter

Berichten
4.749
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Heb het nu werkende met:
Spoiler tonen
[COLOR= #0000BB]<?php[/COLOR]

[URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Content-Type: text/xml"[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #FF8000]//set the content type to xml
// Initialize the xmlOutput variable[/COLOR]
[COLOR= #0000BB]$xmlBody[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]<?xml version="1.0" encoding="UTF-8" ?>[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]//je wilt eigenlijk altijd met utrf8 werken, tenzij dat problemen lijkt te geven.[/COLOR]
[COLOR= #0000BB]$xmlBody[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"<XML>"[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #0000BB]$html[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR]


[COLOR= #0000BB]$con[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"swienink_besp"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"*"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][COLOR= #0000BB]$con[/COLOR][COLOR= #007700])
 {[/COLOR]
  [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Could not connect: [/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());
  }[/COLOR]
 [COLOR= #0000BB]$db_selected[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]swienink_besp[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$con[/COLOR][COLOR= #007700]);[/COLOR]

        [COLOR= #0000BB]$today[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Y-m-d"[/COLOR][COLOR= #007700]);[/COLOR]            [COLOR= #FF8000]//2001-03-10 [/COLOR]
        
        [COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT tip_text FROM tvb_dailytipdata WHERE shown_date = 2013-02-03"[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]);[/COLOR]

        [COLOR= #FF8000]//if (!$result) {
        //$message  = Invalid query:  . mysql_error() . "n";
        //$message .= Whole query:  . $query;
           // die($message);
        //}
        //echo "" . $result[tip_text];[/COLOR]



            [COLOR= #0000BB]$xmlBody[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]
            <item> 
                <title>[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$result[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]tip_text[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]</title> 
            </item>[/COLOR][COLOR= #007700];[/COLOR]                        

        [COLOR= #0000BB]$xmlBody[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"</XML>"[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$xmlBody[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]// output the xml[/COLOR]

[URL="http://www.php.net/mysql_close"]mysql_close[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$con[/COLOR][COLOR= #007700]);[/COLOR]
?>
Hoe kan ik nu gebruikmaken van de wordpress database instellingen? Nu moet ik namelijk altijd de connectie neerrzetten..
0
Berichten
6.485
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nielsie schreef:
Fout 1: Je gebruikt geen MySQLi
Fout 2: Geen SimpleXML

Fout 3: Je echod de query.. Dat kan natuurlijk niet yummie Als je $result = mysql_fetch_assoc($query); niet commented had kon je doen:
$result[tip_text]
Fout 4: Stop het in een while loop
Fout 5: mysql_select_db?
aah
Tja en dit is gewoon bullshit, MySQLi is geen wondermiddel waardoor alles mooier wordt. Het is gewoon een Db class.
0
Berichten
308
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Rogier schreef:
Eerdere citaten tonen
Nielsie schreef:
Fout 1: Je gebruikt geen MySQLi
Fout 2: Geen SimpleXML
Fout 3: Je echod de query.. Dat kan natuurlijk niet yummie Als je $result = mysql_fetch_assoc($query); niet commented had kon je doen:
$result[tip_text]
Fout 4: Stop het in een while loop
Fout 5: mysql_select_db?
aah
Tja en dit is gewoon bullshit, MySQLi is geen wondermiddel waardoor alles mooier wordt. Het is gewoon een Db class.
En je gebruikt beter DOMDocument i.p.v. SimpleXML aangzien DOMDoment de DOM principes volgt en OOP is.
0
Berichten
6.485
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
En je gebruikt liever geen XML omdat JSON gewoon 10x beter is.
0
Berichten
308
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Rogier schreef:
En je gebruikt liever geen XML omdat JSON gewoon 10x beter is.
t Is kleiner en word veel sneller geparsed idd.
Maar soms verkies ik toch liever XML voor JSON.
0
Berichten
6.485
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
in welke gevallen?

Het is niet alleen kleiner en wordt sneller geparsed. Het is ook nog een stuk beter met PHP te integreren. In plaats van het generen van moeilijke xml bestanden doe je gewoon json_encode() bij een api en json_decode() bij een api call.

Daarbij is het gebruik van NO-SQL databases ongelofelijk toegenomen afgelopen jaren, vrijwel allemaal JSON. Gewoon omdat het ongelofelijk snel is. Hierdoor is het maken van grote applicaties veel makkelijker geworden biggrin
0
Berichten
308
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Rogier schreef:
in welke gevallen?

Het is niet alleen kleiner en wordt sneller geparsed. Het is ook nog een stuk beter met PHP te integreren. In plaats van het generen van moeilijke xml bestanden doe je gewoon json_encode() bij een api en json_decode() bij een api call.

Daarbij is het gebruik van NO-SQL databases ongelofelijk toegenomen afgelopen jaren, vrijwel allemaal JSON. Gewoon omdat het ongelofelijk snel is. Hierdoor is het maken van grote applicaties veel makkelijker geworden biggrin
In gevallen waarbij je bv met externe APIs werkt yummie
Vele APIs vragen bij iedere tags, attributen.
Met JSON is dat nogal onhandig als je bijvoorbeeld in XML een tag zou hebben met 6 attributten.

Alhoewel, nu ik er aan denk zou je het idd wel gemakkelijker kunnen doen in JSON.

tag: {
att: lol
att2: lol
}

Hmmmmmn, ja. Maar toch, vele APIs zijn nog in XML.
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren