Drone4four Posted July 4, 2006 Share Posted July 4, 2006 The first PHP script I've written looks like this:[code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http:www.w3.org/TR/xhtml/DTD/xhtml1-strict.dtd"><html><head><title>Listing 4.1 Testing the tpe of varibable</title></head><body><div><?php$testing; // declare without assigningprint gettype ($testing ); //NULLprint "<br />";$testing = 5;print gettype( $testing ); //integerprint "<br />";$testing = "five";print gettype( $testing ); // stringprint "<br />";$testing = 5.0print gettype( $testing ); // doubleprint "<br />";$testing = true;print gettype( $testing ); // booleanprint "<br />";?></div></body>[/code]When I try to execute it with my bash commandline, I get this error:[code]bash-3.00$ php firstPHPscript.phpPHP Parse error: syntax error, unexpected T_PRINT in /home/invert/programming/firstPHPscript.php on line 21[/code] Looking at line 21, I can't spot the mistake I've made. Can you? Quote Link to comment https://forums.phpfreaks.com/topic/13617-my-first-php-scripts-wont-execute-solved/ Share on other sites More sharing options...
.josh Posted July 4, 2006 Share Posted July 4, 2006 $testing = 5.0you forgot the ; Quote Link to comment https://forums.phpfreaks.com/topic/13617-my-first-php-scripts-wont-execute-solved/#findComment-52774 Share on other sites More sharing options...
Drone4four Posted July 4, 2006 Author Share Posted July 4, 2006 [quote author=Crayon Violent link=topic=99377.msg391321#msg391321 date=1151991695]$testing = 5.0you forgot the ;[/quote]Thanks Crayon for the quick response. WIth your correction, the script now executes with different errors: [code]bash-3.00$ php firstPHPscript.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http:www.w3.org/TR/xhtml/DTD/xhtml1-strict.dtd"><html><head><title>Listing 4.1 Testing the tpe of varibable</title></head><body><div>PHP Notice: Undefined variable: testing in /home/invert/programming/firstPHPscript.php on line 11PHP Notice: Undefined variable: testing in /home/invert/programming/firstPHPscript.php on line 12NULL<br />integer<br />string<br />double<br />boolean<br /></div></body>[/code]And here is how my script renders in firefox:[code]"; $testing = 5; print gettype( $testing ); //integer print ""; $testing = "five"; print gettype( $testing ); // string print ""; $testing = 5.0; print gettype( $testing ); // double print ""; $testing = true; print gettype( $testing ); // boolean print ""; ?>[/code] edit:spedit:added errors Quote Link to comment https://forums.phpfreaks.com/topic/13617-my-first-php-scripts-wont-execute-solved/#findComment-52776 Share on other sites More sharing options...
Drone4four Posted July 4, 2006 Author Share Posted July 4, 2006 I'm bumping this thread because I significantly edited my last post. Quote Link to comment https://forums.phpfreaks.com/topic/13617-my-first-php-scripts-wont-execute-solved/#findComment-53084 Share on other sites More sharing options...
.josh Posted July 5, 2006 Share Posted July 5, 2006 umm... are you running your script on your own computer? if so, then you have to install php in order to run php files on your computer. Quote Link to comment https://forums.phpfreaks.com/topic/13617-my-first-php-scripts-wont-execute-solved/#findComment-53153 Share on other sites More sharing options...
Drone4four Posted July 6, 2006 Author Share Posted July 6, 2006 [quote author=Crayon Violent link=topic=99377.msg391729#msg391729 date=1152071461]umm... are you running your script on your own computer? if so, then you have to install php in order to run php files on your computer. [/quote]I have php 4 installed. Here is the version information:[code]phpinfo()PHP Version => 4.4.2System => Linux 314 2.4.31 #6 Sun Jun 5 19:04:47 PDT 2005 i686Build Date => Feb 14 2006 16:31:30Configure Command => './configure' '--prefix=/usr' '--enable-force-cgi-redirect' '--enable-fastcgi' '--enable-pcntl' '--enable-sigchild' '--sysconfdir=/etc' '--enable-discard-path' '--with-config-file-path=/etc/apache' '--enable-safe-mode' '--with-openssl' '--with-mhash' '--enable-bcmath' '--with-bz2' '--with-pic' '--enable-calendar' '--enable-ctype' '--with-gdbm' '--with-db3' '--with-imap-ssl=/usr/local/lib/c-client' '--with-imap=/usr/local/lib/c-client' '--enable-dbase' '--enable-ftp' '--with-iconv' '--with-dom' '--with-exif' '--enable-exif' '--with-gd' '--enable-gd-native-ttf' '--with-jpeg-dir=/usr' '--with-png' '--with-gmp' '--enable-mbstring' '--with-curl=/usr' '--with-pcre-regex=/usr' '--with-mysql=shared,/usr' '--with-gettext=shared,/usr' '--with-expat-dir=/usr' '--with-xml' '--enable-wddx' '--with-mm=/usr' '--enable-trans-sid' '--enable-shmop' '--enable-sockets' '--with-regex=php' '--enable-sysvsem' '--enable-sysvshm' '--enable-yp' '--enable-memory-limit' '--with-tsrm-pthreads' '--enable-shared' '--disable-debug' '--with-zlib=/usr'Server API => Command Line InterfaceVirtual Directory Support => disabledConfiguration File (php.ini) Path => /etc/apache/php.iniPHP API => 20020918PHP Extension => 20020429Zend Extension => 20050606Debug Build => noZend Memory Manager => enabledThread Safety => disabledRegistered PHP Streams => php, http, ftp, https, ftps, compress.bzip2, compress.zlib This program makes use of the Zend Scripting Language Engine:Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies _______________________________________________________________________ConfigurationPHP CoreDirective => Local Value => Master Valueallow_call_time_pass_reference => Off => Offallow_url_fopen => On => Onalways_populate_raw_post_data => Off => Offarg_separator.input => & => &arg_separator.output => & => &asp_tags => Off => Offauto_append_file => no value => no valueauto_prepend_file => no value => no valuebrowscap => no value => no valuedefault_charset => no value => no valuedefault_mimetype => text/html => text/htmldefine_syslog_variables => Off => Offdisable_classes => no value => no valuedisable_functions => no value => no valuedisplay_errors => Off => Offdisplay_startup_errors => Off => Offdoc_root => no value => no valuedocref_ext => no value => no valuedocref_root => no value => no valueenable_dl => On => Onerror_append_string => no value => no valueerror_log => no value => no valueerror_prepend_string => no value => no valueerror_reporting => 2047 => 2047expose_php => On => Onextension_dir => /usr/lib/php/extensions/ => /usr/lib/php/extensions/file_uploads => On => Ongpc_order => GPC => GPChighlight.bg => #FFFFFF => #FFFFFFhighlight.comment => #FF8000 => #FF8000highlight.default => #0000BB => #0000BBhighlight.html => #000000 => #000000highlight.keyword => #007700 => #007700highlight.string => #DD0000 => #DD0000html_errors => Off => Onignore_repeated_errors => Off => Offignore_repeated_source => Off => Offignore_user_abort => Off => Offimplicit_flush => On => Offinclude_path => .:/usr/lib/php => .:/usr/lib/phplog_errors => On => Onlog_errors_max_len => 1024 => 1024magic_quotes_gpc => Off => Offmagic_quotes_runtime => Off => Offmagic_quotes_sybase => Off => Offmax_execution_time => 0 => 30max_input_time => 60 => 60memory_limit => 8M => 8Mopen_basedir => no value => no valueoutput_buffering => 0 => 4096output_handler => no value => no valuepost_max_size => 8M => 8Mprecision => 14 => 14register_argc_argv => On => Offregister_globals => Off => Offreport_memleaks => On => Onsafe_mode => Off => Offsafe_mode_exec_dir => no value => no valuesafe_mode_gid => Off => Offsafe_mode_include_dir => no value => no valuesendmail_from => no value => no valuesendmail_path => /usr/sbin/sendmail -t -i => /usr/sbin/sendmail -t -i serialize_precision => 100 => 100short_open_tag => On => OnSMTP => localhost => localhostsmtp_port => 25 => 25sql.safe_mode => Off => Offtrack_errors => Off => Offunserialize_callback_func => no value => no valueupload_max_filesize => 2M => 2Mupload_tmp_dir => no value => no valueuser_dir => no value => no valuevariables_order => GPCS => GPCSxmlrpc_error_number => 0 => 0xmlrpc_errors => Off => Offy2k_compliance => On => OnbcmathBCMath support => enabledbz2BZip2 Support => EnabledBZip2 Version => 1.0.3, 15-Feb-2005calendarCalendar support => enabledctypectype functions => enabledcurlCURL support => enabledCURL Information => libcurl/7.12.2 OpenSSL/0.9.7g zlib/1.2.3 libidn/0.5.17dbaDBA support => enabledSupported handlers => gdbm cdb cdb_make db3 inifile flatfile domxmlDOM/XML => enabledDOM/XML API Version => 20020815libxml Version => 20622HTML Support => enabledXPath Support => enabledXPointer Support => enabledexifEXIF Support => enabledEXIF Version => 1.4 $Id: exif.c,v 1.118.2.37.2.4 2006/01/01 13:46:52 sniper Exp $Supported EXIF Version => 0220Supported filetypes => JPEG,TIFFftpFTP support => enabledgdGD Support => enabledGD Version => bundled (2.0.28 compatible)GIF Read Support => enabledGIF Create Support => enabledJPG Support => enabledPNG Support => enabledWBMP Support => enabledXBM Support => enabledgettextGetText Support => enabledgmpgmp support => enablediconviconv support => enablediconv implementation => glibciconv library version => 2.3.6Directive => Local Value => Master Valueiconv.input_encoding => ISO-8859-1 => ISO-8859-1iconv.internal_encoding => ISO-8859-1 => ISO-8859-1iconv.output_encoding => ISO-8859-1 => ISO-8859-1imapIMAP c-Client Version => 2004SSL Support => enabledmbstringMultibyte Support => enabledJapanese support => enabledSimplified chinese support => enabledTraditional chinese support => enabledKorean support => enabledRussian support => enabledMultibyte (japanese) regex support => enabled mbstring extension makes use of "streamable kanji code filter and converter", which is distributed under the GNU Lesser General Public License version 2.1. Directive => Local Value => Master Valuembstring.detect_order => no value => no valuembstring.encoding_translation => Off => Offmbstring.func_overload => 0 => 0mbstring.http_input => pass => passmbstring.http_output => pass => passmbstring.internal_encoding => ISO-8859-1 => no valuembstring.language => neutral => neutralmbstring.substitute_character => no value => no valuemhashMHASH support => EnabledMHASH API Version => 20020524mysqlMySQL Support => enabledActive Persistent Links => 0Active Links => 0Client API version => 4.1.20MYSQL_MODULE_TYPE => externalMYSQL_SOCKET => /var/run/mysql/mysql.sockMYSQL_INCLUDE => -I/usr/include/mysqlMYSQL_LIBS => -L/usr/lib -lmysqlclient Directive => Local Value => Master Valuemysql.allow_persistent => On => Onmysql.connect_timeout => 60 => 60mysql.default_host => no value => no valuemysql.default_password => no value => no valuemysql.default_port => no value => no valuemysql.default_socket => no value => no valuemysql.default_user => no value => no valuemysql.max_links => Unlimited => Unlimitedmysql.max_persistent => Unlimited => Unlimitedmysql.trace_mode => Off => OffopensslOpenSSL support => enabledOpenSSL Version => OpenSSL 0.9.7g 11 Apr 2005overloadUser-Space Object Overloading Support => enabledpcntlpcntl support => enabledpcrePCRE (Perl Compatible Regular Expressions) Support => enabledPCRE Library Version => 6.4 05-Sep-2005posixRevision => $Revision: 1.51.2.4.2.1 $sessionSession Support => enabledRegistered save handlers => files user mm Directive => Local Value => Master Valuesession.auto_start => Off => Offsession.bug_compat_42 => Off => Offsession.bug_compat_warn => On => Onsession.cache_expire => 180 => 180session.cache_limiter => nocache => nocachesession.cookie_domain => no value => no valuesession.cookie_lifetime => 0 => 0session.cookie_path => / => /session.cookie_secure => Off => Offsession.entropy_file => no value => no valuesession.entropy_length => 0 => 0session.gc_divisor => 1000 => 1000session.gc_maxlifetime => 1440 => 1440session.gc_probability => 1 => 1session.name => PHPSESSID => PHPSESSIDsession.referer_check => no value => no valuesession.save_handler => files => filessession.save_path => /tmp => /tmpsession.serialize_handler => php => phpsession.use_cookies => On => Onsession.use_only_cookies => Off => Offsession.use_trans_sid => Off => Offshmopshmop support => enabledsocketsSockets Support => enabledstandardRegex Library => Bundled library enabledDynamic Library Support => enabledPath to sendmail => /usr/sbin/sendmail -t -i Directive => Local Value => Master Valueassert.active => 1 => 1assert.bail => 0 => 0assert.callback => no value => no valueassert.quiet_eval => 0 => 0assert.warning => 1 => 1auto_detect_line_endings => 0 => 0default_socket_timeout => 60 => 60safe_mode_allowed_env_vars => PHP_ => PHP_safe_mode_protected_env_vars => LD_LIBRARY_PATH => LD_LIBRARY_PATHurl_rewriter.tags => a=href,area=href,frame=src,input=src,form=fakeentry => a=href,area=href,frame=src,input=src,form=fakeentryuser_agent => no value => no valuetokenizerTokenizer Support => enabledwddxWDDX Support => enabledWDDX Session Serializer => enabledxmlXML Support => activeXML Namespace Support => activeEXPAT Version => expat_1.95.8ypYP Support => enabledzlibZLib Support => enabledCompiled Version => 1.2.3Linked Version => 1.2.3Directive => Local Value => Master Valuezlib.output_compression => Off => Offzlib.output_compression_level => -1 => -1zlib.output_handler => no value => no valueAdditional ModulesModule NamedbasesysvsemsysvshmEnvironmentVariable => ValueCPLUS_INCLUDE_PATH => /usr/lib/qt/includeMANPATH => /usr/local/man:/usr/man:/usr/X11R6/man:/usr/lib/java/man:/opt/kde/man:/usr/lib/qt/doc/man:/usr/share/texmf/manHZ => 100HOSTNAME => 314.slackwareSHELL => /bin/bashTERM => xtermWINDOWID => 25165826HUSHLOGIN => FALSEQTDIR => /usr/lib/qtUSER => invertLS_COLORS => no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.bat=01;32:*.BAT=01;32:*.btm=01;32:*.BTM=01;32:*.cmd=01;32:*.CMD=01;32:*.com=01;32:*.COM=01;32:*.dll=01;32:*.DLL=01;32:*.exe=01;32:*.EXE=01;32:*.arj=01;31:*.bz2=01;31:*.deb=01;31:*.gz=01;31:*.lzh=01;31:*.rpm=01;31:*.tar=01;31:*.taz=01;31:*.tb2=01;31:*.tbz2=01;31:*.tbz=01;31:*.tgz=01;31:*.tz2=01;31:*.z=01;31:*.Z=01;31:*.zip=01;31:*.ZIP=01;31:*.zoo=01;31:*.asf=01;35:*.ASF=01;35:*.avi=01;35:*.AVI=01;35:*.bmp=01;35:*.BMP=01;35:*.flac=01;35:*.FLAC=01;35:*.gif=01;35:*.GIF=01;35:*.jpg=01;35:*.JPG=01;35:*.jpeg=01;35:*.JPEG=01;35:*.m2a=01;35:*.M2a=01;35:*.m2v=01;35:*.M2V=01;35:*.mov=01;35:*.MOV=01;35:*.mp3=01;35:*.MP3=01;35:*.mpeg=01;35:*.MPEG=01;35:*.mpg=01;35:*.MPG=01;35:*.ogg=01;35:*.OGG=01;35:*.ppm=01;35:*.rm=01;35:*.RM=01;35:*.tga=01;35:*.TGA=01;35:*.tif=01;35:*.TIF=01;35:*.wav=01;35:*.WAV=01;35:*.wmv=01;35:*.WMV=01;35:*.xbm=01;35:*.xpm=01;35:GDK_USE_XFT => 1KDEDIR => /opt/kdeT1LIB_CONFIG => /usr/share/t1lib/t1lib.configMINICOM => -c onMAIL => /var/spool/mail/invertPATH => /usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/opt/www/htdig/bin:/usr/lib/java/bin:/usr/lib/java/jre/bin:/opt/kde/bin:/usr/lib/qt/bin:/usr/share/texmf/bin:.LC_COLLATE => CINPUTRC => /etc/inputrcPWD => /home/invertJAVA_HOME => /usr/lib/javaLANG => en_USCOLORFGBG => 0;default;15SHLVL => 4HOME => /home/invertLS_OPTIONS => --color=auto -F -b -T 0LESS => -MLOGNAME => invertLESSOPEN => |lesspipe.sh %sDISPLAY => :0.0COLORTERM => rxvt-xpmXAUTHORITY => /home/invert/.Xauthority_ => /usr/bin/phpPHP VariablesVariable => Value_SERVER["CPLUS_INCLUDE_PATH"] => /usr/lib/qt/include_SERVER["MANPATH"] => /usr/local/man:/usr/man:/usr/X11R6/man:/usr/lib/java/man:/opt/kde/man:/usr/lib/qt/doc/man:/usr/share/texmf/man_SERVER["HZ"] => 100_SERVER["HOSTNAME"] => 314.slackware_SERVER["SHELL"] => /bin/bash_SERVER["TERM"] => xterm_SERVER["WINDOWID"] => 25165826_SERVER["HUSHLOGIN"] => FALSE_SERVER["QTDIR"] => /usr/lib/qt_SERVER["USER"] => invert_SERVER["LS_COLORS"] => no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.bat=01;32:*.BAT=01;32:*.btm=01;32:*.BTM=01;32:*.cmd=01;32:*.CMD=01;32:*.com=01;32:*.COM=01;32:*.dll=01;32:*.DLL=01;32:*.exe=01;32:*.EXE=01;32:*.arj=01;31:*.bz2=01;31:*.deb=01;31:*.gz=01;31:*.lzh=01;31:*.rpm=01;31:*.tar=01;31:*.taz=01;31:*.tb2=01;31:*.tbz2=01;31:*.tbz=01;31:*.tgz=01;31:*.tz2=01;31:*.z=01;31:*.Z=01;31:*.zip=01;31:*.ZIP=01;31:*.zoo=01;31:*.asf=01;35:*.ASF=01;35:*.avi=01;35:*.AVI=01;35:*.bmp=01;35:*.BMP=01;35:*.flac=01;35:*.FLAC=01;35:*.gif=01;35:*.GIF=01;35:*.jpg=01;35:*.JPG=01;35:*.jpeg=01;35:*.JPEG=01;35:*.m2a=01;35:*.M2a=01;35:*.m2v=01;35:*.M2V=01;35:*.mov=01;35:*.MOV=01;35:*.mp3=01;35:*.MP3=01;35:*.mpeg=01;35:*.MPEG=01;35:*.mpg=01;35:*.MPG=01;35:*.ogg=01;35:*.OGG=01;35:*.ppm=01;35:*.rm=01;35:*.RM=01;35:*.tga=01;35:*.TGA=01;35:*.tif=01;35:*.TIF=01;35:*.wav=01;35:*.WAV=01;35:*.wmv=01;35:*.WMV=01;35:*.xbm=01;35:*.xpm=01;35:_SERVER["GDK_USE_XFT"] => 1_SERVER["KDEDIR"] => /opt/kde_SERVER["T1LIB_CONFIG"] => /usr/share/t1lib/t1lib.config_SERVER["MINICOM"] => -c on_SERVER["MAIL"] => /var/spool/mail/invert_SERVER["PATH"] => /usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/opt/www/htdig/bin:/usr/lib/java/bin:/usr/lib/java/jre/bin:/opt/kde/bin:/usr/lib/qt/bin:/usr/share/texmf/bin:._SERVER["LC_COLLATE"] => C_SERVER["INPUTRC"] => /etc/inputrc_SERVER["PWD"] => /home/invert_SERVER["JAVA_HOME"] => /usr/lib/java_SERVER["LANG"] => en_US_SERVER["COLORFGBG"] => 0;default;15_SERVER["SHLVL"] => 4_SERVER["HOME"] => /home/invert_SERVER["LS_OPTIONS"] => --color=auto -F -b -T 0_SERVER["LESS"] => -M_SERVER["LOGNAME"] => invert_SERVER["LESSOPEN"] => |lesspipe.sh %s_SERVER["DISPLAY"] => :0.0_SERVER["COLORTERM"] => rxvt-xpm_SERVER["XAUTHORITY"] => /home/invert/.Xauthority_SERVER["_"] => /usr/bin/php_SERVER["PHP_SELF"] => _SERVER["SCRIPT_NAME"] => _SERVER["SCRIPT_FILENAME"] => _SERVER["PATH_TRANSLATED"] => _SERVER["DOCUMENT_ROOT"] => _SERVER["argv"] => Array()_SERVER["argc"] => 0PHP LicenseThis program is free software; you can redistribute it and/or modifyit under the terms of the PHP License as published by the PHP Groupand included in the distribution in the file: LICENSEThis program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.If you did not receive a copy of the PHP license, or have anyquestions about PHP licensing, please contact license@php.net.[/code]edit:sp Quote Link to comment https://forums.phpfreaks.com/topic/13617-my-first-php-scripts-wont-execute-solved/#findComment-53671 Share on other sites More sharing options...
Drone4four Posted July 11, 2006 Author Share Posted July 11, 2006 My second script in PHP is a settype exercise. It looks like this:[code]<!DOCTYPE html PUBLIC"-//W3C// DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml/DTD/xhtml1-strict.dtd"><html><head><title>Listing 4.2 Changing the Type of a variable with settype()</title></head></html><body><div><?php$undecided = 3.14;print gettype( $undecided ); // doubleprint "-- $undecided<br />"; //3.14settype( $undecided, string );print gettype( $undecided ); // stringprint "-- $undecided<br />"; //3.14settype( $undecided, int );print gettype( $undecided ); // integerprint " -- $undecided<br />"; // 3settype( $undecided, double );print gettype( $undecided<br />"; // doubleprint " -- $undecided<br />"; // 3.0settype( $undecided, bool );print gettype( $undecided ); //booleanprint " -- $undecided<br />; // 1?>,/div></body></html>[/code] That script produces this error:[code]bash-3.1$ php settypePHPExercise.phpPHP Parse error: syntax error, unexpected '>' in /home/invert/programming/settypePHPExercise.php on line 22bash-3.1$ [/code] I can't figure out what's wrong with my line 22. Can you? Quote Link to comment https://forums.phpfreaks.com/topic/13617-my-first-php-scripts-wont-execute-solved/#findComment-55962 Share on other sites More sharing options...
Dville Posted July 11, 2006 Share Posted July 11, 2006 [code],/div>[/code]should be[code]</div>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13617-my-first-php-scripts-wont-execute-solved/#findComment-55968 Share on other sites More sharing options...
kenrbnsn Posted July 11, 2006 Share Posted July 11, 2006 Yes, the </div> tag is incorrect, but PHP shouldn't be complaining about it. What's really wrong is that you forgot the terminating double quote on this line:[code]<?php print " -- $undecided<br />; // 1?>[/code]It should be written:[code]<?php print " -- $undecided<br />"; // 1?>[/code]Ken Quote Link to comment https://forums.phpfreaks.com/topic/13617-my-first-php-scripts-wont-execute-solved/#findComment-55990 Share on other sites More sharing options...
Drone4four Posted July 11, 2006 Author Share Posted July 11, 2006 According to itrebal on freenode, “well $testing; doesn't declare the variable - you avhe to actually set it to something.” Further, “you cant output HTML with the variable like that.” I didn’t really know what itrebal was talking about so I asked him, “wtf?” itrebal recommended http://ca3.php.net/strings and http://us3.php.net/manual/en/language.types.string.phpI'll respond to the the posts made by kenrbnsn and Dville soon. Quote Link to comment https://forums.phpfreaks.com/topic/13617-my-first-php-scripts-wont-execute-solved/#findComment-55999 Share on other sites More sharing options...
Drone4four Posted July 11, 2006 Author Share Posted July 11, 2006 [quote author=kenrbnsn link=topic=99377.msg394900#msg394900 date=1152589782]Yes, the </div> tag is incorrect, but PHP shouldn't be complaining about it. What's really wrong is that you forgot the terminating double quote on this line:[code]<?php print " -- $undecided<br />; // 1?>[/code]It should be written:[code]<?php print " -- $undecided<br />"; // 1?>[/code][/quote][quote author=Dville link=topic=99377.msg394875#msg394875 date=1152585537][code],/div>[/code]should be[code]</div>[/code]Ken[/quote]Thanks for the quick replies. But even with these two corrections, line 22 is still some how problematic. Quote Link to comment https://forums.phpfreaks.com/topic/13617-my-first-php-scripts-wont-execute-solved/#findComment-56013 Share on other sites More sharing options...
bodenzord Posted July 11, 2006 Share Posted July 11, 2006 This following line is incorrect:[code]print gettype( $undecided<br />"; // double[/code]Change it to:[code]print gettype( $undecided<br />); // double[/code]Notice that you have a quote at the end just before the semi-colon that is supposed to be a closing parenthesis. Quote Link to comment https://forums.phpfreaks.com/topic/13617-my-first-php-scripts-wont-execute-solved/#findComment-56023 Share on other sites More sharing options...
Drone4four Posted July 11, 2006 Author Share Posted July 11, 2006 Thanks bodenzord for the parenthesis correction. I'm still getting an error for line 22. Here is what my script looks like now: [code]<!DOCTYPE html PUBLIC"-//W3C// DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml/DTD/xhtml1-strict.dtd"><html><head><title>Listing 4.2 Changing the Type of a variable with settype()</title></head></html><body><div><?php$undecided = 3.14;print gettype( $undecided ); // doubleprint "-- $undecided<br />"; //3.14settype( $undecided, string );print gettype( $undecided ); // stringprint "-- $undecided<br />"; //3.14settype( $undecided, int );print gettype( $undecided ); // integerprint " -- $undecided<br />"; // 3settype( $undecided, double );print gettype( $undecided<br />); // doubleprint " -- $undecided<br />"; // 3.0settype( $undecided, bool );print gettype( $undecided ); //booleanprint " -- $undecided<br />"; // 1?></div></body></html>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13617-my-first-php-scripts-wont-execute-solved/#findComment-56025 Share on other sites More sharing options...
bodenzord Posted July 11, 2006 Share Posted July 11, 2006 Okay...the problem was that you had <br /> on line 22 that should not have been there. Check out the corrected code:[code]<!DOCTYPE html PUBLIC"-//W3C// DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml/DTD/xhtml1-strict.dtd"><html><head><title>Listing 4.2 Changing the Type of a variable with settype()</title></head></html><body><div><?php$undecided = 3.14;print gettype( $undecided ); // doubleprint "-- $undecided<br />"; //3.14settype( $undecided, string );print gettype( $undecided ); // stringprint "-- $undecided<br />"; //3.14settype( $undecided, int );print gettype( $undecided ); // integerprint " -- $undecided<br />"; // 3settype( $undecided, double );print gettype( $undecided); // doubleprint " -- $undecided<br />"; // 3.0settype( $undecided, bool );print gettype( $undecided ); //booleanprint " -- $undecided<br />"; // 1?></div></body></html>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13617-my-first-php-scripts-wont-execute-solved/#findComment-56034 Share on other sites More sharing options...
Drone4four Posted July 17, 2006 Author Share Posted July 17, 2006 [quote author=bodenzord link=topic=99377.msg394950#msg394950 date=1152596732]Okay...the problem was that you had <br /> on line 22 that should not have been there. Check out the corrected code:[code]<!DOCTYPE html PUBLIC"-//W3C// DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml/DTD/xhtml1-strict.dtd"><html><head><title>Listing 4.2 Changing the Type of a variable with settype()</title></head></html><body><div><?php$undecided = 3.14;print gettype( $undecided ); // doubleprint "-- $undecided<br />"; //3.14settype( $undecided, string );print gettype( $undecided ); // stringprint "-- $undecided<br />"; //3.14settype( $undecided, int );print gettype( $undecided ); // integerprint " -- $undecided<br />"; // 3settype( $undecided, double );print gettype( $undecided); // doubleprint " -- $undecided<br />"; // 3.0settype( $undecided, bool );print gettype( $undecided ); //booleanprint " -- $undecided<br />"; // 1?></div></body></html>[/code][/quote]Uhm, when I run bodenzord's modified script, I get this:[code]bash-3.1$ php firstPHPscript-bodenzord.php <!DOCTYPE html PUBLIC"-//W3C// DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml/DTD/xhtml1-strict.dtd"><html><head><title>Listing 4.2 Changing the Type of a variable with settype()</title></head></html><body><div>double-- 3.14<br />PHP Notice: Use of undefined constant string - assumed 'string' in /home/invert/programming/PHP/firstPHPscript-bodenzord.php on line 15string-- 3.14<br />PHP Notice: Use of undefined constant int - assumed 'int' in /home/invert/programming/PHP/firstPHPscript-bodenzord.php on line 18integer -- 3<br />PHP Notice: Use of undefined constant double - assumed 'double' in /home/invert/programming/PHP/firstPHPscript-bodenzord.php on line 21double -- 3<br />PHP Notice: Use of undefined constant bool - assumed 'bool' in /home/invert/programming/PHP/firstPHPscript-bodenzord.php on line 24boolean -- 1<br /></div></body></html>bash-3.1$ [/code]What's going on here? What am I doing wrong?edit:sp Quote Link to comment https://forums.phpfreaks.com/topic/13617-my-first-php-scripts-wont-execute-solved/#findComment-59146 Share on other sites More sharing options...
True`Logic Posted July 17, 2006 Share Posted July 17, 2006 [code]<?php$testing; // declare without assigningprint gettype ($testing ); //NULLprint "<br />";$testing = 5;print gettype( $testing ); //integerprint "<br />";$testing = "five";print gettype( $testing ); // stringprint "<br />";$testing = 5.0print gettype( $testing ); // doubleprint "<br />";$testing = true;print gettype( $testing ); // booleanprint "<br />";?>[/code]print sucks for one, use echo.. for 2, you forgot a semicolon, 3, all that unneeded whitespace adds to your filesize, get rid of it..[code]<?php$testing = ""; // declare without assigningecho gettype($testing); //NULLecho "<br>";$testing = 5;echo gettype($testing); //integerecho "<br>";$testing = "five";echo gettype($testing); // stringecho "<br>";$testing = 5.0;echo gettype($testing); // doubleecho "<br>";$testing = true;echo gettype($testing); // booleanecho "<br>";/* returns:string<br>integer<br>string<br>double<br>boolean<br>*/?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13617-my-first-php-scripts-wont-execute-solved/#findComment-59173 Share on other sites More sharing options...
Drone4four Posted July 17, 2006 Author Share Posted July 17, 2006 Thanks True`Logic, your version of my script executed perfectly . Quote Link to comment https://forums.phpfreaks.com/topic/13617-my-first-php-scripts-wont-execute-solved/#findComment-59195 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.