plet9090
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Connecting MySQL with php code in WordPressIt is the same database. Sorry for my confusion. I added a table in the same database and want users to be able to add information to the table when clicking on the map and saving.
How do I go about this?Forum: Fixing WordPress
In reply to: Connecting MySQL with php code in WordPressThe map is already completed, I have that done at http://www.tothenationsworldwide.com/social-travel-map/
Forum: Fixing WordPress
In reply to: Connecting MySQL with php code in WordPressI have added the table to my database on myphpadmin with my host. I just want to connect the map to the table so everytime someone clicks and saves, it adds a new row to the table and saves the information.
Forum: Fixing WordPress
In reply to: Connecting MySQL with php code in WordPressthis code:
<?php
require(“phpsqlinfo_dbinfo.php”);// Gets data from URL parameters
$name = $_GET[‘name’];
$address = $_GET[‘address’];
$lat = $_GET[‘lat’];
$lng = $_GET[‘lng’];
$type = $_GET[‘type’];// Opens a connection to a MySQL server
$connection=mysql_connect (“localhost”, $username, $password);
if (!$connection) {
die(‘Not connected : ‘ . mysql_error());
}// Set the active MySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
die (‘Can\’t use db : ‘ . mysql_error());
}// Insert new row with user data
$query = sprintf(“INSERT INTO markers ” .
” (id, name, address, lat, lng, type ) ” .
” VALUES (NULL, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’);”,
mysql_real_escape_string($name),
mysql_real_escape_string($address),
mysql_real_escape_string($lat),
mysql_real_escape_string($lng),
mysql_real_escape_string($type));$result = mysql_query($query);
if (!$result) {
die(‘Invalid query: ‘ . mysql_error());
}?>
Forum: Fixing WordPress
In reply to: Connecting MySQL with php code in WordPressIf I wanted to do a google maps API that when you clicked on it, it added a new infowindow that can be saved into MySQL (map already created http://www.tothenationsworldwide.com/social-travel-map/)
Where would I include this code you just showed me? into my functions.php?
Forum: Fixing WordPress
In reply to: Adding Google Maps API to WordPress After EnqueueOh okay, I see. Thanks for the heads up!
Forum: Fixing WordPress
In reply to: Adding Google Maps API to WordPress After EnqueueI finally got it by changing the CSS
thanks for your help!Forum: Fixing WordPress
In reply to: Adding Google Maps API to WordPress After EnqueueIf I rearrange the scripts on the page, they are rearranged in the page content. They also show up before they show up in the page content because I used the enqueue code in my functions.php and it has the API key first and map_script.js afterwards. If this makes sense…In my page source, the API key shows twice and the javascript file shows twice because I am enqueueing them and adding them to my page.
Forum: Fixing WordPress
In reply to: Adding Google Maps API to WordPress After EnqueueReverse the order of the scripts on the page? So the API key comes after the .js file with my javascript code? I tried, but still not showing.
Thanks for the help so far, this has taken me too long.
Any other suggestions?
Forum: Fixing WordPress
In reply to: Adding Google Maps API to WordPress After EnqueueThanks for the input. Okay I have the order like this on my page:
<script async defer src=”https://maps.googleapis.com/maps/api/js?key=AIzaSyCoy32ewrrQZ4cLSfQxd1u3vtL-4gFpTR0&signed_in=true&callback=initMap”></script>
<script type=”text/javascript” src=”http://www.tothenationsworldwide.com/wp-content/themes/university/js/map_script.js?ver=4.3.1″></script>
<div id=”map”></div>and in my CSS
#map{
height: 80%;
}and the code on my first post in my functions.php plus the revision with the uri
But still not showing the map. There is an extra space after the page’s title though.
Any advice?
Forum: Fixing WordPress
In reply to: Adding Google Maps API to WordPress After Enqueueenqueue script fixed to add uri so the map_script.js shows in the page source when you click on it, but still no map…
Forum: Fixing WordPress
In reply to: Adding Google Maps API to WordPress After EnqueueShould I add in the CSS
#map{
height: 100%
}And a <div id=”map”></div> onto my page?
Forum: Fixing WordPress
In reply to: Javascript into WordPressI have edited some things, but now
Any page I don’t have my [cutsom-map-shortcode], the page loads with Error Code: InvalidKeyOrUnauthorizedURLMapError. I have gone through the google api and registered and verified my site. That can’t be it.
I looked at my page source and saw there was a line break in my api key code, however if I try to retype or delete the break, it wont work. That could be what is stopping it, but it wont let me edit it.
Forum: Fixing WordPress
In reply to: Javascript into WordPressthe footer change didnt work. I have this code so far, and I know I’m almost there because the js path file is in my source code, I also see my script source with my api key. If I put the shortcode into the body of my page, it doesn’t show up in the page, so I know the shortcode is working. I just can’t find what else I am doing wrong.
Forum: Fixing WordPress
In reply to: Javascript into WordPressadd_shortcode('custom-map-shortcode', 'custom_map_shortcode_callback'); function custom_map_shortcode_callback() { return '<div id="map" style="height: 100%; margin: 0;padding: 0;"></div>'; } add_action( 'wp_enqueue_scripts', 'enqueue_map_script' ); add_action( 'wp_head', function(){ echo '<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAsQtOoS2PUGzaip_GDVzVhxKNI5mLVr1A&signed_in=true&callback=initMap"></script>'; }); function enqueue_map_script(){ global $post; if( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'custom-map-shortcode') ) { wp_enqueue_script( 'map-script', get_template_directory_uri() . '/js/map_script.js'); } }[Moderator note: code fixed. Please wrap code in the backtick character or use the code button.]