Jump to content

premiso

Members
  • Posts

    6,951
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by premiso

  1. umm try this, you removed the mysql_connect portion out of the code thus no sql connection would be found. <?php ini_set("display_errors", 1); error_reporting(E_ALL); //database inforamtion $host="stocks"; // Host name $username="wbennett"; // Mysql username $password="mysql5"; // Mysql password $db_name="wbennett"; // Database name $tbl_name1="flight_webair"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $one_way= isset($_POST['one_way'])?$_POST['one_way']:null; // make sure value is available first. //To protect MySQL injection $flight_route_out = stripslashes($flight_route_out); $flight_route_return = stripslashes($flight_route_return); $flight_route_out = mysql_real_escape_string($flight_route_out); $flight_route_return = mysql_real_escape_string($flight_route_return); //Queries $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'"; //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'"; //Execute query 1 $result = mysql_query($sql1) or die(mysql_error()); echo mysql_num_rows($result); while ($row = mysql_fetch_assoc($result)) { echo $row['flight_route_out']; // removed the $ echo $row['flight_route_return']; // removed the $ } mysql_free_result($result); ?> If it was there, what errors if it giving you?
  2. <?php if ($field == 0) { echo "Some Text"; }elseif ($field == 1) { echo 'Do something else!'; } maq just modified my post. It was correct all along =)
  3. <?php ini_set("display_errors", 1); error_reporting(E_ALL); //database inforamtion $host="stocks"; // Host name $username="wbennett"; // Mysql username $password="mysql5"; // Mysql password $db_name="wbennett"; // Database name $tbl_name1="flight_webair"; // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); You still need the mysql_connection
  4. Yea, look at rhodesa's example. I just missed that it was a mutli-dimm array. =)
  5. Keep the error checking for now, you can remove the print test array stuff though.
  6. money_format is not available in windows environment. On a Linux server it would work. Look at number_format the user examples, one posted a money formater that may help you. There is also one that can be found on the money_format page.
  7. Why not use the implode <?php $sWhere = implode("' AND '", $aAffiliates); Should get what you want =)
  8. <?php $one_way= isset($_POST['one_way'])?$_POST['one_way']:null; // make sure value is available first. //To protect MySQL injection $flight_route_out = stripslashes($flight_route_out); $flight_route_return = stripslashes($flight_route_return); $flight_route_out = mysql_real_escape_string($flight_route_out); $flight_route_return = mysql_real_escape_string($flight_route_return); //Queries $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route` = '$flight_route_out'"; //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'"; //Execute query 1 $result = mysql_query($sql1); if (mysql_error()) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $sql1; die($message); } while ($row = mysql_fetch_assoc($result)) { echo $row['flight_route_out']; // removed the $ echo $row['flight_route_return']; // removed the $ } mysql_free_result($result); ?> Commented what I fixed.
  9. You could just make a functions include, where you create functions the same as what you want to call in the DB. IE: <?php require('db.class.php'); $db = new dbClass(); function query($query) { global $db; $db->query($query); } ?> That way you can have the valid SQL connection and use the db class functions anywhere in your script, where it is in class a or class b. To call it you would just do query($sql); I found that to be the quickest way so you do not have to have the DB class instantiated about 10 times or passed by reference to each class 10 different times =)
  10. Fully corrected version, with error turned on: <?php ini_set("display_errors", 1); error_reporting(E_ALL); echo "Test Post Data <pre>"; print_r($_POST); echo "</pre>End Test Post Data"; //database inforamtion $host="stocks"; // Host name $username="wbennett"; // Mysql username $password="mysql5"; // Mysql password $db_name="wbennett"; // Database name $tbl_name1="flight_webair"; // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); //variables $flight_route_out=$_POST['flight_route_out']; $flight_route_return=$_POST['flight_route_return']; $date_out=$_POST['departure_date']; $date_return=$_POST['return_date']; $passenger_num=$_POST['num_of_pass']; $one_way=$_POST['one_way']; //To protect MySQL injection $flight_route_out = stripslashes($flight_route_out); $flight_route_return = stripslashes($flight_route_return); $flight_route_out = mysql_real_escape_string($flight_route_out); $flight_route_return = mysql_real_escape_string($flight_route_return); //Queries $sql1="SELECT * FROM `$tbl_name1` WHERE `flight_route_out` = '$flight_route_out'"; //$sql="SELECT * FROM $tbl_name1 WHERE flight_route_return='$flight_route_return'"; //Execute query 1 $result = mysql_query($sql1); if (mysql_error()) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $sql1; die($message); } while ($row = mysql_fetch_assoc($result)) { echo $row['flight_route_out']; echo $row['flight_route_return']; } mysql_free_result($result); ?> Run that and see what shows up.
  11. For queries this is not true, a single equals works. For the verification part. print_r($_POST); Will print out all the variables, make sure the ones you need come out.
  12. I think you forgot to implement the pimp class to make sure the hoe works....LOL I couldnt help myself sorry =)
  13. $flight_route_return=$_post['flight_route_return']; $_POST needs to be caps. '$tbl_name1' WHERE 'flight_route_out' Needs to be: `$tbl_name1` WHERE `flight_route_out` Table and columns need to be encapsulated in backticks (`) not single quotes('), only data should be encapsulated in (').
  14. FullText is great as long as you have alot of data, if your search terms return more than 50% (i think its 50%) of the results, it comes out false (I think). But I have not used FullText in a while, I am not exactly I can answer your question.
  15. Try it out =) Notice the first if he checks for 11, so it should return correctly.
  16. Alphabetized <?php $sql="SELECT facebook_usera.users as userA,facebook_userb.users as userB FROM facebook_usera A, facebook_userb B WHERE A.users LIKE '%john%' OR B.users LIKE '%john%' order by a.users, b.users"; ?>
  17. $data = array(0 => array('Amount' => '35.00', 'Customer_id' => '6172', 'Age' => '115'), 1 => array('Amount' => '99.00', 'Customer_id' => '6172', 'Age' => '115'));
  18. Set a date in the database, then setup a cron job to run every x minutes, if that date has been reached do an update, if not than do not update.
  19. To what? What is a standard max length for usernames, first names, email addresses? Also, since the password will be a md5 should I set it as char(32) in the table? varchar(32) for the password storage. There is no standard for those lengths, its your preference. Whatever you feel is a good length for them set it to that, see the above post for my preferences.
  20. No, invalid sql. The following would work. <?php $sql="SELECT facebook_usera.users as userA,facebook_userb.users as userB FROM facebook_usera A, facebook_userb B WHERE A.users LIKE '%john%' OR B.users LIKE '%john%'"; ?>
  21. An MD5 has a length of 32 characters, so that size is set I would think. As for the username portion, this would be true. As far as max lengths for username, I do anywhere from 15-30 depending on the site. For fname and lname, I allow it to be 15 chars each just incase. Email address I set at varchar(255), anything longer I take it the user is insane and should not be allowed on my website.
  22. I would also suggest using sessions, so add session_start after the <?php tag.
  23. What if someone puts a 200 character password or 200 character username? Does a user table with maxlength for usernames, passwords, fname, lnames, etc with about 50 - 60 chacters run alot faster than a user table with a maximium with about 250 - 300 chacaters? Username should be limited. For the password, it will be checked and as long as they had all the 200 characters right it would log them in. It would just be their loss cause the password could easily be forgotten, which is why I limit passwords to avoid too many password resets. User's are assumed to be stupid, so you must guide them as much as possible to avoid them getting frustrated and confused and having problems.
  24. <?php $query = "SELECT membera.usera, memberb.userb FROM membera as A AND memberb as B WHERE A.usera LIKE '%$search%' OR B.userb LIKE '%$search%'"; ?> Invalid SQL, as cannot be in the FROM part, you also are using AND, which would throw an error, and you do not have a comma. corrected <?php $query = "SELECT A.usera, B.userb FROM membera A, memberb B WHERE A.usera LIKE '%$search%' OR B.userb LIKE '%$search%'"; ?> If you would like further guidance, I would suggest creating a new topic =)
  25. The second will error, you do not need to use as keyword (cannot use as keyword in table definitions. <?php $query = "SELECT membera.usera, memberb.userb FROM membera A,memberb B WHERE A.usera LIKE '%$search%' OR B.userb LIKE '%$search%'"; ?> Either will be just as fast, but I prefer the method above, less chance of an error for mis-writing the whole table name.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.