Yet another weary MySQL question

Hi, Everyone

I hope you are enjoying the weekend and staying cool - we hit 124°F yesterday in the Coachella Valley. While I have found several sources of ideas for a simple, automated MySQL upload whenever my app is used (showing location data), none of them fit perfectly. Such is life.

My primary question here is that all of the references showed the creation of a simple php script that, ostensibly, tells MySQL how to behave and is to be "uploaded to my server" but this concept/action is not explained. Is this something that gets uploaded to the MySQL app on GoDaddy? There is an IMPORT button on the top of the page but importing a sample php script on the Internet gave me nothing but errors.

I know I am sounding like a whiney "B" but I cannot find information that is written at the level of my understanding, which is basically severely limited. Would someone please tell me where I should locate to following script and how I get it where it belongs? I have included a link, as well because I could not format the code.

Thank you for your patience and support

<?php

DEFINE ('DBUSER', 'YourDatabaseUserName'); 
DEFINE ('DBPW', 'YourPassword'); 
DEFINE ('DBHOST', 'YourDatabaseHost'); 
DEFINE ('DBNAME', 'YourDatabaseName'); 
 
$dbc = mysqli_connect(DBHOST,DBUSER,DBPW);
if (!$dbc) {
    die("Database connection failed: " . mysqli_error($dbc));
    exit();
}

$dbs = mysqli_select_db($dbc, DBNAME);
if (!$dbs) {
    die("Database selection failed: " . mysqli_error($dbc));
    exit(); 
}

$result = mysqli_query($dbc, "SHOW COLUMNS FROM customer");
$numberOfRows = mysqli_num_rows($result);
if ($numberOfRows > 0) {

/* By changing Fred below to another specific persons name you can limit access to just the part of the database for that individual. You could eliminate WHERE recorder_id='Fred' all together if you want to give full access to everyone. */

$values = mysqli_query($dbc, "SELECT * FROM customer WHERE recorder_id='Fred'");
while ($rowr = mysqli_fetch_row($values)) {
 for ($j=0;$j<$numberOfRows;$j++) {
  $csv_output .= $rowr[$j].", ";
 }
 $csv_output .= "\n";
}

}

print $csv_output;
exit;
?>

php_setup.txt (1.1 KB)

you can put it anywhere on your web server in a directory, which is accessible from the internet, for example in the same directory of your index.html file or any subdirectory from there

Taifun

Thank you, I was trying to make it difficult again.

Oops, it is still difficult;(.

I have a php file I copied right from the author's page except with my data populating the first four lines. When I try to upload it, I receive all sorts of errors so I am still not doing something right. I am including a couple of screenshots and the php code. I don't know if the code is old, or just me:) but another pair of skilled eyes would be greatly appreciated.

php_setup.txt (1.1 KB)

phpMyAdmin is a tool to manage your database on your web server
it looks like you are trying to install your php file in your database, which is incorrect

to transfer files to your web server usually you use ftp or a file manager on your web server to transfer it manually

Taifun