Re: Re: Newbie Setup Trouble
| From: | J. Connolly | Date: | Mon, 07 Feb 2005 15:36:48 +0000 |
| Subject: | Re: Re: Newbie Setup Trouble | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-38490@lists.php.net to get a copy of this message | ||
Mike,
There is no database sepcified in your code anywhere. The line:
$result = mysql_query($sql); does not specify which database you are connecting to either. You can specify the database in the line:
$link = mysql_connect($host,$user,$password,$database); //or in a separate line with the function
mysql_select_db("database name",$link) //where $link is the connection info above
And then use in the line:
$result = mysql_query($link, $sql); //this enable the query to find the connection and the code.I hope this makes sense. I have only been doing this a couple of weeks. Some books have the ($link,$sql) order reversed which will also give you an error. IN ADDITION, if you are using mysqli you need to enter this ext in the PHP.ini file. I can only connect using mysqli and not mysql. Good luck, jzf This should help you.
Mike Rondeau wrote:Hello, I have just begun study of using PHP, MySQL and Apache server. Right now I'm following a book, "PHP and MySQL For Dummies" and am having trouble already. I must be a REAL dummy! I have installed all 3 programs but something is not right somewhere. Being so new to this I am having a real time trying to figure out which program is messed up. Certain things work, but others don't. For instance, my book told me how to make a phpinfo.php page, which works fine. But it also tells me to create some other pages to test if PHP and MySQL are working or not. I followed the scripts provided exactly but keep getting syntax errors, even though the script is just what the authors wrote. For instance, it said to make a page and call it mysql_up.php. Here's the script for it: <html> <head><title>Test MySQL</title></head> <body> <!-- mysql_up.php --> <?php $host="localhost"; $user="blablablabla"; $password="blablabla"; mysql_connect($host,$user,$password); $sql="show status"; $result = mysql_query($sql); if ($result == 0) { echo "<b>Error " . mysql_errno() . ": ". mysql_error() . "</b>";} else { ?> <!-- Table that displays the results --> <table border="1"> <tr><td><b>Variable_name</b></td><td><b>Value</b></td></tr><?phpfor ($i = 0; $i < mysql_num_rows($result); $i++) { echo "<TR>"; $row_array = mysql_fetch_row($result); for ($j = 0; $j < mysql_num_fields($result); $j++) { echo "<TD>" . $row_array[$j] . "</td>"; } echo "</tr>"; }?> </table> <?php } ?> </body></html> But when I open it in my browser I get this error: Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\htdocs\mysql_up.php on line 10 Could anyone of you smart people point me in the right direction? I'd be pulling my hair out if I had any left :) I can't make any progress with this study until I know my 3 programs are talking to eachother properly, but my book gives no info on this error. Thanks a millionfold for any advice, and I appologise for the length of this post. Sincerely, Mike Rondeau