ljzxtww Posted July 12, 2008 Share Posted July 12, 2008 hi: I want to create a URL into mysql data(phpmyadmin) i want to put url into mysql data(phpmyadmin) I want to print on page. like title call <?php bloginfo('name'); and this data is in phpmyadmin. and print name on php page call <title>PHP Freaks Forums </title> how to print on page. and also other stuff. like I want to print URL, tilte, bbsurl db_ceoemail please help me thank u Larry Link to comment https://forums.phpfreaks.com/topic/114389-how-to-use-mysqlphpmyadmin-to-print-data-title-on-page/ Share on other sites More sharing options...
dannyb785 Posted July 12, 2008 Share Posted July 12, 2008 Are you familiar with using SELECT from mysql to grab a row from your database, and then how to successfully output it? If not, I'd suggest reading some tutorials. Link to comment https://forums.phpfreaks.com/topic/114389-how-to-use-mysqlphpmyadmin-to-print-data-title-on-page/#findComment-588257 Share on other sites More sharing options...
ljzxtww Posted July 13, 2008 Author Share Posted July 13, 2008 Are you familiar with using SELECT from mysql to grab a row from your database, and then how to successfully output it? If not, I'd suggest reading some tutorials. yes I got it work. but I wrong messenge: Parse error: syntax error, unexpected '<' in C:\www\test\hearder.php on line 2 code is: <?php <title>echo $rows['db_names']</title> ?> Link to comment https://forums.phpfreaks.com/topic/114389-how-to-use-mysqlphpmyadmin-to-print-data-title-on-page/#findComment-588704 Share on other sites More sharing options...
dezkit Posted July 13, 2008 Share Posted July 13, 2008 <?php echo "<title>$rows['db_names']</title>"; ?> Link to comment https://forums.phpfreaks.com/topic/114389-how-to-use-mysqlphpmyadmin-to-print-data-title-on-page/#findComment-588705 Share on other sites More sharing options...
ljzxtww Posted July 13, 2008 Author Share Posted July 13, 2008 <?php echo "<title>$rows['db_names']</title>"; ?> Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Program Files\www\hearder.php on line 2 problem again Link to comment https://forums.phpfreaks.com/topic/114389-how-to-use-mysqlphpmyadmin-to-print-data-title-on-page/#findComment-588723 Share on other sites More sharing options...
chronister Posted July 13, 2008 Share Posted July 13, 2008 <?php echo '<title>'.$rows['db_names'].'</title>'; ?> or <?php echo "<title>{$rows['db_names']}</title>"; ?> I believe the second one is right.... berate me and call me a fool if not.. Nate Link to comment https://forums.phpfreaks.com/topic/114389-how-to-use-mysqlphpmyadmin-to-print-data-title-on-page/#findComment-588733 Share on other sites More sharing options...
dannyb785 Posted July 13, 2008 Share Posted July 13, 2008 <?php echo "<title>$rows['db_names']</title>"; ?> Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Program Files\www\hearder.php on line 2 problem again You need to learn a few basics about outputting variables to the screen. First off, when you are in between <?php and ?>, the only thing printed as html is that which is echo'd. Secondly, You have to end any and every line with a semicolon. Example: echo "hello world!"; Thirdly, if you are using double quotes for your echo, using an array with a string as an index cannot be in a single quote. Example: echo "$row[variable]"; not echo "$row['variable']"; Fourthly, if you are using single quotes, the only way to display a variable is to temporarily end the quote, truncate the variables with periods(.'s) and then startthe quote again. Example: echo 'The value '.$variable.' has been set into a variable'; not echo 'The value $variable has been set into a variable'; So in summary. If you want some variable between title tags, you can do it a few different ways: either: <?php echo "<title>$variable</title>"; ?> or <title><?php echo $variable; ?> </title> and ther are other slight variations, but those are the main 2. Link to comment https://forums.phpfreaks.com/topic/114389-how-to-use-mysqlphpmyadmin-to-print-data-title-on-page/#findComment-588791 Share on other sites More sharing options...
dannyb785 Posted July 13, 2008 Share Posted July 13, 2008 <?php echo '<title>'.$rows['db_names'].'</title>'; ?> or <?php echo "<title>{$rows['db_names']}</title>"; ?> I believe the second one is right.... berate me and call me a fool if not.. Nate I believe they are both correct. Putting a variable in between curly braces is as if you ended the quote, truncated with dots, and then continued the quote afterwards. so it's be equivalent to <?php echo "<title>".$rows['db_names']."</title>"; ?> Link to comment https://forums.phpfreaks.com/topic/114389-how-to-use-mysqlphpmyadmin-to-print-data-title-on-page/#findComment-588792 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.