Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 08-27-2003, 07:07 AM   #16 (permalink)
Odoggy5
Registered User
 
Odoggy5's Avatar
 
Join Date: Aug 2003
Location: SF
Posts: 45
Odoggy5 is on a distinguished road
Send a message via AIM to Odoggy5
cool,
I think it will be litte while before I get to that point. Im still doing the prerequisites:p But do you have any suggestions for a good book? I am going to the bookstore and computer store after work. I need some RAM and some drives so I'll have another box, which I am going to put RedHat on. I don't know if I am a dork but...I love this stuff!:rock:
Odoggy5 is offline   Reply With Quote
Old 08-27-2003, 09:07 AM   #17 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
i've always liked WROX .. they are the red books with the geek looking people on the front =)

beginning php
professional php

then as a good function reference

core php
php cookbook

i have other books, but these are what i have used the most.
__________________
Mike
sde is offline   Reply With Quote
Old 09-02-2003, 08:22 AM   #18 (permalink)
Odoggy5
Registered User
 
Odoggy5's Avatar
 
Join Date: Aug 2003
Location: SF
Posts: 45
Odoggy5 is on a distinguished road
Send a message via AIM to Odoggy5
ok still did'nt make it to the bookstore still using a tutorial on the web. I am tryin to connect to a mysql databse now and need some help. this is what I got.

Code:
<html>
<body>
<?
$dbcnx = @mysql_connect("localhost", "root", "mypasswd");
if (!$dbcnx) {  echo( "<P>Unable to connect to the " . 
"database server at this time.</P>" );  
exit();}
?>
</body>
</html>
I am trying to get that error message to pop up to verfiy that it is trying to connect, by using the wrong password, but it does not.
Odoggy5 is offline   Reply With Quote
Old 09-02-2003, 01:50 PM   #19 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
hey, please start a new thread for new topics .. it's easier to follow and more beneficial for people searching for past threads.

also, there's great php highlighting built into this forum .. use the [php ] and [/ php] tags =) easier to read.

ok, now for the questions and help... hehe

are you running mysql locally? are you on windows? are you sure your permissions in mysql are set up right?

in mysql, you can grant full permission on all tables to a user like this:
Code:
GRANT ALL PRIVILEGES ON *.* TO username@'%' IDENTIFIED BY 'password';
__________________
Mike
sde is offline   Reply With Quote
Old 09-02-2003, 02:04 PM   #20 (permalink)
bdl
Senior Contributor
 
Join Date: May 2002
Location: vta.ca.usa
Posts: 555
bdl is on a distinguished road
PHP Code:
<?
$dbcnx 
= @mysql_connect("localhost""root""mypasswd");
if (!
$dbcnx)
{
  echo( 
"<P>Unable to connect to the database server at this time.</P>" );  
  exit();
}
?>
Hmm. Correct me if I'm wrong, but in your syntax above, $dbcnx would still 'have value' or 'exist' in the method you use. You supply it with a null value even if the MySQL connection fails.

Your syntax on echo ( " (with the extra spacing) may also be hanging things up, try just using echo " or echo(".

What I usually do is this:
PHP Code:
if (!$dbcnx mysql_connect("server""user""password"))
  die(
"Could not connect to MySQL DB: " mysql_error()); 
That would definitely give you an error if you couldn't connect to the MySQL server, and tell you why (thats the mysql_error() part). You should try removing error suppression (the '@' symbol) when you test a script, make sure you get all the bugs first. Then if it fails later on at least error messages won't get to the user.
bdl is offline   Reply With Quote
Old 09-02-2003, 03:26 PM   #21 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
mysql_connect returns a MySQL link identifier on success, or false on failure, so his code should work fine. he's just testing for false as you are in the example you show.
__________________
Mike
sde is offline   Reply With Quote
Old 09-02-2003, 07:01 PM   #22 (permalink)
bdl
Senior Contributor
 
Join Date: May 2002
Location: vta.ca.usa
Posts: 555
bdl is on a distinguished road
Ok, I stand corrected. =P

I tried the same code on my server, works fine, gives an error code as you would expect. Even with the echo statement spaced out some, although I have seen a script fail with minor details like that before. For example, IIRC, you must use parenthesis with die().
bdl is offline   Reply With Quote
Old 09-03-2003, 07:31 AM   #23 (permalink)
Odoggy5
Registered User
 
Odoggy5's Avatar
 
Join Date: Aug 2003
Location: SF
Posts: 45
Odoggy5 is on a distinguished road
Send a message via AIM to Odoggy5
My permissions are ok, and if they were not should'nt the error message appear? I am using the wrong password purposely to make the error message pop up.
Odoggy5 is offline   Reply With Quote
Old 09-03-2003, 08:08 AM   #24 (permalink)
Odoggy5
Registered User
 
Odoggy5's Avatar
 
Join Date: Aug 2003
Location: SF
Posts: 45
Odoggy5 is on a distinguished road
Send a message via AIM to Odoggy5
Ok I got it to work. I don't even want to tell you guys what I was doing wrong, because I was being a dumbass!
Odoggy5 is offline   Reply With Quote
Old 09-03-2003, 08:21 AM   #25 (permalink)
Odoggy5
Registered User
 
Odoggy5's Avatar
 
Join Date: Aug 2003
Location: SF
Posts: 45
Odoggy5 is on a distinguished road
Send a message via AIM to Odoggy5
ok ok, I guess thats not fair...
I was saving them as an html file instead of a php file.
Why does that not work?
Odoggy5 is offline   Reply With Quote
Old 09-03-2003, 08:26 AM   #26 (permalink)
Admin
$_['Your_Mom'];
 
Admin's Avatar
 
Join Date: May 2002
Location: Santee
Posts: 627
Admin is on a distinguished road
because HTML is a static page, the server simply sends that file without processing it.

PHP being dynamic is processed on the server before being sent to the user.
__________________


Urban Clothing
Admin is offline   Reply With Quote
Old 09-03-2003, 02:19 PM   #27 (permalink)
bdl
Senior Contributor
 
Join Date: May 2002
Location: vta.ca.usa
Posts: 555
bdl is on a distinguished road
Actually, it's simple to have an .html page or .phtml, whatever to be recognized as a PHP script and work properly. Just change your Apache config like so:
Code:
AddType application/x-httpd-php .php .html .phtml
Restart Apache server.

Basically just tells Apache to allow those suffixes to parse as PHP files if they happen to contain any PHP code.
bdl is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
DB Design Question Part II sde Program Design and Methods 10 09-02-2008 11:37 AM
Hello! Please forgive newbie question jimmyoctane PHP 4 09-13-2004 06:33 AM
Would you mind if there were small flash elements at code newbie? sde Lounge 10 05-29-2004 09:05 PM
Newbie question. p0etsou1 Standard C, C++ 9 06-24-2003 07:47 AM
Newbie Site ? DesertWolf Java 2 12-05-2002 12:38 PM


All times are GMT -8. The time now is 11:34 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting