Database driven websites page chapter4

thanks for your reply i am using windows 7

Windows Essentials (AMD64/Intel EMm64T)

VC6 Thread Safe,
i got it working fine on my main comp it just laptop

the set up out the book works ok with my main execpt error message
Parse error: syntax error, unexpected ‘)’ in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\connect\index.php on line 2
when try to view in ie but the database part works fine
thanks bail

If you have an extra comma, PHP expects another argument. Since there isn’t one, the closing parenthesis is unexpected.

i have installed the v6 thread safe version like you say and the one out the book but im still getting these error:

c:\uswers\bail_main>mysqladmin -u root status
mysqladmin: connect to server at’localhost’ failed
error: ‘access denied for user ‘root’@localhost’ <using password: no>’

c:\uswers\bail_main>mysqladmin -u root status
mysqladmin: connect to server at’localhost’ failed
error: ‘access denied for user ‘root’@localhost’ <using password: yes>’

php is showing in the apache box and when i go to localhost through the browser its all working, it just when i go to command promt and type;

mysqladmin -u root status

i get the errors so is it just down to php?

ive unistalled everything and reinstalled them but im lost
thanks bail

PHP is not involved in running mysqladmin

You need to use your password (-p) to connect to the mysql server from any software

ok in the book it says
mysqladmin -u root status

when you hit enter you should see a line or two of basic statistics about your mysql
sever like this:
uptime:102261 threads:1 questions:1 slow queries:0
open:15 flush table:1 0pen tables:0
queries per second avg: 0.0

but im getting thoses errors and if i use
mysqladmin -u root -p
i just get loads of text come on the screen just few lines of what comes on but there is loads:
verbos false
vertical false
connect_timeout 43200
shutdown_timeout 3600

thanks bail
id pull my hair out if i had some so ill just keep banging me head upwall haa

OK i got it working on another comp still not my laptop any way the only way i can access the database is through mysql\mysqlserver 5.1\bin\mysql.exe command screen is this ok to use because it still not working from command promt in windows, also when i open the page in internet explorer all i get is white screen is this because of the way im entering through mysql and not comand promt here is the code;
i am sorry for this but it is starting to get to me now cause ive done everything people have told me and from book and still having problems makes me wonder if i should knock it on the head but its somthing i realy want to learn;

<?
$link = mysqli_connect (‘localhost’,‘root’,‘bailuk’);
if (!$link)
{
$output = ‘UNABLE TO CONNECT TO DATABASE SERVER.’;
include ‘output.html.php’;
exit();
}
if (!mysqli_set_charset ($link, ‘utf8’))
{
$output = ‘UNABLE TO SET DATABASE CONNECTION ENCODING.’;
include ‘output.htmp.php’;
exit();
}
if (mysqli_select_db($link, ‘ijdb’))
{
$output = ‘UNABLE TO LOCATE THE JOKE DATABASE.’;
include ‘output.html.php’;
exit();
}
$output = ‘DATABASE CONNECTION ESTABLISHED.’;
include ‘output.html.php’;
?>

thankyou all for your patience and time bail

It sounds very much to me like you’re trying to go too fast, and expecting the book to tell you everything you need to know. That definitely won’t work in the long run; it will barely work in the short term either.

My advice on the process of learning programming (taken from my own experience):

  • Learn to read reference manuals and technical documentation. Goto the MySQl and PHP websites, bookmark them and revisit them frequently.
  • You seem to be trying to rip through chapters in this book as quickly as possible until you reach the end. Don’t be in a hurry. Don’t just move onto the next bit as soon as you’ve ticked some boxes. Play around a bit. Experiment. Take the scenic route, and give yourself time for the information to sink in.
  • Start small. I started learning Java and quickly got overwhelmed at the sheer size of it all. I revised my goals and played with simple file IO before I got to databases.
  • As soon as you start to get frustrated or angry, stop what you’re doing. You won’t be productive.

Cheers,
D.

as any one got direct link for MYSQL this i cant find it

windows essentials (x84) (AMD64/intel EM64T) 5.1.34

i have found the msi installer one but in the book it says dont use that one ?

THANKS BAIL

ok think ive sorted it on laptop now formatted the laptop wnet on stright away and seems ok.
thanks everyone bail

I’ll second that.

Also, I find that if I let the knowledge go in at a rate my tiny brain can accept, rather than rushing it, I remember much more ~ for much longer. Pushing it in means I can be doing something very similar in just a couple of days time and I may not realise it until I have finished doing basically the same thing for second time. Sounds pathetic, I know, but thats the way I work and it is getting me to where I want to be.

http://www.aesops-fables.org.uk/aesop-fable-the-hare-and-the-tortoise.htm

bazz

I think this is the case for most people. I can attest to constantly forgetting things learned in a hurry if I didn’t use it for a week or more, and having to constantly search for the info over and over again.

Sometimes you just have to force yourself to be diligent and play with things until they become second nature. And only then, move on to the next chapter/lesson/task.

Cheers,
D.

ok i have sorted database added the jokes ect i have followed all instructions of how to link database mysql is running apache is running and all i am getting is blank white page when i connect to localhost/connect folder anyone tell me why! i should be getting database connection established or when i change my password for test reasons should have unable to connect to database server but im just gettin white page in ie and all other browsers?

thanks

show us your code for connecting. You should have an error message to display when it, well, errors.

bazz

<?
$link = mysqli_connect (‘localhost’, ‘root’, ‘bailuk’);
if (!$link)
{
$output = ‘unable to connect to the database server.’;
include ‘output.html.php’;
exit();
}
if (!mysqli_set_charset ($link, ‘utf8’))
{
$output = ‘unable to set database connecion encoding.’;
include ‘output.html.php’;
exit();
}
if (!mysqli_select_db ($link, ‘ijdb’))
{
$output = ‘unable to locate the joke database.’;
include ‘output.html.php’;
exit();
}
$output = ‘DATABASE CONNECTION ESTABLISHED.’;
include ‘output.html.php’;
?>

thanks baz

I’m wondering if you’re getting a “blank screen” because the file was saved as UTF-8 with a BOM (signature).

If so try openning it and saving it again making sure it’s without a BOM

ok thanks i havent got clue what you mean so i rewrote it all any way but nw im getting this error

error:

<? $link = mysqli_connect(‘localhost’, ‘root’, ‘bailuk’); if (!$link) { $output = ‘UNABLE TO LOCATE THE JOKE DATABASE.’; include ‘output.html.php’; exit(); } if (!mysqli_set_charset($link, ‘utf8’)) ( $output = ‘UNABLE TO SET DATABASE CONNECTION SERVER,’; include ‘output.html.php’; exit(); } if (!mysqli_select_db($link, ‘ijdb’)) ( $output = ‘UNABLE TO LOCATE THE JOKE DATABASE,’; include ‘output.html.php’; exit(); } $output = ‘DATABASE CONNECTION ESTABLISHED.’; include 'output.html.php ?>

CODE:

<?
$link = mysqli_connect(‘localhost’, ‘root’, ‘bailuk’);
if (!$link)
{
$output = ‘UNABLE TO LOCATE THE JOKE DATABASE.’;
include ‘output.html.php’;
exit();
}
if (!mysqli_set_charset($link, ‘utf8’))
(
$output = ‘UNABLE TO SET DATABASE CONNECTION SERVER,’;
include ‘output.html.php’;
exit();
}
if (!mysqli_select_db($link, ‘ijdb’))
(
$output = ‘UNABLE TO LOCATE THE JOKE DATABASE,’;
include ‘output.html.php’;
exit();
}
$output = ‘DATABASE CONNECTION ESTABLISHED.’;
include 'output.html.php
?>

THANKS BAIL

I don’t know much php but I found this, which you might like to use - even if only for testing purposes.


// Make a MySQL Connection
mysql_connect("localhost", "***********", "**********") or die(mysql_error());
mysql_select_db("**************") or die(mysql_error()); 

bazz

ok i have got somthing come on me screen and im reading it as a port cannot connect but i have not set anyports when seting the software up if this is correct how do i set a port 3306 to allow it to connect in windows 7 ultimate or is it easyeir to just remove it all and start again the error is below and below that is my code thanks bail

ERROR:

Warning: mysqli_connect() [function.mysqli-connect]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\connect\index.php on line 2

Warning: mysqli_connect() [function.mysqli-connect]: (HY000/2002): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\connect\index.php on line 2

Fatal error: Maximum execution time of 30 seconds exceeded in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\connect\index.php on line 2

MYCODE:

<?php
$link = mysqli_connect(‘localhost’, ‘root’, ‘bailuk’);
if (!$link)
{
$output = ‘unable to connect to the database server.’;
include ‘output.html.php’;
exit();
}
if (!mysqli_set_charset($link, ‘utf8’))
{
$output = ‘unable to set database connection encoding.’;
include ‘output.html.php’;
exit();
}
if ($mysqli_select_db($link, ‘ijdb’))
{
$output = ‘unable to locate the joke database.’;
include ‘output.html.php’;
exit();
}
$output = ‘database connection established.’;
include ‘output.html.php’;

?>

Sounds like the MySQL server is not running on your computer. 3306 is the default port used by MySQL so you don’t have to change that. Make sure it’s still running, and if it is, try giving it a restart since it doesn’t seem to be responding to your PHP script’s attempt to connect.

it says it running in task manager ??

thanks bail