Jump to content

Search the Community

Showing results for tags '#php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 5 results

  1. I'm working on my php skills and I run .php files on XAMPP server but it signals parse error even when php code checker sees no problem. This is one of the codes that I wrote: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/ xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head>5 <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Quotes</title> </head> <body> <?php // Script 2.4 - pursue3.php $name = "M"; $age = 29; $lastname = 'B'; $nationality = "S"; print "<h1>Basic Info</h1><p>My name is $name, I am $age years old.<br/>My nationality is $nationality. My lastname is $lastname</p>" ?> </body> </html> When I execute this code on my localhost it says: "Parse error: syntax error, unexpected '?' in C:\xampp\htdocs\my-site\pursue3.php on line 18" It happened with last 3 php files that I wrote. I know what a parse error is, I just don't see where I made any mistake.
  2. I wrote this correct code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Upload a File</title> </head> <body> <?php // Script 11.4 - upload_file.php if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (move_uploaded_file($FILES['the_file']['tmp_name'],"../uploads/{$_FILES['the_file']['name']}")) { print '<p>Your file has been uploaded.</p>'; } else { print '<p style="color:red;">Your file could not be uploaded because: '; switch($_FILES['the_file']['error']) { case 1: print 'The file exeeds upload_max_filesize setting in php.ini'; break; case 2: print 'The file exeeds MAX_FILE_SIZE setting in the HTML form'; break; case 3: print 'The file was only partially uploaded'; break; case 4: print 'No file was uploaded.'; break; case 6: print 'The temporary folder does not exist.'; default: print 'Somethin unforseen happened.'; break; print '.</p>'; } } } ?> <form action="upload_file.php" enctype="multipart/form-data" method="post"> <p>Upload a file using this form: </p> <input type="hidden" name="MAX_FILE_SIZE" value="300000" /> <p><input type="file" name="the_file" /></p> <p><input type="submit" name="submit" value="Upload this file" /></p> </form> </body> </html> I ran this code through browser, uploaded a file that I named 'the_file' and I received error 6: Your file could not be uploaded because: Something unforseen happened. Is there something that I'm missing here?
  3. I'm working of registration form and I have a problem with understanding one of the codes. <?php // Script 8.9 - register.php define ('DEFINE', 'register'); include('templates/header.html'); print '<h2>Registration Form</h2> <p>Register so that you can take advantage of certain features like this, that, and the other things</p>'; print '<style type="text/css" media="screen"> .error { color: red; } </style>'; if ($_SERVER['REQUESTED_METHOD'] == 'POST') { $problem = FALSE; if (empty($_POST['first_name'])) { $problem = TRUE; print '<p class="error">Please enter your first name!</p>'; } if (empty($_POST['last_name'])) { $problem = TRUE; print '<p class="error">Please enter your last name!</p>'; } if (empty($_POST[email'])) { $problem = TRUE; print '<p class="error">Please enter your email address.</p>'; } if (empty($_POST['password1'])) { $problem = TRUE; print '<p class="error">Please enter a password.</p>'; } if ($_POST['password1'] != $_POST['password2']) { $problem = TRUE; print '<p class="error">Your password did not match your confirm password.</p>'; } if (!$problem) { print '<p>You are now registered.</p>' } $_POST = array(); } else { print '<p class="error">Please try again!</p> } } ?> this part: if (!$problem) { print '<p>You are now registered.</p>' } Why are we using exclamation mark here? I already defined $problem = FALSE at the beginning of the whole code. That means that there is no problem. If we reverse it to TRUE it will mean that there is a problem with registration but in that case the user shouldn't see "You are now registered". The if condition is fulfilled in any case because with don't have any '<', '>' or '=='.
  4. Truman

    array_diff_key()

    I don't understand this array function although I read php manual. This is an example: <?php $array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4); $array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8); var_dump(array_diff_key($array1, $array2)); ?> and this is output: array(2) { ["red"]=> int(2) ["purple"]=> int(4)} I don't see any connection here, why is for example key red different from the key blue in the second array but the key blue from the first arrays differs from the key green in the second array? Or I got this completely wrong?
  5. Truman

    PHP problems

    Hi, I was hoping that you could help we with this problem. First, I need to make $name variable with my name. After that, using knowledge of strlen(string), rand(min, max), and substr(string, start, length) I need to print a random character from my name. It's a codeacademy problem. So it shouldn't be a number, only one of letters of my name.
×
×
  • Create New...