Jump to content

Website Help


tier1rep

Recommended Posts

I have been asked to host a website on my server which is no problem. The site loads just fine but the issue im having is getting the php to link to the mysql database. im not that versed in PHP other then to make the updates in it to link to my mysql which is where im still having the problem. i have the info in right but it still wont connect. i made a test php to test access to the mysql and it is working fine. if someone would mind taking a look at these webfiles and give me some input i would appreciate it. listed below will be all the info. thanks

 

 

Server info:

Windows server 2008 sp1

webserver IIS7

PHP 5

mysql 5.5

PHPmyadmin 3.5.3

website name: http://millercomputerrepair.com

 

I made a test php to make sure the database was allowing access, here is the test address. it did pull data from the database and table. below is the test php

 

http://millercomputerrepair.com/test1.php

 

Please Help me!!

 

 

 

Website Files -------->>> http://millercomputerrepair.com/Miller.zip

Link to comment
Share on other sites

You link a database to php through a php connection script.

 

Ex:

 

<?php

//Define connection settings
$host = "localhost";
$user = "root";
$pass = "";
$database = "database name";

//Connect
$con = mysql_connect($host, $user, $pass) or die("Could not connect.");

//Select the database your website gets its content from
$db = mysql_select_db($database) or die("Could not select database.");

?>

Link to comment
Share on other sites

thanks for the response but i didnt build the pages, im just trying to make them work... there is coding just like that already on the page.. but what im saying is i dont understand why it still doest work.. did you take a look at the zipfile i posted. i have updated the host, user, pass, databasename already but it still wont connect. im not sure if something else is wrong. dream weaver finds not syntax errors which is why im lost... I have listed a zip file with the website in it if you care to look at the actual site and code.

 

thanks

Link to comment
Share on other sites

this is the coding on the index page

 

 

<?
//MySQL Variables
$db_host = "localhost";
$db_user = "pmiller";
$db_name = "murrayju_miller";
$db_pass = "admin191";

$connect = mysql_connect("$db_host","$db_user","$db_pass");
$select_db = mysql_select_db("$db_name");

$q = mysql_query("INSERT INTO `fields` ( `id` , `name` , `content` ) VALUES (NULL , 'setup', 'mer');", $connect);
$q = mysql_query("INSERT INTO `fields` ( `id` , `name` , `content` ) VALUES (NULL , 'upgrades', 'mer');", $connect);
$q = mysql_query("INSERT INTO `fields` ( `id` , `name` , `content` ) VALUES (NULL , 'dataretrieval', 'mer');", $connect);
$q = mysql_query("INSERT INTO `fields` ( `id` , `name` , `content` ) VALUES (NULL , 'virus', 'mer');", $connect);
?>

 

 

and there is similar cable on all other pages

Link to comment
Share on other sites

Whats with all the inserts? O.o

 

Have you also tried using a php.ini file?

 

If not - create one and type into it:

 

display_errors = on

error_reporting = -1

 

 

 

 

Save that file as "php.ini" and run your web page again. (NOTE: you may need to re-start your web server)

Edited by White_Lily
Link to comment
Share on other sites

A.Don't post personal credentials on a forum.

Go change the password for that account now.

 

B. Are you sure the user/database/table exists?

 

C. Try taking the quotes out from around the variables.

Link to comment
Share on other sites

Whats with all the inserts? O.o

 

Have you also tried using a php.ini file?

 

If not - create one and type into it:

 

display_errors = on

error_reporting = -1

 

 

 

 

Save that file as "php.ini" and run your web page again. (NOTE: you may need to re-start your web server)

 

Or you can just add

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

to the top of your script

Link to comment
Share on other sites

As i found out the other day its better to use "-1" not E_ALL

 

So change it to -1 then, it's much easier then restarting a web server

 

if he uses php.ini it will show errors across his entire site, not just one page.

 

It sounds like he's in a live environment so that's not a good thing. Just one man's opinion.

Edited by TOA
Link to comment
Share on other sites

As i found out the other day its better to use "-1" not E_ALL and if he uses php.ini it will show errors across his entire site, not just one page.

If you're using 5.4+ you use E_ALL. It's not "better" to use one over the other, the -1 is for <5.4 when E_STRICT was not included in E_ALL.

Link to comment
Share on other sites

The -1 will show all possible error, whereas E_ALL will suppress E_DEPRECATED and few others. Using -1 lets a developer correct as much as possible, and helps make sure the code isn't going to suddenly stop working when the server is upgraded to the next version of php.

 

So actually it is more useful to use -1.

Edited by White_Lily
Link to comment
Share on other sites

ok i appreciate all the responses. sorry it got off track there but i think my issue is a problem that might be hard coded into that Flash SWF file which i will not be able to corrct so i will think i will just build new site. but one question i have that i cant seem to find an answer to ... is it possible build a page in HTML , ID certain tables around the page and have them call data form fields in the table?

 

everything i see is echo'ing or printing the data in a table on the page but not where i need the table to show like next to an imaga or so.. is it possible to set the cell or table as a placeholder to auto call data from the connected database?

 

hope i explained that right.

 

thanks

Link to comment
Share on other sites

PHP is stateless, and is run on the server. After a client (browser) calls the server, it translates the PHP, and sends results to the browser. PHP is then finished with it's project, and forgets everything it just did. There is no constant "connection" between the client and the server.

 

In order to update a "cell" in a table on-click or otherwise, you will have to use a client side scripting language (javascript) to call the server, and ask for the data. This method is called Asynchronous Javascript (AJAX).

 

You will need to know a little bit of PHP, Javascript, and HTML in order to get it to work correctly. More specifically:

How to use PHP's $_GET array.

How to make a HTTP request with Javascript

How to receive a HTTP request with Javascript

How to take the results, and put them into the HTML table

 

There are libraries like Jquery, which make AJAX a little easier. Although, I even find their manual a little bit confusing.

I hope this answered your last question.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.