PHP - Problem With Mysql Db
I creating a members only web for my wife's 45th reunion. Everything went great untill I tackled something I never did before. PHP!
From the home page I'm having the user enter a username and password. I created the db using phpmyadmin and populated the table with two users. I checked the include and it is attempting to open the db and proper table. however, the php loginck.php, goes to the programed error message. Can I get a little assistance, it would be greatly appreciated. The form calls loginck,pfp and it gets there OK. <div class="art-blockcontent"> <div class="art-blockcontent-body"> <!-- block-content --> <div style="border: medium ridge blue;padding:15px; font-size:.8em;"> To assist in maintaining contact with our alumni, please register. <br> Already registered, sign in. <br><br> <form action="loginck.php" method="POST"> <label>Username: </label><input type="varchar" style="height: 1em;" size="15" name="passWord" required> <br> <label>Password: </label><input type="password" style="height: 1em;" size="15" name="passWord" required> <br><br> <center><input type="submit" value="Sign In"> <input type="reset" value="Clear"></center> </form> <br><br> <a href="register.html">Register</a> <br> <hr> <br> This site best viewed using Google Chrome, FireFox, or Opera browsers. </form> </div> <!-- /block-content --> I attached loginck.php and the inserted a called file 'z_db.php' for your review. I know if I can get this figured out I can do the others I need to do. Sorry, if ther's too many typos, I'm relegated to typing with one finger (Stroke) and in a wheel chair. Similar TutorialsThis is my code it always returns null i know that there is info in the table but it never works
$sql = 'SELECT * FROM $user WHERE ticker = "$ticker"'; $resultsql = mysqli_query($conp,$sql); $row = mysqli_fetch_array($resultsql); echo $row[ticker]; var_dump($row); echo '<br>'; Hi all. I'm not sure if this post belongs here or in the MySQL forum because I'm not entirely sure where the problem is. I have a script that takes data from a form and puts it into a database. There are several tables that were hand built and the script works fine with those. There are several tables that were converted from M$ Access to MySQL and the script does not work with those. All tables are InnoDB (if that matters). My inkling is that the converted tables that have weird field names, some containing "%","#", and "-" characters, are interfering with the MySQL statement to do the insert. Any thoughts on this? Would those odd characters for field names in fact affect the MySQL statement to enter data? P.S. I don't have access to the code at the moment. Can post it later unless the solution to this problem is simple (i.e. weird characters are the problem). Thanks in advance! Well im using paypal IPN im trying to get it to update something out of my database. Heres the code I think this is all you need Quote <?php include('config.php') ?> <?php function updatePayments($data){ global $link; if(is_array($data)){ $sql = mysql_query("INSERT INTO `serverb` WHERE name = 'Official' (gold) VALUES ('yes')"); } } ?> How do i get it to work? this is probably going to be really simple to fix but i cant figure it out :/ on one page i have a form which uses php to populate a dropdown box, now this form will allow the user to add 1 to the person which was selected in the dropdown box. The code for this looks like this.. <form action="addpoint.php" method="post"> <select> <?php $sql="SELECT id,name FROM man"; $result =mysql_query($sql); while ($data=mysql_fetch_assoc($result)){ ?> <option value ="<?php echo $data['id'] ?>" ><?php echo $data['name'] ?></option> <?php } ?> </select> <input type="submit" value="Add Point"/> </form> the php to process this form looks like this.. <?php $sql="UPDATE man SET points = (points + 1) WHERE name = ('$_POST[name]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "$_POST[name] has been added"; mysql_close($con) ?> The problem i have is that i dont think its pulling the name from the form so therefore it wont effect the database, ive tried the sql like this.. UPDATE man SET points = (points + 1) WHERE name = 'joe' and it works fine, any help would be gratefully received Owen HI - I am dynamically populating a drop down form list from the table 'hotels', and the 'est_town' column. It is supposed to only list each town once, but several towns appear multiple times. Am I using the DISTINCT command correctly and if so, what can i do to stop multiple appearances of towns? Code: [Select] $query_hotels_select = "SELECT DISTINCT est_town FROM hotels ORDER BY est_town ASC"; $hotels_select = mysql_query($query_hotels_select, $contractors) or die(mysql_error()); $row_hotels_select = mysql_fetch_assoc($hotels_select); $totalRows_hotels_select = mysql_num_rows($hotels_select); FORM BIT Code: [Select] <select name="digs" id="digs"> <?php do { ?> <option value="<?php echo $row_hotels_select['est_town']?>"<?php if (!(strcmp($row_hotels_select['est_town'], $row_hotels_select['est_town']))) {echo "selected=\"selected\"";} ?>><?php echo ucwords(strtolower($row_hotels_select['est_town']))?></option> <?php } while ($row_hotels_select = mysql_fetch_assoc($hotels_select)); $rows = mysql_num_rows($hotels_select); if($rows > 0) { mysql_data_seek($hotels_select, 0); $row_hotels_select = mysql_fetch_assoc($hotels_select); } ?> </select> Hello All, I Develop a small e-shop and i am facing a problem with invoice number I attach to an order the invoice number after client has successfully paid the order through Paypal, so i use the function below to retrieve the next inv num function GET_NEXT_INV_NUM() { $query= "SELECT MAX(inv_num) AS max_inv_num FROM orders"; $rs_query = mysql_query($query, $db) or die(mysql_error()); $row_query = mysql_fetch_assoc($rs_ws_mod_tvg_program_rec); $Next_inv_num = $row_query['max_inv_num']+1; return $Next_inv_num; } all looked to work fine but one day i realised that i have some invoice numbers that are missing, because in some cases instead of next inv to increase by one, is increased by two for example: INV NUMBERS: ============ 101 102 103 --->PROBLEM HERE (MISSING 104) 105 106 107 108 109 110 --->PROBLEM HERE (MISSING 111) 112 113 114 115 116 ... I check all of my code 3-4 times and all looks ok Can anyone help me please??? Thanks in advance (i apologise for my english) i could connect to the database and i dod nothing but to go through privileges in phpmyadmin by selecting privileges of the data base i design and by using the icon (action) it gave me a page to edit user i selected all check boxes mentioned in the global privileges then pressed go and for resource limits i read a note that said setting these options to zero removes the limit i set then to 1 and by using the connection function i could connect to the data base Code: [Select] <?php $connectdb = mysql_connect('localhost','root','') or die("not connected"); $selectdb = mysql_select_db("koora", $connectdb); if($selectdb) { echo "ok you,re now connected to table "; }else die("couldn,t connect to the database"); when refreshing my page it showed a message that said ok you,re now connected to table but i got another problem which is by using this form <form action="admins.php" method='post'> <table align="center" valign="center"> <tr> <td> Admin,s name: </td> <td><input type="text" name="adminname" /><br /></td></tr> <td>Admin,s Password: </td> <td><input type="password" name="adminpassword" /></td></tr> <td><input type="submit" value="Add New Admin" /></td></tr> </form> </tr> </table> to enter user name and password and by using the following code to get the data to the page the form directs to $admin = $_POST['adminname']; $password = $_POST['adminpassword']; if($admin&&$password){ mysql_query("INSERT INTO 'admin'('','admin','password') VALUES('','$admin','$password');"); echo "admin was added"; }else die("not added"); every time i enter a name and password to the text box and press enter it shows the message that admin was added and by checking the table which data are entered and stored i find nothing was added and the table is empty i guess that this problem is because of something wrong with the database may be something with settings or some like that i need your help with this problem Thanks in advance So i started on a project and not within long, i hit a wicked wall. The upper part works fine, i get the correct $pilotcorpid, however it doesnt seem to query the 2nd time, it just uses the variable from the first time. I have the information in the database, i just need to pick em out right. Code: [Select] <?php include 'config.php'; //database config include 'opendb.php'; //connect database $search = @$_GET['q'] ; //getting a name from a form $result = mysql_query("SELECT * FROM kb3_pilots WHERE plt_name='$search'")or die(mysql_error()); //here i choose to check in the kb3_pilots table, the plt_name column for the name written in the form earlier. $pilotcorpid=mysql_result($result,"plt_crp_id"); //since i found the guy in the query, i need info from that column, the plt_crp_id. $resultcorp = mysql_query("SELECT * FROM kb3_corps WHERE crp_id='$pilotcorpid'")or die(mysql_error()); //now we query the kb3_corps table to check if the corp exists. $pilotcorpname=mysql_result($resultcorp,"crp_name"); //Because it did, i will now pull out the name echo "TEST: Pilot Id: $pilotcorpid and corp name: $pilotcorpname"; include 'closedb.php'; ?> If somebody also have a big php/mysql ebook which explains commands great, that would be awesome. Best regards, Mumlebumle Senseis, I give nothing error. But mysql query dont put in to the table. I am using variables... $ara = '/Public Game - /'; $degistir = ''; $seo_var=preg_replace( $ara, $degistir, $yeni_title ); $ara2 = '/\s+/'; $degistir2 = ''; $seo_var2=preg_replace( $ara2, $degistir2, $seo_var ); $seo_link = tr_converter($seo_var); $makalequery = "INSERT INTO `jos_content` (`id`, `title`) VALUES (NULL, '$seo_link')"; $makaleekle = mysql_query($makalequery) or die("Problem with the query: $q<br>" . mysql_error()); Thank you for help... Note: I'm dealing with this problem for three days.. Best Regards... Hi Friends, i am new one to this.i have a big problem i think i will get the correct solution... when i am connecting to the MySql Database i am getting this. Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server at 'reading initial communication packet', system error: 110 in /home/txtimg0/public_html/cherple/Scheduled_Campaigns.php on line 24 unable to select database define("prod_dbuser","xxxx"); //gtmdev1 define("prod_dbpass","xxxxx"); //gtmdev1 define("prod_database_cm2","cm2"); define("prod_database_glue","glue"); define("prod_hostname","xxxxxxxx"); i am defined these constants in gtm _constants.php i am includeing this file when ever i need to connect with database. this working fine in past.now we installed the new Database from then i am getting this error. can any one Please me Help to Resolve this Issue.? and why php is not connecting to the database??? Thanks, Ramky Hello , i need some help on this line. Line: $compose_a = mysql_query("SELECT * FROM users WHERE username LIKE '%". realEscape($sendto) ."%' LIMIT 1") or die(mysql_error()); From the code : <?php if(isset($_GET['usercp']) && $_GET['send'] == 'true') { if($_POST['sendtitle'] == "") { echo "You need to have a message title."; } else { if($_POST['sendto'] == "") { echo "You must enter the username of the user you wish to send a message to."; } else { if($_POST['sendtext'] == "") { echo "You have not entered anything to send"; } else { $sendto = str_replace('_', ' ' , $_POST['sendto']); $compose_a = mysql_query("SELECT * FROM users WHERE username LIKE '%". realEscape($sendto) ."%' LIMIT 1") or die(mysql_error()); if(mysql_num_rows($compose_a) >= 1) { While($compose_b = mysql_fetch_array($compose_a)) { $sendto = $compose_b['id']; } mysql_query("INSERT INTO `notifications` (ipaddress, senderid, recieverid, sent, title, text) VALUES ('". $_SERVER['REMOTE_ADDR'] ."', '". $_SESSION['id'] ."', '" . $sendto . "', NOW(), '". htmlspecialchars($_POST['sendtitle']) ."', '". htmlspecialchars($_POST['sendtext']) ."')") or die(mysql_error()); echo "Message has been sent."; } else { echo "The username you entered does not Exist"; } } } } } ?> The $sendto is a username. i want to make it so if a user puts a Uppercase letter or a lowercase letter or a space where a '_' should be. it still matchs whats in the database. if you find a better way of doing this please post it I am slightly puzzled when I attempt to connect to MySQL using variables, if I use this:- Code: [Select] // Connect to MySQL and select dbase mysql_connect("$host", "$user", "$pwd") or die("Computer say NO!"); mysql_select_db("test_site") or die("I've just had a senior moment, and cannot connect to the database..."); I get this error:- Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in C:\wamp\www\php\test site\regproc.php on line 24 Computer say NO! Whereas if I use this:- Code: [Select] // Connect to MySQL and select dbase mysql_connect("localhost", "root", "my password") or die("Computer say NO!"); mysql_select_db("test_site") or die("I've just had a senior moment, and cannot connect to the database..."); it works perfectly. Most of the tutorials I have read seem to indicate that one can use variables in this case, so I do not understand why it doesn't work... <?php $username="a7564065_si"; $password="*****"; $database="a7564065_food"; mysql_connect(mysql4.000webhost.com,$username,$password); ... I am trying to connect to mysql but having trouble. The host name: mysql4.000webhost.com I get the error: Parse error: syntax error, unexpected T_DNUMBER in /home/a7564065/public_html/Index.html on line 17 Any ideas? Hey guys, I'm having a nightmare at the moment.
I am trying to import a CSV file into a MySQL table, some of the data is interested properly into the rows however some of the CSV row do not get imported.
Here is my PHP script:
<?php $databasehost = "localhost"; $databasename = "name"; $databasetable = "import"; $databaseusername="username"; $databasepassword = "password"; $fieldseparator = ","; $lineseparator = "\n"; $enclosedbyquote = '"'; $csvfile = "db-core/feed/csv/test.csv"; if(!file_exists($csvfile)) { die("File not found. Make sure you specified the correct path."); } try { $pdo = new PDO("mysql:host=$databasehost;dbname=$databasename", $databaseusername, $databasepassword, array( PDO::MYSQL_ATTR_LOCAL_INFILE => true, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ) ); } catch (PDOException $e) { die("database connection failed: ".$e->getMessage()); } $pdo->exec("TRUNCATE TABLE `$databasetable`"); $affectedRows = $pdo->exec(" LOAD DATA LOCAL INFILE ".$pdo->quote($csvfile)." REPLACE INTO TABLE `$databasetable` FIELDS OPTIONALLY ENCLOSED BY ".$pdo->quote($enclosedbyquote)." TERMINATED BY ".$pdo->quote($fieldseparator)." LINES TERMINATED BY ".$pdo->quote($lineseparator)." IGNORE 1 LINES"); echo "Loaded a total of $affectedRows records from this csv file.\n"; ?>As you can see the script is importing the CSV into the table however only 40 of the rows are added to the SQL table when there are actually 80 rows in the CSV. I am also telling the script to IGNORE 1 LINES if that has anything to do with the issue. Here is one of the rows from the CSV file: "AETA83919","AETV34458584","SD57VUP","BLACK","Diesel","2007","76778","Hatchback","3","VAUXHALL","CORSA","1.3 CDTi [90] SXi 3dr [AC]","1200","3989","","Manual","http://images.autoexposure.co.uk/AETA83919/AETV34458584_1b.jpg","0","3","","0","2007 57 reg VAUXHALL CORSA 1.3 CDTi [90] SXi 3dr [AC], Manual, Hatchback, Diesel, 76,778 miles. BLACK, Comprehensive Warranty Included In Price. HPI Checked! Pre Delivery Health Check!, 5 seats, LOVELY VAUXHALL CORSA SXI 1.3CDTI SXI WITH AIR CONDITIONING!! VERY WELL CARED FOR AND MAINTAINED AND JUST SERVICED BY DRIVEN CAR SALES LTD AT 76K!! GREAT COMBINATION OF PERFORMANCE AND ECONOMY!! VIEWING AND TEST DRIVING IS RECOMMENDED!! EACH CAR COMES WITH A MININIUM 9 MONTHS MOT. FULL MECHANICAL HEALTH CHECK GUARANTEES CAR IS PREPARED TO THE HIGHEST STANDARD. COMPREHENSIVE RAC WARRANTY INCLUDED. DRIVEN CAR SALES WELCOME ANY INSPECTION. BUY WITH CONFIDENCE AND REASSURANCE AS DRIVEN CAR SALES LTD ARE OFFICIAL MEMBERS OF RETAIL MOTOR INDUSTRY FEDERATION. VIEW OUR REVIEWS ON TRUSTPILOT. 3,989","","0","1","","UK","0","","0","0","","","",""As far as I can see everything looks fine with the row, all of the rows in the CSV end like this. One thing I have noticed is it looks like the rows that are missing are in fact being placed in the last column of every other row here is an example: So as you can see it looks like one row is being inserted into the last column of some rows and I am so confused to why this might be happening? Any ideas? I have problem with this code. It does absolutely nothing. When INSERT is over it should redirect to index.php but it does nothing. There is no error, when the submit is clicked the page just refresh itself and because of echo function it write all the values. What seems to be the problem (I going slightly mad ) Code: [Select] <?php require_once("public/includes/session.php"); ?> <?php require_once("public/includes/connection.php"); ?> <?php require_once("public/includes/functions.php"); ?> <?php include_once("public/includes/form_functions.php"); include_once("public/includes/header.php"); if (isset($_POST['submit'])) { // Form has been submitted. $errors = array(); $required_fields = array('nik', 'lozinka', 'ime', 'prezime', 'adresa', 'grad', 'postanskiBroj', 'fiskni', 'moblini', 'email'); $errors = array_merge($errors, check_required_fields($required_fields, $_POST)); $username = trim(mysql_prep($_POST['nik'])); $password = trim(mysql_prep($_POST['lozinka'])); $hashed_password = sha1($password); $ime = trim(mysql_prep($_POST['ime'])); $prezime = trim(mysql_prep($_POST['prezime'])); $adresa = trim(mysql_prep($_POST['adresa'])); $grad = trim(mysql_prep($_POST['grad'])); $postanskiBroj = trim(mysql_prep($_POST['postanskiBroj'])); $fiskni = trim(mysql_prep($_POST['fiksni'])); $moblini = trim(mysql_prep($_POST['mobilni'])); $email = trim(mysql_prep($_POST['email'])); echo $username . $hashed_password . $ime . $prezime . $adresa . $grad . $postanskiBroj . $fiskni . $moblini . $email; if ( empty($errors) ) { $query = " INSERT INTO `gume`.`korisnik` (`id`, `korisnicko_ime`, `lozinka`, `ime`, `prezime`, `adresa`, `grad`, `postanskiBroj`, `fiksni_telefon`, `mobilni_telefon`, `email`) VALUES (NULL, '$username', '$hashed_password', '$ime', '$prezime', '$adresa', '$grad', '$postanskiBroj', '$fiskni, $moblini', '$email' )"; $result = mysql_query($query, $connection) or die(mysql_error); if ($result) { redirect_to("index.php"); } else { $message = "The user could not be created."; $message .= "<br />" . mysql_error(); } } else { if (count($errors) == 1) { $message = "There was 1 error in the form."; } else { $message = "There were " . count($errors) . " errors in the form."; } } } else { // Form has not been submitted. $username = ""; $password = ""; } ?> <div id="telo"> <div id="kreiranjeNaloga"> <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script> <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" /> <script src="SpryAssets/SpryValidationPassword.js" type="text/javascript"></script> <script src="SpryAssets/SpryValidationConfirm.js" type="text/javascript"></script> <link href="SpryAssets/SpryValidationPassword.css" rel="stylesheet" type="text/css" /> <link href="SpryAssets/SpryValidationConfirm.css" rel="stylesheet" type="text/css" /> <p>Polja sa * su obavezna</p> <form action="new_user.php" method="post"> <span id="sprytextfield1"> <label>Korisnicko ime: </label> <input type="text" name="nik" id="nik" size="40" value=""/> *<span class="textfieldMinCharsMsg">Korisnicko ime ne moze imati manje od 5 karaktera</span><span class="textfieldMaxCharsMsg">Korisnicko ime moze imati najvise 30 karaktera.</span></span><br /> <span id="sprypassword1"> <label>Lozinka:</label> <input type="password" name="lozinka" id="lozinka" size="40" value=""/> *<span class="passwordMinCharsMsg">Sifra mora sadrzati najmanje 5 karaktera.</span><span class="passwordMaxCharsMsg">Sifra moze imati najvise 30 karaktera.</span></span> <br /> <span id="spryconfirm1"> <label>Potvrdite lozinku:</label> <input type="password" name="password1" id="password1" size="40" value=""/> <span class="confirmRequiredMsg">*</span>Obe lozinke moraju da budu iste.</span> <br /> <span id="sprytextfield2"> <label>Ime:</label> <input type="text" name="ime" id="ime" size="40" value=""/> * </span> <br /> <span id="sprytextfield3"> <label>Prezima</label> <input type="text" name="prezime" id="prezime"size="40" value="" /> *</span> <br /> <span id="sprytextfield4"> <label>Adresa:</label> <input type="text" name="adresa" id="adresa" size="40" value=""/> * </span> <br /> <span id="sprytextfield7"> <label>Grad:</label> <input type="text" name="grad" id="grad" size="40" value="" /> * </span> <br /> </span><span id="sprytextfield9"> <label>Postanski Broj: </label> <input type="text" name="postanskiBroj" id="postanskiBroj" size="10" value=""/> * <span class="textfieldInvalidFormatMsg">Postanski broj nije pravilno upisan.</span></span><br /> <span id="sprytextfield5"> <label>Broj fiksnog telefona: </label> <input type="text" name="fiksni" id="Broj fiksnog telefona" size="40" value="" /> *<span class="textfieldInvalidFormatMsg">Broj telefona nije pravilno upisan</span></span> <br /> <span id="sprytextfield6"> <label>Broj mobilnog telefona: </label> <input type="text" name="mobilni" id="mobilni" size="40" value="" /> *<span class="textfieldInvalidFormatMsg">Broj telefona nije pravilno upisan</span></span><br /> <span id="sprytextfield10"> <label>Email:</label> <input type="text" name="email" id="email" size="40" value="" /> *<span class="textfieldInvalidFormatMsg">Email adresa nija pravilno upisana.</span></span><br /> <input name="submit" type="submit" id="submit" value="Kreiraj korisnika" /> </form> </div> </div> <?php include("public/includes/footer.php"); ?> I'm going bananas with one of those issues where it looks like everything is right but the code won't work. I've included a script below that fetches data from a database and creates a drop down menu. I'm trying to use a field called "gone" and enter 'gone' in that field when I want to delete the row but be able to retrieve it by making the field empty. There is something in the WHERE clause of my sql that is screwing things up. I get nothing retrieved with any of the WHERE clauses below. Interestingly, when I take the where clause out completely, I get the rows that have no 'gone' in them. The code is below. None of the following in the included code get me a result. All of them return nothing. I also don't get any errors. Just nothing. WHERE gone != 'gone' WHERE gone <> 'gone' WHERE gone = '' WHERE gone = 'gone' Without the WHERE clause it runs fine. As a work around I tried using if($row['gone'] == 'gone') { continue;} In the while.. function at the end of the file to bypass rows with 'gone' in the field. It also stopped the script. Here's my code: <?php // person_selectall.php /** Create new pdo object */ require 'Db.php'; //$sql = "SELECT person_id, fname, lname FROM Persons"; $sql = "SELECT * FROM Persons WHERE gone = ''"; $stmt = $pdo->prepare($sql); $stmt->execute(); echo "<p><select class=\"select-field\" name=\"person_id\" >\n"; while ($row = $stmt->fetch()) { $name = $row['fname'] . ' ' . $row['lname']; echo "<option value=\"" . $row['person_id'] . "\">" . $name . "</option>\n"; } echo "</select>"; ?>
Hello everyone.
I have a large table consisting of 135497 rows
I have found that by indexing the table, it will take less time in quering the results.
In some site it shows that Using "Explain" before the queries will show that how much rows it has to travel to get the desired results.
SO I have doen and it shows like below...
mysql> EXPLAIN select * FROM ip2country WHERE 3084727327 BETWEEN begin_long_ip AND end_long_ip; +----+-------------+------------+------+---------------------------------------------------------------------------------+------+---------+------+--------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+------------+------+---------------------------------------------------------------------------------+------+---------+------+--------+-------------+ | 1 | SIMPLE | ip2country | ALL | ip_adress,begin_long_ip,end_long_ip,begin_long_ip_3,count_index,begin_long_ip_2 | NULL | NULL | NULL | 135497 | Using where | +----+-------------+------------+------+---------------------------------------------------------------------------------+------+---------+------+--------+-------------+The above results shows 135497. means it has to travel all the rows to get the result. So i have done index on the column ("begin_long_ip and end_long_ip) mysql> CREATE INDEX count_index ON ip2country(begin_long_ip,end_long_ip); Query OK, 135497 rows affected, 1 warning (0.87 sec) Records: 135497 Duplicates: 0 Warnings: 1But it still shows the same result. mysql> EXPLAIN select * FROM ip2country WHERE 3084727327 BETWEEN begin_long_ip AND end_long_ip; +----+-------------+------------+------+---------------------------------------------------------------------------------+------+---------+------+--------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+------------+------+---------------------------------------------------------------------------------+------+---------+------+--------+-------------+ | 1 | SIMPLE | ip2country | ALL | ip_adress,begin_long_ip,end_long_ip,begin_long_ip_3,count_index,begin_long_ip_2 | NULL | NULL | NULL | 135497 | Using where | +----+-------------+------------+------+---------------------------------------------------------------------------------+------+---------+------+--------+-------------+Ahy help will be greatly apprecaited... well i am having a new problem i didnt relize this till now and my website has gone live and i need a fix asap before my user's leave and never return ='( well when i set up a auction there is a image upload where you can upload your image... when trying to upload the image it change page and gave me this error Code: [Select] A Mysql error has occurred while running the script: The query you are trying to run is invalid Mysql Error Output: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND page_handle='auction'' at line 2 SQL Query: SELECT box_id, box_value FROM custom_fields_data WHERE owner_id= AND page_handle='auction' it was working before then i change some things around and dont remember what i change and found that this came up when setting up the image.... please help really need the help asap. i dont know what to do =( I'm working on my website, and I'm having a bit of trouble in getting PHP to select the proper data. I'm trying to select usernames from my database where rank is equal to one (the highest, in my system). As such, I attempted this code; Code: [Select] // Connection info above this line... mysql_select_db("users"); $query = mysql_query ("SELECT displayname FROM login WHERE rank = 1"); $query_a = mysql_fetch_array($query); var_dump($query_a); The var_dump resulting from that is as follows; Code: [Select] array 0 => string 'Seltzer' (length=7) 'displayname' => string 'Seltzer' (length=7) Everything is working correctly, except for the fact that my database contains two displayname rows where rank is equal to one (EDIT: Two distinct rows). In fact, I can run a search of it in phpMyAdmin and get the two that my PHP code should be returning. phpMyAdmin generated the following query, which Inserted into my code in order to double-check things; Code: [Select] SELECT `displayname` FROM `login` WHERE `rank` =1 LIMIT 0 , 30 Even after I swapped my queries, the PHP code still returned the same var_dump as above. Complicating things further, I've noticed another function I've made, which queries "SELECT rank WHERE displayname = '$displayname'", functions perfectly. I've gotten rid of pretty much any source of the error I could think of; I'm testing the function on an otherwise empty page, I've removed any classes being used, and I've tried about a million different queries. Can someone help me out with this? I'm being held up by it and I'm sure that this is a simple fix. Thanks in advance, Dustin |