If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Help with my script

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-01-03, 09:42
Samia1667 Samia1667 is offline
Registered User
 
Join Date: Nov 2003
Posts: 4
Help with my script

Dear All,

I am trying to learn mysql on my own and I was following an example. I have everything installed apache/php/mysql on win2k and working fine. I even managed to create a database jokes thru command prompt start>programs>accessories>, and I can display very well. However tryong to display in my browser using
PHP Code:
<html>
<head>
<title>Our List of Jokes </title>
</head>
<body>
<?php

   
// Connect to the database server
   
$dbcnx = @mysql_connect('localhost''root''myne');
   if (!
$dbcnx) {
   die( 
'<p>Unable to connect to the ' .
          
'database server at this time.</p>' );
   }

   
// Select the jokes database
   
if (! @mysql_select_bd('Jokes'$dbcnx) ) {
   die( 
'<p>Unable to locate the joke ' .
          
'database at this time.</p>' );
   }

?>

<p> Here are all the jokes in our database: </p>
<blockquote>
<?php

   
// Request the text of all the jokes
   
$result = @mysql_querry('SELECT JokeText FROM Jokes');
   if (!
$result) {
     die(
'<p>Error performing query: ' mysql_error() .
         
'</P>');
   }

   
// Display the text of each joke in a paragraph
   
while ( $row mysql_fetch_array($result) ) {
     echo(
'<p>' $row['JokeText'] . '</p>');
   }
?>
</blockquote>
</body>
</html>
won't work. What could be the problem.
Reply With Quote
  #2 (permalink)  
Old 12-02-03, 04:42
ika ika is offline
Registered User
 
Join Date: Oct 2003
Location: Slovakia
Posts: 482
Re: Help with my script

Quote:
Originally posted by Samia1667
Dear All,

I am trying to learn mysql on my own and I was following an example. I have everything installed apache/php/mysql on win2k and working fine. I even managed to create a database jokes thru command prompt start>programs>accessories>, and I can display very well. However tryong to display in my browser using
PHP Code:
<html>
<head>
<title>Our List of Jokes </title>
</head>
<body>
<?php

   
// Connect to the database server
   
$dbcnx = @mysql_connect('localhost''root''myne');
   if (!
$dbcnx) {
   die( 
'<p>Unable to connect to the ' .
          
'database server at this time.</p>' );
   }

   
// Select the jokes database
   
if (! @mysql_select_bd('Jokes'$dbcnx) ) {
   die( 
'<p>Unable to locate the joke ' .
          
'database at this time.</p>' );
   }

?>

<p> Here are all the jokes in our database: </p>
<blockquote>
<?php

   
// Request the text of all the jokes
   
$result = @mysql_querry('SELECT JokeText FROM Jokes');
   if (!
$result) {
     die(
'<p>Error performing query: ' mysql_error() .
         
'</P>');
   }

   
// Display the text of each joke in a paragraph
   
while ( $row mysql_fetch_array($result) ) {
     echo(
'<p>' $row['JokeText'] . '</p>');
   }
?>
</blockquote>
</body>
</html>
won't work. What could be the problem.
Got you some error message?
Reply With Quote
  #3 (permalink)  
Old 12-02-03, 06:32
Samia1667 Samia1667 is offline
Registered User
 
Join Date: Nov 2003
Posts: 4
Actually I finally got it to work, there were typos in querry and not query and @mysql_select_bd and not @mysql_select_db.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On