I really appreciate the patience everyone here has for us beginners.<br /><br />I'm getting closer, I think. I can connect using the script below.<br /><br /><?php<br />$DBHOST = "localhost"; <br />$DBUSER = "sales_bob"; <br />$DBPASS = "abcd"; <br />$DBNAME = "sales_newdatabase"; <br />echo("work");<br />//<br />// lets show any errors we get in PHP<br />//<br /><br />ini_set ('display_errors', 1);<br />error_reporting (E_ALL & ~E_NOTICE);<br /><br />//<br />// Now we connect to the MySQL server and select the database<br />//<br /><br />if ($dbc = @mysql_connect ($DBHOST, $DBUSER , $DBPASS ))<br />{<br />if (!@mysql_select_db ($DBNAME))<br />{<br />die ('<p>Could not select the database because: <b>'.mysql_error().'</b></p>');<br />}<br />} <br />else <br />{<br />die ('<p>Could not connect to MySQL because: <b>'.mysql_error().'</b></p>');<br />}<br /><br />echo ("<h4>Successfully connected to your MySQL server and database</h4>");<br />?><br /><br />But the next script gives me a blank screen when I run it.<br />Not even the echo("test "); prints.<br /><br /><?php<br />$dbhost = "localhost"; <br />$dbuser = "sales_bob"; <br />$dbpass = "abcd"; <br />$dbname = "sales_newdatabase";<br />$dbtable = "feedback"; <br />echo("test ");<br /><br /><br />$conn = mysql_connect"($dbhost,$dbuser,$dbpass);<br />mysql_select_db($dbname);<br />$sql = "select * from $dbtable";<br />$result = mysql_query($sql,$conn);<br />$number_of_rows = mysql_numrows($result);<br />echo "the number of rows is $number_of_rows";<br />?><br /><br />No errors are listed or anything for that matter. Just a blank screen.<br />Through the Cpanel tools I have the DB and Table and sample data.<br />What am I missing? <br />I am trying to get the hang of mysql/php one step at a time.<br />Is there something I need to configure at the php/mysql admin level?<br /><br />Thanks again<!--content-->
I'll take a stab at this.<br /><br />1) You created the database through cPanel<br />2) You created a user for the database<br />3) You added the user to the database<br /><br />To access this database the variables should be as follows.<br /><br />The DBNAME will be <!--coloro:blue--><span style="color:blue"><!--/coloro-->yourcpanelname_databasename-you-created<!--colorc--></span><!--/colorc--><br />The DBUSER will be <!--coloro:blue--><span style="color:blue"><!--/coloro-->yourcpanelname_username-you-created<!--colorc--></span><!--/colorc--><br />The DBPASS will be <!--coloro:blue--><span style="color:blue"><!--/coloro-->password-you-created<!--colorc--></span><!--/colorc--><br />The HOST will be <!--coloro:blue--><span style="color:blue"><!--/coloro-->localhost<!--colorc--></span><!--/colorc--><br /><br />Hope that hepls<!--content-->
That is what I am using. The first script does show I am connecting.<br />But the weird thing on the second script is the ECHO statement doesn't print.<!--content-->
If the second script does not output the word 'test'<br /><br />then I have to ask:<br /><br />did you upload the file as text?<br />does it have the extension of .php?<br />what text editor are you using?<br />Did you save it some where in or below your public_html folder?<br /><br />I know you probably did all this, but we have to start some where.<!--content-->
<!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->$conn = mysql_connect"($dbhost,$dbuser,$dbpass);<br />mysql_select_db($dbname);<!--QuoteEnd--></div><!--QuoteEEnd--><br /><br />Try taking out the quotation mark in the first line I quoted; it shouldn't be there.<br /><br />In the second line, I have found that I sometimes have to assign it to a variable:<br /><br />$db1 = mysql_select_db($dbname);<br /><br />I don't know why, but every once in a while a script gets picky on me. See if it works after taking out that quotation mark, though.<!--content-->
I'll take a stab at this.<br /><br />1) You created the database through cPanel<br />2) You created a user for the database<br />3) You added the user to the database<br /><br />To access this database the variables should be as follows.<br /><br />The DBNAME will be <!--coloro:blue--><span style="color:blue"><!--/coloro-->yourcpanelname_databasename-you-created<!--colorc--></span><!--/colorc--><br />The DBUSER will be <!--coloro:blue--><span style="color:blue"><!--/coloro-->yourcpanelname_username-you-created<!--colorc--></span><!--/colorc--><br />The DBPASS will be <!--coloro:blue--><span style="color:blue"><!--/coloro-->password-you-created<!--colorc--></span><!--/colorc--><br />The HOST will be <!--coloro:blue--><span style="color:blue"><!--/coloro-->localhost<!--colorc--></span><!--/colorc--><br /><br />Hope that hepls<!--content-->
That is what I am using. The first script does show I am connecting.<br />But the weird thing on the second script is the ECHO statement doesn't print.<!--content-->
If the second script does not output the word 'test'<br /><br />then I have to ask:<br /><br />did you upload the file as text?<br />does it have the extension of .php?<br />what text editor are you using?<br />Did you save it some where in or below your public_html folder?<br /><br />I know you probably did all this, but we have to start some where.<!--content-->
<!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->$conn = mysql_connect"($dbhost,$dbuser,$dbpass);<br />mysql_select_db($dbname);<!--QuoteEnd--></div><!--QuoteEEnd--><br /><br />Try taking out the quotation mark in the first line I quoted; it shouldn't be there.<br /><br />In the second line, I have found that I sometimes have to assign it to a variable:<br /><br />$db1 = mysql_select_db($dbname);<br /><br />I don't know why, but every once in a while a script gets picky on me. See if it works after taking out that quotation mark, though.<!--content-->