PHP - Help With Coding On Google Map
Hi I have been working on this code for almost two weeks and can't get over the last hurdle. If someone can put a fresh set of eys on it I would appreciate it. I have 3 files - a geocoder php script which I can't get to work, but it is exactly like the example given on Google except that I have my addresses broken down by street, city, state and zip.
- marker.php which is echoing the data correctly, and my map - location.html which pulls up a map but no markers. my geocoder script is below: Code: [Select] <?php define("MAPS_HOST", "maps.google.com"); define("KEY", "mykey"); // Opens a connection to a MySQL server $connection = mysql_connect("server", "user","pwd"); if (!$connection) { die("Not connected : " . mysql_error()); } // Set the active MySQL database $db_selected = mysql_select_db("Db", $connection); if (!$db_selected) { die("Can\'t use db : " . mysql_error()); } // Select all the rows in the markers table $query = "SELECT * FROM table WHERE 1"; $result = mysql_query($query); if (!$result) { die("Invalid query: " . mysql_error()); } // Initialize delay in geocode speed $delay = 0; $base_url = "http://" . MAPS_HOST . "/maps/geo?output=xml" . "&key=" . KEY; // Iterate through the rows, geocoding each address while ($row = @mysql_fetch_assoc($result)) { $geocode_pending = true; while ($geocode_pending) { $street = $row["street"]; $city = $row["city"]; $state = $row["state"]; $zip_code = $row["zip_code"]; $id = $row["id"]; $request_url = $base_url . "&q=" . urlencode($street + $city + $state + $zip_code); $xml = simplexml_load_file($request_url) or die("url not loading"); $status = $xml->Response->Status->code; if (strcmp($status, "200") == 0) { // Successful geocode $geocode_pending = false; $coordinates = $xml->Response->Placemark->Point->coordinates; $coordinatesSplit = split(",", $coordinates); // Format: Longitude, Latitude, Altitude $lat = $coordinatesSplit[1]; $lng = $coordinatesSplit[0]; $query = sprintf("UPDATE table " . " SET lat = '%s', lng = '%s' " . " WHERE id = '%s' LIMIT 1;", mysql_real_escape_string($lat), mysql_real_escape_string($lng), mysql_real_escape_string($id)); $update_result = mysql_query($query); if (!$update_result) { die("Invalid query: " . mysql_error()); } } else if (strcmp($status, "620") == 0) { // sent geocodes too fast $delay += 100000; } else { // failure to geocode $geocode_pending = false; echo "Address " . $street . " failed to geocoded. "; echo "Received status " . $status . " \n"; } usleep($delay); } } ?> my html file looks like the following: Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>location</title> <script src="http://maps.google.com/maps?file=api&v=2&key=mykey" type="text/javascript"></script> <script type="text/javascript"> var iconFlag = new GIcon(); iconFlag.image = 'images/redflag.png'; iconFlag.iconSize = new GSize(12, 20); iconFlag.iconAnchor = new GPoint(6, 20); iconFlag.infoWindowAnchor = new GPoint(5, 1); var iconBlue = new GIcon(); iconBlue.image = 'images/glossy-ball.png'; iconBlue.iconSize = new GSize(12, 20); iconBlue.iconAnchor = new GPoint(6, 20); iconBlue.infoWindowAnchor = new GPoint(5, 1); var iconRed = new GIcon(); iconRed.image = 'images/redbutton.png'; iconRed.iconSize = new GSize(12, 20); iconRed.iconAnchor = new GPoint(6, 20); iconRed.infoWindowAnchor = new GPoint(5, 1); var customIcons = []; customIcons["Db1"] = iconFlag; customIcons["Db2"] = iconBlue; customIcons["Db3"] = iconRed; function load() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map")); map.addControl(new GSmallMapControl()); map.addControl(new GMapTypeControl()); map.setCenter(new GLatLng(39.0000, 72.0000), 11); // Change this depending on the name of your PHP file GDownloadUrl("marker.php", function(data) { var xml = GXml.parse(data); var markers = xml.documentElement.getElementsByTagName("markers"); for (var i = 0; i < markers.length; i++) { var informant = markers[i].getAttribute("id"); var firstname = markers[i].getAttribute("firstname"); var lastname = markers[i].getAttribute("lastname"); var phone = markers[i].getAttribute("phone"); var zip_code = markers[i].getAttribute("zip_code"); var type = markers[i].getAttribute("type"); var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng"))); var marker = createMarker(point, id, firstname, lastname, street, city, state, zip_code, type); map.addOverlay(marker); } }); } } function createMarker(point, id, firstname, lastname, street, city, state, zip_code, type) { var marker = new GMarker(point, customIcons[type]); var html = "<b>" + id + "</b> <br/>" + firstname + "<br/>" + lastname + "<br/>" + phone + "<br/>" + street + "<br/>" + city + "<br/>" + state + "<br/>" + zip_code +"<br/>" + type; GEvent.addListener(marker, 'click', function() { marker.openInfoWindowHtml(html); }); return marker; } //]]> </script> </head> <body background="images/bg2.jpg"> <body onload="load()" onunload="GUnload()"> <center><div id="map" style="width: 800px; height: 600px"></div></center> </body> </html> Thanks for any help Similar Tutorials<?php require_once('Connections/check_mag.php'); ?> what goes wrong with that code and when i push a link for another post in my page nothing changes? where is the wrong plzzzzz help i cant understand im looking for this for 5 days and i cant find the mistake pllzzzzzzzz heellp . if you write your cooment please give me details because i cant understand very well everything thanx for everythin:) <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_check_mag, $check_mag); $query_getArchives = "SELECT DISTINCT DATE_FORMAT(news.updated, '%M %Y') AS archive, DATE_FORMAT(news.updated, '%Y-%m') AS link FROM news ORDER BY news.updated DESC "; $getArchives = mysql_query($query_getArchives, $check_mag) or die(mysql_error()); $row_getArchives = mysql_fetch_assoc($getArchives); $totalRows_getArchives = mysql_num_rows($getArchives); mysql_select_db($database_check_mag, $check_mag); $query_getRecent = "SELECT news.post_id, news.title FROM news ORDER BY news.updated DESC LIMIT 10 "; $getRecent = mysql_query($query_getRecent, $check_mag) or die(mysql_error()); $row_getRecent = mysql_fetch_assoc($getRecent); $totalRows_getRecent = mysql_num_rows($getRecent); mysql_select_db($database_check_mag, $check_mag); $query_getDisplay = "SELECT news.title, news.blog_entry, DATE_FORMAT(news.updated, '%M %e, %Y') AS formatted FROM news ORDER BY news.updated DESC LIMIT 2 "; $getDisplay = mysql_query($query_getDisplay, $check_mag) or die(mysql_error()); $row_getDisplay = mysql_fetch_assoc($getDisplay); $totalRows_getDisplay = mysql_num_rows($getDisplay); $var1_getdisplay2 = "-1"; if (isset($_GET['archive'])) { $var1_getdisplay2 = $_GET['archive']; $query_getdisplay = sprintf("SELECT news.title, news.blog_entry, DATE_FORMAT(news.updated, '%%M %%e, %%Y') AS formatted FROM news WHERE DATE_FORMAT(news.updated, '%%Y-%%m') = %s ORDER BY news.updated DESC ", GetSQLValueString($var1_getdisplay2, "text")); }elseif (isset($_GET['post_id'])) { $var2_getdisplay3 = $_GET['post_id']; $query_getdisplay= sprintf("SELECT news.title, news.blog_entry, DATE_FORMAT(news.updated, '%%M %%e, %%Y') AS formatted FROM news WHERE news.post_id = %s ", GetSQLValueString($var2_getdisplay3, "int")); }else{ $query_getDisplay = "SELECT news.title, news.blog_entry, DATE_FORMAT(news.updated, '%M %e, %Y') AS formatted FROM news ORDER BY news.updated DESC LIMIT 2 ";} $getDisplay = mysql_query($query_getDisplay, $check_mag) or die(mysql_error()); $row_getDisplay = mysql_fetch_assoc($getDisplay); $totalRows_getDisplay = mysql_num_rows($getDisplay); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/totemp.dwt.php" codeOutsideHTMLIsLocked="false" --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="robots" content="index, follow" /> <meta name="keywords" content="Σύλλογος Ηπειρωτών Πιερίας,Χορευτικός Σύλλογος,Χορός,Χορευτής,Ήπειρος,SYLLOGOS HPIROTON PIERIAS,pieria,ΠΙΕΡΙΑ" /> <meta name="description" content="Σύλλογος Ηπειρωτών Πιερίας,Χορευτικός Σύλλογος,Χορός,Χορευτής,Ήπειρος,SYLLOGOS HPIROTON PIERIAS,pieria,ΠΙΕΡΙΑ" /> <!-- InstanceBeginEditable name="doctitle" --> <title>Check Magazine</title> <!-- InstanceEndEditable --> <link href="styles/check_cs5.css" rel="stylesheet" type="text/css" /> <link href="styles/check_menu.css" rel="stylesheet" type="text/css" /> <!-- InstanceBeginEditable name="head" --> <!-- InstanceEndEditable --> </head> <body> <!-- DO NOT MOVE! The following AllWebMenus linking code section must always be placed right AFTER the BODY tag--> <!-- ******** BEGIN ALLWEBMENUS CODE FOR menu ******** --> <script type="text/javascript">var MenuLinkedBy="AllWebMenus [4]",awmMenuName="menu",awmBN="798";awmAltUrl="";</script><script charset="UTF-8" src="menu.js" type="text/javascript"></script><script type="text/javascript">awmBuildMenu();</script> <!-- ******** END ALLWEBMENUS CODE FOR menu ******** --> <div id="container"> <h1>Check Magazine: Fashion and Lifestyle</h1> <div id="eikona"><img src="images/silogos.jpg" width="1211" height="134" alt="silogos" /></div> <div id="bara"> <p> </p> </div> <!-- InstanceBeginEditable name="EditRegion3" --> <div id="blog"> <p> </p> <div id="archive"> <h3>Archives</h3> <ul><?php do{?> <li><a href="news1.php"> <a href="news1.php"><?php echo $row_getArchives['archive'];?></a><a></li> <?php } while ($row_getArchives=mysql_fetch_assoc($getArchives));?> </ul> </div> <div id="recent"> <h3>RECENT</h3> <ul> <?php do { ?> <li><a href="news1.php?post_id=<?php echo $row_getRecent['post_id']; ?>"><?php echo $row_getRecent['title']; ?></a></li> <?php } while ($row_getRecent = mysql_fetch_assoc($getRecent)); ?> </ul> </div> <div id="blog_posts"> <?php do { ?> <h2><?php echo $row_getDisplay['title']; ?></h2> <p>Uploaded on <?php echo $row_getDisplay['formatted']; ?></p> <p><?php echo nl2br($row_getDisplay['blog_entry']); ?></p> <?php } while ($row_getDisplay = mysql_fetch_assoc($getDisplay)); ?> </div> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> </div> <!-- InstanceEndEditable --> <p> </p> </div> </body> <!-- InstanceEnd --></html> <?php mysql_free_result($getArchives); mysql_free_result($getRecent); mysql_free_result($getDisplay); ?> I'm unable to update the table. Could someone tell me why? $dfield1 = mysql_real_escape_string($field1); $dfield2 = mysql_real_escape_string($field2); $dfield3 = mysql_real_escape_string($field3); $dfield4 = mysql_real_escape_string($field4); $result =sprintf("SELECT * FROM db1 WHERE username ='%s'", $dfield1); $resultf = mysql_query($result); if (mysql_num_rows ($resultf) > 0){ $register = "&err=Not Available. Retry."; echo($register); } else { mysql_query("INSERT INTO db1 (name, birthday, street, phone) VALUES ('$dfield1', '$dfield2', '$dfield3', '$dfield4')"); $register = "Successful."; echo($register); } Hai everbody; I am finishing my site to open for public but before i have a small problem! Actually I am using SMF forum software! I need this help very urgently ! Just need to add login (logout) & register in the template menu!! Please guys try to help me out !! I will join the index_template.php file for you to make the correction ! (sorry for my bad english) Thank You a LOT in advance Daya Could some one please guide me to a possible script to accomplish this task.... I want to pull and display two separate things that are in two separate places and display them as one link on a page. I have figured out how to display the data to a page and also how to display the files to a page separately but need to accomplish this and join the 3 things together. I have a library table in the database that stores the product_code and product_name example: pk-pen(product_code) traditional fountain pen(product_name) ---- (this is where I need to get the data from) Then I have a folder on the server that is called library that has the pdf files in it. Each pdf file has the same name as the product_code that is in the database. example: pk-pen_ins.pdf What I need to accomplish is grabbing the product_code and product_name for the database and then go to the folder on the server and add the correct pdf file with that data and display it as a link on a page for customers to download. bee struggling with this and pasted code that i have to do each task separately but cant seem to get it all in one script to do the above. I understand that this could be asking for a lot here but I am new to this and would be forever in debt to your kindness. Thanks on this in advance Hi I am beginning the first stages of a tumble log and am having some trouble, this works. <?php $connection = @mysql_connect('localhost','admin','asdf'); if(!$connection) ( die('Could not connect to the server!' .mysql_error()) ) ?> but if I add the following I get an error: <?php $connection = @mysql_connect('localhost','admin','asdf'); if(!$connection) ( die('Could not connect to the server!' .mysql_error()) ) if(!mysql_select_db('tumblelog')) ( die('Could not connect to database') ) ?> This is the error: Quote Parse error: syntax error, unexpected T_IF in E:\AppServ\www\tumblelog\database.php on line 10 I also tried this to solve the problem: <?php $connection = @mysql_connect('localhost','admin','glock123'); if(!$connection) ( die('Could not connect to the server!' .mysql_error()) ) $db = mysql_select_db('tumblelog')) if(!$db) ( die('nope') ) ?> that only gives me this error: Quote Parse error: syntax error, unexpected T_VARIABLE in E:\AppServ\www\tumblelog\database.php on line 9 Im having trouble making a code for a feedback system. Can anyone help me to make a code like this. I have a table w/c contains -------------------------------------------- | Itemname | Itemprice | Seller | Laptop | 15000 | Name Phone | 5000 | Name ----------------------------------- Then.. i want a code that will query those values.. And have a button : [BUY] and [POST FEEDBACK] after the values. Then after clicking POST FEEDBACK it will show the values of the SELLER name in another page. HELP ME PLS Hi All I am fairly new to the PHP world so please excuse my ignorance. (I am trying!) Basically I bought a commercially available PHP script and created my own script to work alongside the bought one. What happened then is that the developers of the script I bought released a new version of the software. My script no longer works and is throwing up the following error PHP Fatal error: Using $this when not in object context in C:\wamp\www\classifieds\system\core\System.php on line 175 I've worked out that the script fails on this line, in the new version of the software. $dbhost = System::getSystemSettings('DBHOST'); On review of the commercial script's coding, I noticed that where the old version used the syntax above, the new version uses a syntax as shown below $this->appContext->getSystemSettings('DBHOST'); So I went and modified my script (mismatched.php) to read as follows $dbhost = $this->appContext->getSystemSettings('DBHOST'); But im now getting the following errors PHP Parse error: syntax error, unexpected T_REQUIRE_ONCE, expecting T_FUNCTION in C:\wamp\www\classifieds\admin\mismatched.php on line 5 I'd appreciate any ideas you may have that could help me get my script (mismatched.php) working again. Thanks again Ali Hi I need some help. I have a page which will show all the result based on the user sign in. And it will show something like this ID | Event Start Date | Event End Date | Event Details 1 19-11-2011 20-11-2011 View Event Details The view event details is a link so when I click on the link, it will link me to the next page (eventDetails.php?id=1) And at eventDetails.php?id=1 page, it would requires user to input whether they will be attending or not and will they be bringing their friend along then submit the form. When I submit, how do I pass all the data from eventDetails.php?id=1 page to confirmation.php page (after submitting)? You might want to refer to the attached coding. All the 2 php pages are working fine but when submit to confirmation.php page, the data are not post over so I didn't attach the confirmation.php page. Thanks Ben Chew [attachment deleted by admin] How can I get it so the following work: echo utf8_decode($xml->healings[0]->$xmla[0]->descrip[0]); // NOT work echo utf8_decode($xmlb); // NOT work <?php $xml = simplexml_load_file('extra.xml'); $xmla = "test"; $xmlb = "$xml->healings[0]->".$xmla."[0]->descrip[0]"; echo utf8_decode($xml->healings[0]->test[0]->descrip[0]); // works echo utf8_decode($xml->healings[0]->$xmla[0]->descrip[0]); // NOT work echo utf8_decode($xmlb); // NOT work ?> So I put this in the wrong place so ill try again, I need to write a code to add the price of five items with a subtotal, with tax, and then a grand total. What is the best way to do this? Every way I have tried isnt working PLEASEEEEEE HELP!!! Using crimson editor Is there a way i can make a php code for making a lesson then upload to my made system? Im newbie here. so basically, i need to make an e-learning system that lets the user make a lesson then upload it so that other user can view their made lesson.. Someone help me pls. Im making an E-learning system that when Student registers the Teacher will approve.. So i've got here a code that outputs all those who registered via Checkbox. Code: [Select] <form name="formapprove" method="POST" action="valval3.php" > <div id="apDiv12"><input type="image" src="images/Approve.png" name="approve" value="approve" width="170" height="35" border="0" > </div> <div id="apDiv11"> <input type="image" src="images/reject.png" name="reject" width="170" height="35" border="0" value="reject"> </div> <div id="apDiv14">'; $host="localhost"; $username="root"; $password=""; $db_name="dbreg"; $tbl_name="account"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); echo "<table border=\"5\" width=\"400\" >"; echo "<tr><th>List of Student to be approve</th>"; if(mysql_num_rows($result)) { while($row = mysql_fetch_assoc($result)) { echo "<tr><td>"; echo "<input type='checkbox' name='list[]' value='".$row['Username']."'>".$row['famname'].",".$row['gname']. ",".$row['mname']. ".<br/></td>"; echo "</tr></input>"; } } else { echo "<tr><td align=\"center\"> No Student to be Approve / Reject </td></tr>"; } echo' </form> Then the file "valval3.php" will be the one that will save the variables in my database.. Code: [Select] <?php session_start(); if(isset($_SESSION['uname2']) || ($_SESSION['section'])){ $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } if(isset($_POST['approve_x'], $_POST['approve_y'])) { mysql_select_db("dbreg", $con); $uname = $_SESSION['uname2']; $sec = $_SESSION['section']; $sql="SELECT * FROM account where sec='$sec'"; $result=mysql_query($sql); if(mysql_num_rows($result)) { while($row = mysql_fetch_assoc($result)) { $fullname = "" .$row['famname']. ", " .$row['gname']. " " .$row['mname']. "."; } foreach ($_POST['list'] as $checkbox) { $sql="SELECT * FROM account WHERE sec='$sec'"; } $result=mysql_query($sql); if(mysql_num_rows($result)) { while($row = mysql_fetch_assoc($result)) { $username = $row['Username']; $password = $row['Password']; $gname = $row['gname']; $mname = $row['mname']; $famname = $row['famname']; $sec = $row['sec']; $studnum = $row['studnum']; $fullname = "" .$row['famname']. ", " .$row['gname']. " " .$row['mname']. "."; $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $gname = stripslashes($gname); $famname = stripslashes($famname); $gname = mysql_real_escape_string($gname); $famname = mysql_real_escape_string($famname); $mname = stripslashes($mname); $mname = mysql_real_escape_string($mname); foreach ($_POST['list'] as $checkbox) { mysql_query("INSERT INTO dbaccount (Username, Password, gname, famname, mname, sec, studnum, fullname) VALUES ('$username', '$password', '$gname', '$famname', '$mname', '$sec', '$studnum', '$checkbox')") or die(mysql_error); mysql_query("DELETE FROM account WHERE sec='$sec'") or die(mysql_error); } echo '<script type="text/javascript"> {alert("Approved!");} </script>'; echo '<meta http-equiv="REFRESH" content="0;url=approvereject2.php">'; mysql_close($con); } } else { echo '<meta http-equiv="REFRESH" content="0;url=approvereject2.php">'; } }elseif(isset($_POST['reject_x'], $_POST['reject'])) { mysql_select_db("dbreg", $con); foreach ($_POST['list'] as $checkbox) { $sql="SELECT * FROM account WHERE sec='$sec'"; } $result=mysql_query($sql); if(mysql_num_rows($result)) { foreach ($_POST['list'] as $checkbox) { mysql_query("DELETE FROM account WHERE sec='$sec'") or die(mysql_error); } echo '<script type="text/javascript"> {alert("Rejected!");} </script>'; echo '<meta http-equiv="REFRESH" content="0;url=approvereject2.php">'; } else { echo '<meta http-equiv="REFRESH" content="0;url=approvereject2.php">'; } } else { echo '<meta http-equiv="REFRESH" content="0;url=approvereject2.php">'; } } } else { header("location:failunautho.php");; } ?> I tested my codes. Its only working if theres only 1 user registered ( which means one checkbox would appear in page) But when i tested to have 3 users registered and not yet approve, There would be an error saying.. Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Documents and Settings\Ken\Desktop\xampplite\htdocs\Pages\valval3.php on line 49 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\Documents and Settings\Ken\Desktop\xampplite\htdocs\Pages\valval3.php on line 49 $username = mysql_real_escape_string($username); <-- line #49 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Documents and Settings\Ken\Desktop\xampplite\htdocs\Pages\valval3.php on line 50 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\Documents and Settings\Ken\Desktop\xampplite\htdocs\Pages\valval3.php on line 50 $password = mysql_real_escape_string($password); <-line #50 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Documents and Settings\Ken\Desktop\xampplite\htdocs\Pages\valval3.php on line 54 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\Documents and Settings\Ken\Desktop\xampplite\htdocs\Pages\valval3.php on line 54 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Documents and Settings\Ken\Desktop\xampplite\htdocs\Pages\valval3.php on line 55 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\Documents and Settings\Ken\Desktop\xampplite\htdocs\Pages\valval3.php on line 55 $gname = mysql_real_escape_string($gname); <-line #54 $famname = mysql_real_escape_string($famname); <-line# 55 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Documents and Settings\Ken\Desktop\xampplite\htdocs\Pages\valval3.php on line 58 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\Documents and Settings\Ken\Desktop\xampplite\htdocs\Pages\valval3.php on line 58 mname = mysql_real_escape_string($mname); <-line #58 Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Documents and Settings\Ken\Desktop\xampplite\htdocs\Pages\valval3.php on line 64 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\Documents and Settings\Ken\Desktop\xampplite\htdocs\Pages\valval3.php on line 64 mysql_error VALUES ('$username', '$password', '$gname', '$famname', '$mname', '$sec', '$studnum', '$checkbox')") or die(mysql_error) <-line #64 Then still it saves 3 variables.. but all the same. Hope Someone could help me .. Hello guys it's me again. I have not posted a question in awhile so I am glad to be on PHPFreaks again. Anyways here is my question, I have simple "Filter By" or "Refine By" script I am developing. It's foundation is primarily database (MySQL) and does not use XML or other table files. This script simply add's filtered array ("objects") to the url as the customer filters his/her search. An example, $attributeCodes("processor_type","color","memory"); // These arrays are defined and built from the database on the time of the request. So they are automatically updated. The above array is used in an if/and/or statement to look for these attribute codes. If it finds it and it has a value it then refines the MySQL query to look for products with the said attribute code. Now that we have the basics out there of how it works I am at the part where it confuses me. I give the user the ability to filter his/her search, however I want the user to be able to remove these filters separately if wanted. So for example the customer filters, Domain.com/search/productsearch.php?catId=112&processor_type=AMD&memory=2gb The customer does not need the memory filter and wishes to remove that specific item or vice-verse he/she does not want to search by processor_type. How is it that I can remove specifically one attribute and its value from the URL? So the url will then look like, Domain.com/search/productsearch.php?catID=112&processor_type=AMD or Domain.com/search/productsearch.php?catID=112&memory=2gb Any help would be great. Or if you have any suggestions on a different method to filter by attributes products. Suggestions and criticism are welcome. Please do not be shy or modest when it comes to giving me advice as I am trying to learn efficiently. - Travis I have a small mp3 script and its running accurately ...i want to check the mp3 URL before playing it whether the mp3 link active or broken ....how to check the link is active or broken in php thanks I have a sql statement w/c suppose to output only those records w/c has a name of seller. But, it keeps showing all the records. Code: [Select] <?php session_start(); if(isset($_SESSION['name']) || ($_SESSION['contact']) || ($_SESSION['address']) ) { ini_set('display_errors', 0); $name = $_SESSION['name']; $contact = $_SESSION['contact']; $address = $_SESSION['address']; ?> <div id="apDiv1"> <?php echo "Name : $name"; echo "</br>"; echo "Name : $contact"; echo "</br>"; echo "Name : $address"; ?> <div id="apDiv2"> <?php $host="localhost"; $username="root"; $password=""; $db_name="feedbackdb"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM Feedbacks WHERE Seller = $name"; $result=mysql_query($sql); echo "<table border=\"5\" width=\"600\" >"; echo "<tr><th>Feedbacks</th><th>From</th><th> To </th>"; if(mysql_num_rows($result)) { while($row = mysql_fetch_assoc($result)) { echo "<tr><td>"; echo "" .$row['Feedback']."<br></td>"; echo "<td>".$row['From']."<br></td>"; echo "<td>".$row['Seller']."<br></td>"; echo "</tr>"; } } else { echo "<tr><td align=\"center\"> No Feedback</td></tr>"; } ?></div> </div> <?php } else { header("location:loginpage.php");; } ?> Hi guys,
I am needing some help of how to place the coding as I can not get it to work.
--
Basically I am building a website for the local motorclub and want some code that will "add up" each persons results.
Here is what I have come up with but it does not work;
<?php $total = mysql_fetch_array("SELECT cat1 + cat2 + cat3 + cat4 + cat5 + cat6 AS total FROM results") ?> <?php $cautotest_results = mysql_query("SELECT * FROM results WHERE cat ='1' ORDER BY cattotal DESC"); if(mysql_num_rows($cautotest_results) == '') { echo "<p>No Results Available."; } else { echo "<table width=\"800\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\" class=\"greywritinglight\" align=\"center\"> <tr align=\"center\"> <td>Competitor</td> <td>Vehicle</td> <td>Class</td> <td>Skipton</td> <td>Weston</td> <td>King Bros</td> <td>Normans</td> <td>Norwood</td> <td>Uniroyal</td> <td>Total</td> </tr>"; $x=1; while($results_row = mysql_fetch_array($cautotest_results)) { if($x%2): $rowbgcolor = "#FFFFFF"; else: $rowbgcolor = "#EEEEEE"; endif; echo "<tr align=\"center\" bgcolor=\"" .$rowbgcolor. "\">"; echo "<td>" . $results_row['competitor'] . "</td>"; echo "<td>" . $results_row['catvehicle'] . "</td>"; echo "<td>" . $results_row['catclass'] . "</td>"; echo "<td>" . $results_row['cat1'] . "</td>"; echo "<td>" . $results_row['cat2'] . "</td>"; echo "<td>" . $results_row['cat3'] . "</td>"; echo "<td>" . $results_row['cat4'] . "</td>"; echo "<td>" . $results_row['cat5'] . "</td>"; echo "<td>" . $results_row['cat6'] . "</td>"; echo "<td>" . $total . "</td>"; echo "</tr>"; $x++; } echo "</table>"; } ?>Its the top line of coding... and the echo .total. at the bottom. If you could please correct me I would be ever so grateful. If you need more info please just ask. All help is appreciated. JTM. Edited by JTM, 17 August 2014 - 12:45 AM. I know this form doesn't really work, but the FTP part *should* work. I select a file, and click upload, Chrome shows the file is uploading and gets to 100% then fails. I'm getting "File Upload Failed!" on line 112 every time, but I can't seem to figure out why. I'm hoping a pair of expert eyes can spot it quickly. Code: [Select] Upload A File: <form enctype="multipart/form-data" action="File_Upload.php" method="POST"> <table> <tr><td>Song Title:</td><td><input></input></td></tr> <tr><td>Singer/Group:</td><td><input></input></td></tr> <tr><td>Album Name:</td><td><input></input></td></tr> <tr><td>Video Link:</td><td><input></input></td></tr> <tr><td>Category:</td><td><input></input></td></tr> <tr><td>Choose a file to upload:</td><td><input name="uploadedfile" type="file" /></td></tr> <tr><td><input type="submit" value="Upload File" /></td></tr> </table> </form> <?php //********************************************************************************************** echo "Please wait while we attempt to upload your file...<br><br>"; //********************************************************************************************** $target_path = "temp_uploads/"; $flag = 0; // Safety net, if this gets to 1 at any point in the process, we don't upload. $filename = $_FILES['uploadedfile']['name']; $filesize = $_FILES['uploadedfile']['size']; $mimetype = $_FILES['uploadedfile']['type']; $filename = htmlentities($filename); $filesize = htmlentities($filesize); $mimetype = htmlentities($mimetype); $target_path = $target_path . basename( $filename ); if($filename != ""){ echo "Beginning upload process for file named: ".$filename."<br>"; echo "Filesize: ".$filesize."<br>"; echo "Type: ".$mimetype."<br><br>"; } //First generate a MD5 hash of what the new file name will be //Force a MP3 extention on the file we are uploading $hashedfilename = md5($filename); $hashedfilename = $hashedfilename.".mp3"; //Check for empty fileif($filename == ""){$error = "No File Exists!"; $flag = $flag + 1; //Now we check that the file doesn't already exist. $existname = "temp_uploads/".$hashedfilename; if(file_exists($existname)){ if($flag == 0){ $error = "Your file already exists on the server! Please choose another file to upload or rename the file on your computer and try uploading it again!"; } $flag = $flag + 1; } //Whitelisted files - Only allow files with MP3 extention onto server... $whitelist = array(".mp3"); foreach ($whitelist as $ending) { if(substr($filename, -(strlen($ending))) != $ending) { $error = "The file type or extention you are trying to upload is not allowed! You can only upload MP3 files to the server!"; $flag++; } } //Now we check the filesize. If it is too big or too small then we reject it //MP3 files should be at least 1MB and no more than 25 MB if($filesize > 26214400){ //File is too large if($flag == 0){ $error = "The file you are trying to upload is too large! Your file can be up to 25 MB in size only. Please upload a smaller MP3 file or encode your file with a lower bitrate."; } $flag = $flag + 1; } if($filesize < 1048600){ //File is too small if($flag == 0){ $error = "The file you are trying to upload is too small!Your file has been marked as suspicious because our system has determined that it is too small to be a valid MP3 file.Valid MP3 files must be bigger than 1 MB and smaller than 25 MB."; } $flag = $flag + 1; } //Check the mimetype of the file if($mimetype != "audio/x-mp3" and $mimetype != "audio/mpeg"){ if($flag == 0){ $error = "The file you are trying to upload does not contain expected data.Are you sure that the file is an MP3?"; }$flag = $flag + 1; } //Check that the file really is an MP3 file by reading the first few characters of the file $f = @fopen($_FILES['uploadedfile']['tmp_name'],'r'); $s = @fread($f,3); @fclose($f); if($s != "ID3"){if($flag == 0){ $error = "The file you are attempting to upload does not appear to be a valid MP3 file.";}$flag++; } //All checks are done, actually move the file... if($flag == 0){ if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { //Change the filename to MD5 hash and FORCE a MP3 extention. if(@file_exists("../music/".$filename)){ //Rename the file to an MD5 version rename("uploads/".$filename, "uploads/".$hashedfilename); echo "The file ".basename( $filename )." has been uploaded. Your file is <a href='uploads/$hashedfilename'>here</a>."; } else{ echo "There was an error uploading the file, please try again! (1)"; } } else{ echo "There was an error uploading the file, please try again! (2)"; } } else { echo "File Upload Failed!<br>"; if($error != ""){ echo $error; } } ?> I am self taught and am trying very hard to get a log in page to work. The way i want it to work is that when they log in it uses a url stored in the database for their account. But i am having some much trouble working out a code that works and this is all i got: <?php include ('connection.php'); $username=$_POST['username5']; $password=$_POST['password5']; $query="SELECT password FROM merchants WHERE username = '$_POST(username5)'"; if ($password == $query) { $url = "SELECT url FROM merchants WHERE username = '$_POST(username5)'"; header("Location: $url"); } else { echo urgh } ?> I'm trying to update a field in my MySQL but instead of updating this makes the field BLANK. my code: $SomeVar = $_POST['finco']; mysql_query("UPDATE c_applicants SET streetz='$cts' WHERE username = '".$SomeVar."'"); $result = mysql_query($query); Hey, I would there be a way i could create a form in which upon entering a domain name/URL it will tell you how many connections there are to the site and how many (if any) MySQL queries are running? If I add this line to a wordpress footer it displays the number of sql queries. Code: [Select] <?php echo get_num_queries(); ?> queries in <?php timer_stop(1); ?> seconds. Any help is greatly appreciated. Thanks. |