RE: Programming question - New to PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Try
    	$link = mysql_connect('localhost',$youruser,$yourpassword) or die();
    	mysql_select_db('yourdb'); 

	$query = 'SELECT * FROM Moses_Lake_Lions';
	if(!$result = mysql_query ($query,$link))
	{
		// do error checking here
	}

Jeremy Schreckhise, M.B.A.	

-----Original Message-----
From: Russbucket [mailto:russbucket@xxxxxxx] 
Sent: Wednesday, June 28, 2006 6:58 PM
To: PHP General
Subject:  Programming question - New to PHP

I took an example  of a script from the PHP documentation and try to connect

to my database.   If I leave in the or die part of line 3, I get nothing, if

I comment out that part I get the echo message on line 4. 

<?php
// Connecting and selecting the database $conn = mysql_connect ('localhost',
'finemanruss', 'XXXXXXXl') or die ('Could not connect :  '  .
mysql_error()); echo 'Connected successfully'; mysql_select_db ("Lions",
$conn);

// Preform SQL query
$query = 'SELECT * FROM Moses_Lake_Lions';
$result = mysql_query ($query) or die ( 'Query failed;   '  .
mysql_error());
?>

I know line three works without the or die part since I have a 2nd script
that is almost the same (no or die) and it retrieves info from my DB.

Can anyone point me to some tips or solutions to the or die problem? This
script is located in the mysql ref section of the php manual. I'm using php5
on SUSE Linux 10.0 with a mysql database.

Thanks in advance.
--
Russ

--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux