TheConeHead
Programmer
Can anyone provide me with a sample connection string and query? I am working within PHP and am familiar with SQL (not My SQL)
Thanks!
Thanks!
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
<?php
# sample connection query
$link = mysql_connect('ServerNameOfMySql', 'MyLoginnameForMySql', 'MyPasswdForMySql') ;
if ($link && mysql_db_select_db("samp_db")
{
$qry = 'SELECT * FROM MyTbl' ;
$result = mysql_query($qry)
or die("Sorry Query failed");
while ($row = mysql_fetch_row($result))
{
for ($i = 0; $i < mysql_num_fields($result); $i++)
{
if ($i > 0)
print("\t") ;
print($row[$i]) ;
}
print("\n") ;
}
}
mysql_free_result($result) ;
?>
$qry = 'SELECT Fld1, Fld2, Fld3 FROM MyTbl' ;
$qry = 'SELECT FirstName, Lastname FROM Names' ;
$result = mysql_query($result)
or die() ;
while ($row = mysql_fetch_array($result))
{
printf("%s %s\n", $row[0], $row[1]) ;
printf("%s %s\n", $row['FirstName'],
$row['Lastname']) ;
}