Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

How do I access a sql database on my web page?

I set up a free sql server on byet, and would like to test a small sample sql database. This html page isn't working. What's wrong?

<HTML>

<HEAD>

<TABLE WIDTH="100%">

<TR><TD WIDTH="10%"></TD><TD>

<TITLE>

php test page

</TITLE>

</HEAD>

<center><br><br><br><br><br><br>

<B><font size="6">

php test page</B></center>

</FONT>

<br><br><br>

<font color="black" size="4">

<?php

$link = mysql_connect('sql333.byethost55.com', 'b8888', 'password');

if (!$link) {

die('Could not connect: ' . mysql_error());

}

echo 'Connected successfully';

?>

<?php

// This could be supplied by a user, for example

$name = 'smith';

$city = 'chicago';

$query = sprintf("SELECT name, city, st FROM contacts WHERE name='%s' AND city+'%s'",

mysql_real_escape_string($name),

mysql_real_escape_string($city));

$result = mysql_query($query);

if (!$result) {

$message = 'Invalid query: ' . mysql_error() . "\n";

$message .= 'Whole query: ' . $query;

die($message);

}

</font>

</TD><TD WIDTH="10%"></TD></TR>

</TABLE>

</Center>

</BODY>

</HTML>

Update:

I tried the first response and removed the second php script.

All I got was a blue screen with the page title.

2 Answers

Relevance
  • 1 decade ago
    Favorite Answer

    What happens when u run the script?

    The first thing would be to check your connection details

    So create a new empty PHP file which just connects to the database

    <?php

    $link = mysql_connect($host,$user,$password);

    if (!$link) {

    die('Could not connect: ' . mysql_error());

    }

    echo 'Connected successfully';

    ?>

    and see which appears.

    Also check that the mysql libaries are installed by running a phpinfo()

    eg

    <?php

    phpinfo();

    ?>

  • 5 years ago

    I agree that Microsoft Access is quite happy to serve as a database for smaller web sites. It doesn't like many more than about 50 concurrent users and you need to ensure that there are weekly maintanence jobs that repair and compact the database as Access has a habit of consuming space quickly. ASP is the primary scripting language when it comes to using Microsoft Access as a database because it can use both ADODB and ODBC to connect to the database. JSP (Java Server Pages) and PHP can also connect to Microsoft Access using ODBC. Once the ODBC connections are set up you have to use SQL to query and update the database.

Still have questions? Get your answers by asking now.