View previous topic :: View next topic |
Author |
Message |
jroon91 n00b
Joined: 15 May 2004 Posts: 73
|
Posted: Wed Jul 14, 2004 2:07 am Post subject: Problems with PHP Apache and MYSQL |
|
|
Ok guys i got everything working, or atleast i thought. I can do a phpinfo and everything works fine. So i figured i'd start messing with a php mysql book i bought. Heres the page i'm trying to get to work:
Code: |
<?php
$conn = @mysql_connect("localhost","root","password")
or die("Sorry I was unable to connect to MySQL");
$rs1= @mysql_create_db($db);
$rs2= @mysql_list_dbs($conn);
for($row=0; $row < mysql_num_rows($rs2); $row++)
{ $list .= mysql_tablename($rs2, $row)." | ";}
?>
<html>
<head><title>Create New DB</title></head>
<body>
<form action="<?php echo($list); ?>" method="post">
Current Databases: <?php echo($list); ?> <hr>
Name: <input type="text" name="db">
<input type="submit" value="Create database">
</form>
</body>
</html>
|
Whenever php is able to connect to mysql, meaning when i user the right user name and password, the page stays blank. Could this be a setting? or is it a scripting problem? I copied it right from the book so i thought it would be alright. Thanks guys |
|
Back to top |
|
|
nobspangle Veteran
Joined: 23 Mar 2004 Posts: 1318 Location: Manchester, UK
|
Posted: Wed Jul 14, 2004 7:37 am Post subject: |
|
|
looks like your book might be expecting register globals to be turned on,
Try adding Code: | $db = $_POST["db"]; | before the $rs1= line
also (I don't know if this is right) I always use
echo $list;
not
echo($list);
Here's a trick I've just learnt (may not work needs short_open_tag config setting)
Instead of Code: | <form action="<?php echo $list; ?>" | You can put Code: | <form action="<?=$list?>" |
I don't know what the @ signs are for in front of the mysql functions, I've never used them before. |
|
Back to top |
|
|
jroon91 n00b
Joined: 15 May 2004 Posts: 73
|
Posted: Wed Jul 14, 2004 3:02 pm Post subject: |
|
|
Yeah once i changed to $_POST everything started working fine, do you know where i can set it so that i can just use it the way i have it?
The short open tag does seem to work...thats the way i've always done it with asp also.
The @ infront of the mysql functions suppress any errors generated bythe functions themselves. I just got mysql and php working so i figured i'd use it for now to prevent some errors as long as they work. Thanks for the reply |
|
Back to top |
|
|
nobspangle Veteran
Joined: 23 Mar 2004 Posts: 1318 Location: Manchester, UK
|
Posted: Wed Jul 14, 2004 4:55 pm Post subject: |
|
|
you can enable register globals but it's not recommended as it is considered a security risk. The setting should be in php.ini, make sure you change the one for apache not the one for cli |
|
Back to top |
|
|
|