473,289 Members | 2,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

Is my code for seeing a database wrong? Please help - getting very desperate!

Please help - getting very desperate! Sun, 12 October 2003 05:39

I have PHPDEV 4.2.3 from Firepages.com.au as the upgrade to 4.3.0 did
not work. I also had an abortive download from PHP.NET as I could not
configure Apache myself.

The REAL problem is that PHPmyAdmin works and sees my test database
Wines....
But my PHP program does not!

The code I have used is:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<TITLE> Getting PHP & MY SQL to work </TITLE>
<head>Wines PHP Tester<BR></head>
<body>
<?php
echo "This is PHP here....<BR>\n";
$link_id = @msql_pconnect("localhost");
if (!$link_id) {
echo ("Failed to connect to MySQL!");
exit;
}
else;
{
echo "Connected OK!";
}

if (!mysql_select_db("Wines")) {
echo ("Failed to select database cms!");
exit;

}
echo ("Connected to Database");
$resultset = mysql_query("SELECT * FROM wine");
while ($row = mysql_fetch_row ($resultset)) {
echo "Date $row[0]: $row[1]\n";
}
echo ("end");
?>
</html>
</BODY>
</HTML>

And I have also tried:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Getting PHP & MY SQL to work </TITLE>
</HEAD>

<BODY>
<html>
<head>Wines PHP Tester<BR></head>
<body>
<?php
echo "This is PHP here....<BR>\n";
$connection = mysql_connect("localhost");

$db = mysql_select_db("Wines",$connection);
$query = "SELECT * FROM Wine";
echo "Select...";
$result = mysql_query($query,$connection);
echo "result...";

?>
</body>
</html>
</BODY>
</HTML>
But I get no results. It works fine in PHPmyAdmin though.

I did have a different Mysql on my XPHome box which I have
subsequently deleted as it could not connect to the server once PHP
was installed.

I am falling further behind in my degree as I can even get the db up
and running so I cant even get coding!

Please please help.
Jul 17 '05 #1
3 2533
try this

<?php
class base
{
#### SQL ####
//In this part of the Base class are located all sql related
functions
var $connected = false;

function sql_connect() //In this function u make a sql connection
{
############# FILL THIS IN: #############
$mysqlhost = 'localhost'; // Database
provider URL
$mysqluser = 'tobegood_test'; // Database
gebruiker
$mysqlpassword = 'test'; // Database wachtwoord
$mysqldb = 'tobegood_test1'; // Database
naam
############# That was all thnx ###########
if(!$this->connected)
{
$conn =
mysql_connect($mysqlhost,$mysqluser,$mysqlpassword ) or die("Could not
connect to database!");
$select = mysql_select_db($mysqldb,$conn) or
die("Could not select the database!");
$connected = true;
}
}

function sql_query($query) //With this function u do a sql query
{
if(!$this->connected)
{
$this->sql_connect();
}
$result = mysql_query($query) or die("MySQL error :
".mysql_error());
return ($result);
}
#### End SQL ####
}

class test extends base
{
function test()
{
$sql = $this->sql_query("SELECT * FROM wine");
$count = 0;
while($info = mysql_fetch_array($sql))
{
echo $info[$count];
$count++;
}
}
}

$test = new test();

?>

Haven't tested it because my php server is down but it should work

good luck

On 12 Oct 2003 03:15:28 -0700, ju**************@hotmail.com (James)
wrote:
Please help - getting very desperate! Sun, 12 October 2003 05:39

I have PHPDEV 4.2.3 from Firepages.com.au as the upgrade to 4.3.0 did
not work. I also had an abortive download from PHP.NET as I could not
configure Apache myself.

The REAL problem is that PHPmyAdmin works and sees my test database
Wines....
But my PHP program does not!

The code I have used is:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<TITLE> Getting PHP & MY SQL to work </TITLE>
<head>Wines PHP Tester<BR></head>
<body>
<?php
echo "This is PHP here....<BR>\n";
$link_id = @msql_pconnect("localhost");
if (!$link_id) {
echo ("Failed to connect to MySQL!");
exit;
}
else;
{
echo "Connected OK!";
}

if (!mysql_select_db("Wines")) {
echo ("Failed to select database cms!");
exit;

}
echo ("Connected to Database");
$resultset = mysql_query("SELECT * FROM wine");
while ($row = mysql_fetch_row ($resultset)) {
echo "Date $row[0]: $row[1]\n";
}
echo ("end");
?>
</html>
</BODY>
</HTML>

And I have also tried:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Getting PHP & MY SQL to work </TITLE>
</HEAD>

<BODY>
<html>
<head>Wines PHP Tester<BR></head>
<body>
<?php
echo "This is PHP here....<BR>\n";
$connection = mysql_connect("localhost");

$db = mysql_select_db("Wines",$connection);
$query = "SELECT * FROM Wine";
echo "Select...";
$result = mysql_query($query,$connection);
echo "result...";

?>
</body>
</html>
</BODY>
</HTML>
But I get no results. It works fine in PHPmyAdmin though.

I did have a different Mysql on my XPHome box which I have
subsequently deleted as it could not connect to the server once PHP
was installed.

I am falling further behind in my degree as I can even get the db up
and running so I cant even get coding!

Please please help.


Jul 17 '05 #2
sam

"James" <ju**************@hotmail.com> wrote in message
news:4e**************************@posting.google.c om...
Please help - getting very desperate! Sun, 12 October 2003 05:39

I have PHPDEV 4.2.3 from Firepages.com.au as the upgrade to 4.3.0 did
not work. I also had an abortive download from PHP.NET as I could not
configure Apache myself.

The REAL problem is that PHPmyAdmin works and sees my test database
Wines....
But my PHP program does not!

The code I have used is:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<TITLE> Getting PHP & MY SQL to work </TITLE>
<head>Wines PHP Tester<BR></head>
<body>
<?php
echo "This is PHP here....<BR>\n";
$link_id = @msql_pconnect("localhost");
mysql and not msql !

$link_id = @mysql_pconnect("localhost","user_name","user_pass word");

change user_name and user_password with your user name and passord
if (!$link_id) {
echo ("Failed to connect to MySQL!");
exit;
}
else;
{
echo "Connected OK!";
}

if (!mysql_select_db("Wines")) {
if (!mysql_select_db("Wines",$link_id)) {
echo ("Failed to select database cms!");
exit;

}
echo ("Connected to Database");
$resultset = mysql_query("SELECT * FROM wine");
$resultset = mysql_query("SELECT * FROM wine",$link_id);
while ($row = mysql_fetch_row ($resultset)) {
echo "Date $row[0]: $row[1]\n";
echo "Date ".$row[0].": ".$row[1]."\n";
}
echo ("end");
?>
</html>
</BODY>
</HTML>

And I have also tried:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Getting PHP & MY SQL to work </TITLE>
</HEAD>

<BODY>
<html>
<head>Wines PHP Tester<BR></head>
<body>
<?php
echo "This is PHP here....<BR>\n";
$connection = mysql_connect("localhost");

$db = mysql_select_db("Wines",$connection);
$query = "SELECT * FROM Wine";
echo "Select...";
$result = mysql_query($query,$connection);
echo "result...";

?>
</body>
</html>
</BODY>
</HTML>
But I get no results. It works fine in PHPmyAdmin though.

I did have a different Mysql on my XPHome box which I have
subsequently deleted as it could not connect to the server once PHP
was installed.

I am falling further behind in my degree as I can even get the db up
and running so I cant even get coding!

Please please help.

Jul 17 '05 #3
I noticed that Message-ID:
<4e**************************@posting.google.com > from James contained
the following:
$link_id = @msql_pconnect("localhost");
if (!$link_id) {
echo ("Failed to connect to MySQL!");


According to the manual, that function is used to make a persistent
connection to MiniSQL Dunno if it works with MySQL.

Try
$db = mysql_connect("localhost", "username", "password");

if (!mysql_select_db("Wines",$db)) {
echo ("Failed to select database");
exit;
etc.,etc.,
--
Geoff Berrow
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

242
by: James Cameron | last post by:
Hi I'm developing a program and the client is worried about future reuse of the code. Say 5, 10, 15 years down the road. This will be a major factor in selecting the development language. Any...
1
by: Matt | last post by:
Hello I have spent the last weeks trying to solve this problem but with no luck at all, I have a piece of code that looks like this declare @bestnr int, @artnr varchar(25), @journalnrrow...
171
by: tshad | last post by:
I am just trying to decide whether to split my code and uses code behind. I did it with one of my pages and found it was quite a bit of trouble. I know that most people (and books and articles)...
8
by: Scott Emick | last post by:
I am using the following to compute distances between two lat/long coordinates for a store locator - (VB .NET 2003) it seems to take a long time to iterate through like 100-150 locations -...
29
by: Gernot Frisch | last post by:
Hi, I have no clue. - I want to align the red, green, blue boxes in one line - red,green,blue must be 45px high - red (center) must be as wide as possible - yellow must start exactly below...
3
by: garyusenet | last post by:
I have been trying to interface with my act database using .net and act api's. I was originally using c# but it wouldn't connect to the database. I tried VB in desperation and it is connecting! ...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
1
by: esimons | last post by:
I am searching for days now to get a concrete example of how to use the __sleep() and __wakeup() function in a class to restore a databaseconnection when passing an object from one page to another by...
16
by: haft | last post by:
I have posted this question on a javascript forum as it contains javascript code however it was believed to be an asp issue. The following head section javascript code contains the function...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.