CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   PHP (http://www.codingforums.com/forumdisplay.php?f=6)
-   -   An error in my PHP (http://www.codingforums.com/showthread.php?t=287404)

tarasmuz 02-10-2013 09:16 AM

An error in my PHP
 
Hi, I'm getting this error when I press an action button on my page and I'm not sure on how to solve it

http://cs405822.userapi.com/v4058227...ealCXj0CT4.jpg

This is the code from that page:
PHP Code:

<?php
require_once "../include/config.php";
require_once 
"../include/ShortUrl.php";

if (
$_SERVER["REQUEST_METHOD"] != "POST" || empty($_POST["url"])) {
    
header("Location: shorten.html");
    exit;


try {
    
$pdo = new PDO(DB_PDODRIVER ":host=" DB_HOST ";dbname=" DB_DATABASE,
        
DB_USERNAMEDB_PASSWORD);
}
catch (
PDOException $e) {
    
header("Location: error.html");
    exit;
}

$shortUrl = new ShortUrl($pdo);
try {
    
$code $shortUrl->urlToShortCode($_POST["url"]);
}
catch (
Exception $e) {
    
header("Location: error.html");
    exit;
}
$url SHORTURL_PREFIX $code;

echo <<<ENDHTML
<html>
 <head>
  <title>URL Shortener</title>
 </head>
 <body>
  <p><strong>Short URL:</strong> <a href="$url">$url</a></p>
 </body>
</html>
ENDHTML;


LearningCoder 02-10-2013 11:22 AM

It means the file path you have written for that require_once statement is wrong.

Because you are calling that file within your submit.php script, you need to make your file paths relative to the submit.php file.

Kind regards,

Lc.

tarasmuz 02-10-2013 11:58 AM

Got it. Thanks

LearningCoder 02-10-2013 06:36 PM

How are you getting on with it?

Just got back online today so let us know if you sorted it and if not, give us a description of how you have your structure set up and we may be able to give you the correct code in order for your code to work.

Kind regards,

Lc.


All times are GMT +1. The time now is 03:25 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.