Jump to content

uploading to a server


j05hr

Recommended Posts

my problem is that when i upload any php to my server it doesn't work, with this simple test code it comes out blank on the page when i upload it to the server maybe it's my login information that's wrong or maybe the code or maybe i'm putting the code in the wrong location when i upload it. or maybe my database is wrong. any help will be appreciated

 

i have two bits of code one called dbconncect.php

 

dbtest.php

<?php
   DEFINE ('HOST', 'jasongold.org');
   DEFINE ('USER', 'user');
   DEFINE ('PASS', 'example');
   DEFINE ('MYDB', 'jason_gold');
?>

 

and another one just a test

 

dbconnect.php

<?php
   require_once('../../dbconnect.php');
    error_reporting(E_ALL);
   $dbc = mysql_connect(HOST, USER, PASS) OR die("Unable to connect to database: " . mysql_error());
   mysql_select_db(MYDB) OR die("Unable to select database: " . mysql_error($dbc))
  
   $query = "INSERT INTO jason_gold (name, email_address) VALUES ('Kevin', '[email protected]')";
   $result = mysql_query($query);

   if(mysql_affected_rows() == 1)
   {
      echo "Insert successful!";
   }
   else
   {
      echo "Something went wrong!";
   }
?>

 

image of database

800515_database.JPG

Link to comment
https://forums.phpfreaks.com/topic/126994-uploading-to-a-server/
Share on other sites

Try:

 

<?php
   error_reporting(E_ALL);
   require_once('../../dbconnect.php');
   $dbc = mysql_connect(HOST, USER, PASS) OR die("Unable to connect to database: " . mysql_error());
   mysql_select_db(MYDB) OR die("Unable to select database: " . mysql_error($dbc))
  
   $query = "INSERT INTO jason_gold (name, email_address) VALUES ('Kevin', '[email protected]')";
   $result = mysql_query($query);

   if(mysql_affected_rows() == 1)
   {
      echo "Insert successful!";
   }
   else
   {
      echo "Something went wrong!";
   }
?>

still getting a blank screen, when i type in a filename i haven't uploaded i get the message

 

Not Found

 

The requested URL /fthth.php was not found on this server.

 

which means it must recognise it at it comes up blank?

 

also when i type in another bit of php i've done i get the message

 

Database connection failed: Access denied for user 'root'@'localhost' (using password: YES)

 

so again it recognises it but doesn't work either

Put both of the following lines immediately after your first <?php tag (display_errors is probably and should be OFF on a live server) -

 

ini_set ("display_errors", "1");
error_reporting(E_ALL);

 

Also, have you tested this code first on a local development system so that you know it is free of parse errors?

i hadn't actually tested it on a local server yet which was silly.

 

i got this error for it

 

Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\test\dbtest.php on line 7

 

i had also changed my code back to how it was originally so this is what it was, i think the error message has something to do with my database.

<?php
   require_once('../../dbconnect.php');

   $dbc = mysql_connect(HOST, USER, PASS) OR die("Unable to connect to database: " . mysql_error());
   mysql_select_db(MYDB) OR die("Unable to select database: " . mysql_error($dbc))
   
   $query = "INSERT INTO jason_gold (name, email_address) VALUES ('Kevin', '[email protected]')";
   $result = mysql_query($query);

   if(mysql_affected_rows() == 1)
   {
      echo "Insert successful!";
   }
   else
   {
      echo "Something went wrong!";
   }
?>

i now get this error

 

 

Warning: require_once(../../dbconnect.php) [function.require-once]: failed to open stream: No such file or directory in C:\wamp\www\test\dbtest.php on line 2

 

Fatal error: require_once() [function.require]: Failed opening required '../../dbconnect.php' (include_path='.;C:\php5\pear') in C:\wamp\www\test\dbtest.php on line 2

 

is it saying the dbconnect file doesn't exsist?

i'm now using a different bit of code to upload and i get this message

 

Database selection failed: Unknown database 'widget_corp'

 

i know the database definately exsists because i used it on the local machine and it worked fine but when i upload it to the server it says it doesn't recognise it.

 

www.jasongold.org/index.php

still can't get it to work the error message being

 

Database selection failed: Unknown database ' widget_corp'

 

the database definately exsists

 

here's the code

 

constants.php

<?php

// Database Constants
define("DB_SERVER", 'localhost');
define("DB_USER", 'root);
define("DB_PASS", 'example');
define("DB_NAME", 'widget_corp');

?>

 

connection.php

<?php
require("constants.php");

// 1. Create a database connection
$connection = mysql_connect(DB_SERVER,DB_USER,DB_PASS);
if (!$connection) {
die("Database connection failed: " . mysql_error());
}

// 2. Select a database to use 
$db_select = mysql_select_db(DB_NAME,$connection);
if (!$db_select) {
die("Database selection failed: " . mysql_error());
}
?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.