Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-10-2013, 09:16 AM   PM User | #1
tarasmuz
New Coder

 
Join Date: Oct 2012
Location: Edinburgh
Posts: 10
Thanks: 3
Thanked 0 Times in 0 Posts
tarasmuz is an unknown quantity at this point
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



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;
tarasmuz is offline   Reply With Quote
Old 02-10-2013, 11:22 AM   PM User | #2
LearningCoder
Regular Coder

 
LearningCoder's Avatar
 
Join Date: Jan 2011
Location: The Pleiades
Posts: 849
Thanks: 67
Thanked 28 Times in 28 Posts
LearningCoder is an unknown quantity at this point
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.
LearningCoder is offline   Reply With Quote
Old 02-10-2013, 11:58 AM   PM User | #3
tarasmuz
New Coder

 
Join Date: Oct 2012
Location: Edinburgh
Posts: 10
Thanks: 3
Thanked 0 Times in 0 Posts
tarasmuz is an unknown quantity at this point
Got it. Thanks

Last edited by tarasmuz; 02-10-2013 at 12:15 PM.. Reason: Got it
tarasmuz is offline   Reply With Quote
Old 02-10-2013, 06:36 PM   PM User | #4
LearningCoder
Regular Coder

 
LearningCoder's Avatar
 
Join Date: Jan 2011
Location: The Pleiades
Posts: 849
Thanks: 67
Thanked 28 Times in 28 Posts
LearningCoder is an unknown quantity at this point
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.
LearningCoder is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:40 AM.


Advertisement
Log in to turn off these ads.