Extentie van html naar php geeft fouten

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Roy -

Roy -

29/06/2012 19:25:12
Quote Anchor link
Beste forum leden!

Ik heb het volgende script:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!doctype html>
<html>
<head>
    <title>Test DYMO</title>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script type="text/javascript" src="http://labelwriter.com/software/dls/sdk/js/DYMO.Label.Framework.latest.js"></script>
</head>
<body>
<script type="text/javascript">
template = '<?xml version="1.0" encoding="utf-8"?>' +
'<DieCutLabel Version="8.0" Units="twips">' +
    '<PaperOrientation>Landscape</PaperOrientation>' +
    '<Id>MultiPurpose11355</Id>' +
    '<PaperName>11355 Multi-Purpose</PaperName>' +
    '<DrawCommands>' +
        '<RoundRectangle X="0" Y="0" Width="1080" Height="2880" Rx="180" Ry="180" />' +
    '</DrawCommands>' +
    '<ObjectInfo>' +
        '<AddressObject>' +
            '<Name>ADRES</Name>' +
            '<ForeColor Alpha="255" Red="0" Green="0" Blue="0" />' +
            '<BackColor Alpha="0" Red="255" Green="255" Blue="255" />' +
            '<LinkedObjectName></LinkedObjectName>' +
            '<Rotation>Rotation0</Rotation>' +
            '<IsMirrored>False</IsMirrored>' +
            '<IsVariable>True</IsVariable>' +
            '<HorizontalAlignment>Center</HorizontalAlignment>' +
            '<VerticalAlignment>Middle</VerticalAlignment>' +
            '<TextFitMode>ShrinkToFit</TextFitMode>' +
            '<UseFullFontHeight>True</UseFullFontHeight>' +
            '<Verticalized>False</Verticalized>' +
            '<StyledText>' +
                '<Element>' +
                    '<String>tekst</String>' +
                    '<Attributes>' +
                        '<Font Family="Comic Sans MS" Size="16" Bold="False" Italic="False" Underline="False" Strikeout="False" />' +
                        '<ForeColor Alpha="255" Red="0" Green="0" Blue="0" />' +
                    '</Attributes>' +
                '</Element>' +
            '</StyledText>' +
            '<ShowBarcodeFor9DigitZipOnly>False</ShowBarcodeFor9DigitZipOnly>' +
            '<BarcodePosition>AboveAddress</BarcodePosition>' +
            '<LineFonts>' +
                '<Font Family="Comic Sans MS" Size="16" Bold="False" Italic="False" Underline="False" Strikeout="False" />' +
            '</LineFonts>' +
        '</AddressObject>' +
        '<Bounds X="326" Y="615" Width="2317" Height="383" />' +
    '</ObjectInfo>' +
    '<ObjectInfo>' +
        '<BarcodeObject>' +
            '<Name>STREEPJESCODE</Name>' +
            '<ForeColor Alpha="255" Red="0" Green="0" Blue="0" />' +
            '<BackColor Alpha="0" Red="255" Green="255" Blue="255" />' +
            '<LinkedObjectName></LinkedObjectName>' +
            '<Rotation>Rotation0</Rotation>' +
            '<IsMirrored>False</IsMirrored>' +
            '<IsVariable>True</IsVariable>' +
            '<Text>12345</Text>' +
            '<Type>Code39</Type>' +
            '<Size>Medium</Size>' +
            '<TextPosition>Bottom</TextPosition>' +
            '<TextFont Family="Arial" Size="8" Bold="False" Italic="False" Underline="False" Strikeout="False" />' +
            '<CheckSumFont Family="Arial" Size="8" Bold="False" Italic="False" Underline="False" Strikeout="False" />' +
            '<TextEmbedding>None</TextEmbedding>' +
            '<ECLevel>0</ECLevel>' +
            '<HorizontalAlignment>Center</HorizontalAlignment>' +
            '<QuietZonesPadding Left="0" Top="0" Right="0" Bottom="0" />' +
        '</BarcodeObject>' +
        '<Bounds X="326" Y="150" Width="2257" Height="450" />' +
    '</ObjectInfo>' +
'</DieCutLabel>';

    var printers = dymo.label.framework.getPrinters();
    if (printers.length == 0) {
        alert("Geen DYMO LabelWriter 400 Turbo gevonden!");
    } else {
        var label = dymo.label.framework.openLabelXml(template);
        label.setObjectText("ADRES", '19,95');
        label.setObjectText("STREEPJESCODE", '16848');
        label.print("DYMO LabelWriter 400 Turbo");
    }
</script>

</body>
</html>


Deze heet test.html en werkt! Maar ik wil php hierbij gaan gebruiken dus de extensie gewijzigd met als uitkomst test.php
Prachtig, kan niks fout gaan zou je denken!

Maar toch krijg ik na deze wijziging:

Parse error: syntax error, unexpected T_STRING in test.php on line 10

Wat gaat er of doe ik fout?

Groet en dank!

Toevoeging op 29/06/2012 19:29:22:

EDIT
Ik zal wel gek zijn maar zo werkt het wel:

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!doctype html>
<html>
<head>
    <title>Test DYMO</title>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script type="text/javascript" src="http://labelwriter.com/software/dls/sdk/js/DYMO.Label.Framework.latest.js"></script>
</head>
<body>
<script type="text/javascript">
template = '<? echo '<?xml version="1.0" encoding="utf-8"?>'; ?>' +
'<DieCutLabel Version="8.0" Units="twips">' +
    '<PaperOrientation>Landscape</PaperOrientation>' +
    '<Id>MultiPurpose11355</Id>' +
    '<PaperName>11355 Multi-Purpose</PaperName>' +
    '<DrawCommands>' +
        '<RoundRectangle X="0" Y="0" Width="1080" Height="2880" Rx="180" Ry="180" />' +
    '</DrawCommands>' +
    '<ObjectInfo>' +
        '<AddressObject>' +
            '<Name>ADRES</Name>' +
            '<ForeColor Alpha="255" Red="0" Green="0" Blue="0" />' +
            '<BackColor Alpha="0" Red="255" Green="255" Blue="255" />' +
            '<LinkedObjectName></LinkedObjectName>' +
            '<Rotation>Rotation0</Rotation>' +
            '<IsMirrored>False</IsMirrored>' +
            '<IsVariable>True</IsVariable>' +
            '<HorizontalAlignment>Center</HorizontalAlignment>' +
            '<VerticalAlignment>Middle</VerticalAlignment>' +
            '<TextFitMode>ShrinkToFit</TextFitMode>' +
            '<UseFullFontHeight>True</UseFullFontHeight>' +
            '<Verticalized>False</Verticalized>' +
            '<StyledText>' +
                '<Element>' +
                    '<String>tekst</String>' +
                    '<Attributes>' +
                        '<Font Family="Comic Sans MS" Size="16" Bold="False" Italic="False" Underline="False" Strikeout="False" />' +
                        '<ForeColor Alpha="255" Red="0" Green="0" Blue="0" />' +
                    '</Attributes>' +
                '</Element>' +
            '</StyledText>' +
            '<ShowBarcodeFor9DigitZipOnly>False</ShowBarcodeFor9DigitZipOnly>' +
            '<BarcodePosition>AboveAddress</BarcodePosition>' +
            '<LineFonts>' +
                '<Font Family="Comic Sans MS" Size="16" Bold="False" Italic="False" Underline="False" Strikeout="False" />' +
            '</LineFonts>' +
        '</AddressObject>' +
        '<Bounds X="326" Y="615" Width="2317" Height="383" />' +
    '</ObjectInfo>' +
    '<ObjectInfo>' +
        '<BarcodeObject>' +
            '<Name>STREEPJESCODE</Name>' +
            '<ForeColor Alpha="255" Red="0" Green="0" Blue="0" />' +
            '<BackColor Alpha="0" Red="255" Green="255" Blue="255" />' +
            '<LinkedObjectName></LinkedObjectName>' +
            '<Rotation>Rotation0</Rotation>' +
            '<IsMirrored>False</IsMirrored>' +
            '<IsVariable>True</IsVariable>' +
            '<Text>12345</Text>' +
            '<Type>Code39</Type>' +
            '<Size>Medium</Size>' +
            '<TextPosition>Bottom</TextPosition>' +
            '<TextFont Family="Arial" Size="8" Bold="False" Italic="False" Underline="False" Strikeout="False" />' +
            '<CheckSumFont Family="Arial" Size="8" Bold="False" Italic="False" Underline="False" Strikeout="False" />' +
            '<TextEmbedding>None</TextEmbedding>' +
            '<ECLevel>0</ECLevel>' +
            '<HorizontalAlignment>Center</HorizontalAlignment>' +
            '<QuietZonesPadding Left="0" Top="0" Right="0" Bottom="0" />' +
        '</BarcodeObject>' +
        '<Bounds X="326" Y="150" Width="2257" Height="450" />' +
    '</ObjectInfo>' +
'</DieCutLabel>';

    var printers = dymo.label.framework.getPrinters();
    if (printers.length == 0) {
        alert("Geen DYMO LabelWriter 400 Turbo gevonden!");
    } else {
        var label = dymo.label.framework.openLabelXml(template);
        label.setObjectText("ADRES", '19,95');
        label.setObjectText("STREEPJESCODE", '16848');
        label.print("DYMO LabelWriter 400 Turbo");
    }
</script>

</body>
</html>


Toevoeging op 29/06/2012 19:29:54:

EDIT2
Dus.. opgelost :) sorry voor de overlast :P
 
PHP hulp

PHP hulp

22/12/2024 08:57:07
 
Ykcin Ykcin

Ykcin Ykcin

29/06/2012 20:20:38
Quote Anchor link
Moet
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
template =

niet gewoon
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
var template =

zijn?

Ik zie namelijk niet dat je de variabele eerder hebt gedeclareerd,
sorry als ik het mis heb.


EDIT:
Mijn fout, na het escapen van de eerste vraagteken in je script en het toevoegen van var voor de variabele krijg ik nu een alert dat de labelwriter niet is gevonden, maar verder geen scriptfouten meer.

Ik heb dit:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
template = '<?xml version="1.0" encoding="utf-8"?>'

veranderd in dit:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
var template = '<\?xml version="1.0" encoding="utf-8"?>
'

Dit is misschien een nettere oplossing dan je huidige oplossing
Gewijzigd op 29/06/2012 20:28:54 door Ykcin Ykcin
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.