Jump to content

mrooks1984

Members
  • Posts

    82
  • Joined

  • Last visited

    Never

Everything posted by mrooks1984

  1. got to the bottom of it as soon as i moved the contents of the db file to the home.php and replaced the inc db code it works. so know i need to figure out how i can get it to work using the databse file as i dont want username passwords db names etc on the home page. any ideas i be greatful, thanks all
  2. the actual db file i am using on the 1and1 server is this i have changed username and password. the one on my local xampp test server is the one at the top of the page with localhost //Setup Our Connection Vars $obj->host = 'db1222.oneandone.co.uk'; $obj->username = 'username'; $obj->password = 'password'; $obj->db = 'db361371865'; //Connect To Our Database $obj->connect(); hope this helps, thanks again.
  3. hello, thats what i had done double checked the details and they are correct, but got the message, i left the database file like that as dident want to post my actual username password etc on a public forum. i have to keep looking to try find out why its not working, thanks again
  4. hello, thanks for your responce no the mysql server is not the localhost and no i am not connecting using root, i am trying to learn php and was told this is a better way of creating a blog related site. could you point me in the right direction of what i would need to do to the db file to make it work with remote mysql servers. thanks again, mike
  5. hi all, i have a test server (newest xampp) and the code works fine, as soon as i upload to 1and1 (they use apachi, php and mysql) i get this message: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) i have double checked username and passwords, had a look on google, contacted there support with no luck yet. i am wondering if its a mysql or php version problem, so hoping someone knows when the following code with classes etc was added or if someone knows how to fix it i be really greatful. heres some of the code i am using class cyberglide { var $host; var $username; var $password; var $db; function connect() { $con = mysql_connect($this->host, $this->username, $this->password) or die (mysql_error()); mysql_select_db($this->db, $con) or die(mysql_error()); } function get_top() { if (isset($_GET['page'])) { $page = $_GET['page']; // Display Page. $sql = "SELECT title,body FROM content WHERE page = '$page' AND location = 'left' AND disabled = 'no' ORDER BY id"; $res = mysql_query($sql) or die (mysql_error()); while($row = mysql_fetch_assoc($res)){ echo '<h1>' . $row['title'] . '</h1>'; echo '<p>' . $row['body'] . '</p>'; } } else { //Show Home Page $sql = "SELECT title,body FROM content WHERE page = 'home' AND location = 'left' AND disabled = 'no' ORDER BY id"; $res = mysql_query($sql) or die (mysql_error()); while($row = mysql_fetch_assoc($res)){ echo '<h1>' . $row['title'] . '</h1>'; echo '<p>' . $row['body'] . '</p>'; } } } function get_left() { if (isset($_GET['page'])) { $page = $_GET['page']; // Display Page. $sql = "SELECT title,body FROM content WHERE page = '$page' AND location = 'left' AND disabled = 'no' ORDER BY id"; $res = mysql_query($sql) or die (mysql_error()); while($row = mysql_fetch_assoc($res)){ echo '<h1>' . $row['title'] . '</h1>'; echo '<p>' . $row['body'] . '</p>'; } } else { //Show Home Page $sql = "SELECT title,body FROM content WHERE page = 'home' AND location = 'left' AND disabled = 'no' ORDER BY id"; $res = mysql_query($sql) or die (mysql_error()); while($row = mysql_fetch_assoc($res)){ echo '<h1>' . $row['title'] . '</h1>'; echo '<p>' . $row['body'] . '</p>'; } } } }//Ends Our Class db file //Setup Our Connection Vars $obj->host = 'localhost'; $obj->username = 'root'; $obj->password = ''; $obj->db = 'db361371865'; //Connect To Our Database $obj->connect(); many thanks all.
  6. thanks for you reply i am a newbie learning or tring to learn php, what do you mean by check it? i have tried removing the 0 as i knew it was something to do with that part but it dident work.
  7. hello all, i am stuck with a problem and hoping someone can help me. i have got the following code to sort of work. the problem i am having is when i put e.g. index.php?page=test and there is no information with test under page in the sqlite db i get this message, Notice: Undefined offset: 0 in C:\xampp\htdocs\test\Frontend\left.php on line 8. as soon as i type index.php?page=test2 and i have test2 in the database the error is gone and shows the content heres the code if (isset($_GET['page'])) { $page = $_GET['page']; // Display Page. $query = "SELECT body FROM content WHERE page = '$page' AND location = 'left' AND disabled = 'no' ORDER BY id"; $results = $base->arrayQuery($query, SQLITE_ASSOC); $arr = $results[0]; echo '<div id="left">'; echo '<p>' . $arr['body'] . '</p>'; echo '</div>'; } else { //Show Home Page $query = "SELECT body FROM content WHERE page = 'home' AND location = 'left' AND disabled = 'no' ORDER BY id"; $results = $base->arrayQuery($query, SQLITE_ASSOC); $arr = $results[0]; echo '<div id="left">'; echo '<p>' . $arr['body'] . '</p>'; echo '</div>'; } hope you understand what i am trying to say, thanks very much all.
×
×
  • 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.