Jump to content

mikosiko

Members
  • Posts

    1,327
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by mikosiko

  1. ok... one more try... do this modifications in your code (commented with ADD THIS LINE ... 2 lines) <?php $list = "SELECT * FROM section_main"; $result = mysql_query($list) or die ("Query failed"); $numofrows = mysql_num_rows($result); echo "Select 1 Rows :" . $numofrows; // ADD THIS LINE echo "<table border='1' id='section_list'>"; echo "<tr><th>section_id</th><th>section_title</th></tr>"; for($j = 0; $j < $numofrows; $j++) { echo '<tr>'; $row = mysql_fetch_array($result); echo "<tr><td>". $row['section_id'] . "</td><td>". $row['section_title'] . "</td></tr>"; $answer = $row['section_title']; $query2 = "SELECT * FROM section_sub WHERE section_title = ".$answer." ORDER BY section_sub_title"; $result2 = mysql_query($query2) or die("Select Error :" . mysql_error()); $numofrows2 = mysql_num_rows($result2); echo "Select 2 Rows :" . $numofrows2; // ADD THIS LINE for($i = 0; $i<$numofrows2; $i++){ $row2 = mysql_fetch_array($result2); echo '<tr><td>'.$row2['section_sub_title'].'</td></tr>'; } } echo '</table>'; ?> and analyze what numbers those echoes gave to you... and after that look your real data for both tables and try to understand what is happening.
  2. no even close to the error that your code is giving to you... nor similar... but well... change this line... in your code $query2 = "SELECT * FROM section_sub WHERE section_title = ".$answer." ORDER BY section_sub_title"; to this $query2 = "SELECT * FROM section_sub WHERE section_title = '".$answer."' ORDER BY section_sub_title"; notice that I just added a single ' before and after the " surrounding $answer
  3. well.. look again... first your tables and then your select... and then the error " Select Error: Unknown column 's.section_id' in 'order clause' " do you see any section_id field in your section_sub table ?
  4. post the structure of your tables (both)... the error is telling you exactly what is happening.. just check your tables and look if the select is consistent with their definition.
  5. $result = mysql_query($query) or die("Select Error: " . mysql_error()); and check the error.
  6. for your future reference (if you don't already have it) http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html
  7. same answer than in the other forum - In your $query definition... what is the value of $newdbname ? do you have that variable defined in your dbinfo.inc.php file? - Suppress the "@" before your @mysql_select_db if there are an error you are suppressing the display of it. - write the line mysql_query($query) at least in this way mysql_query($query) or die("Query Error: " . mysql_error()); that will show that you have an error in your UPDATE sentence $query="UPDATE * FROM $newdbname SET username ='$ud_username', password= PASSWORD('$ud_password') WHERE id='$ud_id'" is not a valid syntax for the UPDATE clause http://dev.mysql.com/doc/refman/5.0/en/update.html
  8. article_number is ambiguous... you have that column in both tables... you must specify which one you want to use in your group by
  9. you have an incorrect ")" after the first item in your VALUES ($item => title),... etc..etc
  10. fortnox is incorrect based on the format of the sentence. this sentence is incomplete $sql =("SELECT `customer_id`, `nic`, `full_name`, `name_with_initials`, `address`, `contact_number`, `gender` FROM `customer` WHERE `nic`='%s'", mysql_real_escape_string($_POST['nic']) ) ; should be write this way $sql = sprintf("SELECT `customer_id`, `nic`, `full_name`, `name_with_initials`, `address`, `contact_number`, `gender` FROM `customer` WHERE `nic`='%s'", mysql_real_escape_string($_POST['nic']) ); there '%s' is formating mysql_real_escape_string($_POST['nic']) as a string. http://www.php.net/manual/en/function.sprintf.php
  11. check the values for your system variables auto_increment_increment and auto_increment_offset maybe is something there http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html
  12. good... looks this lines: //Function to sanitize values received from the form. Prevents SQL injection function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } //Sanitize the POST values $login = clean($_POST['login']); $password = clean($_POST['password']); Do you see the reference to a "form" and then the usage of $_POST['login'] and $_POST['password'] ?? if you don't have the form (another php/html file) which is supposed to show you a screen to allow you enter your login and password and then call the script that you posted, then I'm afraid that you need to read/study a lot more before make it works. and forget about the "mysql.sql" document that you have.. the purpose of that was only create the table and import a row of data on it ... which according to your post you already did. just read/try some more examples and if you have doubts post again
  13. well.. try to isolate the problem first... test again that MYSQL is working try this replacing the "your_etc.etc" with the username and password for your database and see if that works. <?php $link = mysql_connect('localhost', 'your_username', 'your_username_password'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_close($link); ?>
  14. Sorry if I'm insulting your intelligence here (no my intention).. but.. after read again your post here: I'm wondering if you really have MYSQL installed, up an running.. could you please clarify it you have it and how did you tested that it is in working conditions?
  15. at first glance (I didn't read all the code) this line: //Connect to mysql server $link = mysql_connect(host, user, pass); doesn't look good at all... that should be something like: //Connect to mysql server $link = mysql_connect($host, $user, $pass); and obviously you have to define the values for each variable in some place
  16. and ?... it is working or not?.... if not: - Check that your first line in the code that you posted is not a blank line (nothing before your first "<?php" - Check the same for the file that you are including (dbconnect.php). hope it helps
  17. a few basic questions.... which platform is your server?... *NIX (any unix flavor) or Windows? ... - if *NIX... did you test that sendmail is installed/configured and working? - if Windows... did you configure your php.ini with the proper SMTP server?
  18. what part is not working?.... works for me.... what datatype is your column 'date' is a DATE or DATETIME?
  19. this is the reason why it works and your previous intent don't.... read the allowed "types" below CAST in the function CONVERT http://dev.mysql.com/doc/refman/5.0/en/cast-functions.html#function_cast
  20. what Zanus said... but the main reason for your error is that you didn't define the alias (b) for your table products as you did for the table basket (a). +1 in the way that Zanus wrote the sentence
  21. could you post your table simple_search description?.... or tell us what datatype/length the column sdescription has... the example that you posted is exactly 254 characters long.... could be your sdescription field a VARCHAR(255) ?
  22. yes, you can ... the only thing that you need to do is add a field that represent the difference... easy and more simple.... but.. If you want to do in your way and pay the price is ok. you can solve your search creating a VIEW with the UNION of all the tables (horrible... but works)... just google for examples
  23. do you want to solve it just with a query?... I don't think it is possible. I can think in 2 approachs: - Use a combination of PHP and mysql PREPARED INSERT. or if you are more comfortable with MYSQL - a MySQL Stored procedure that include the PREPARED INSERT below is a few lines that could help you as an example (incomplete example of course) /* Prepare Insert Statement */ $stmt = $mysqli->prepare("INSERT INTO test1 (ip,posdate,obs) VALUES (?, ?, ?)") or die("Error " . $mysqli->error); $stmt->bind_param('sss', $val1, $val2, $val3) or die($mysqli->error); /* execute prepared statement */ $stmt->execute() or die($mysqli->error); printf("%d Row inserted.\n", $stmt->affected_rows); /* close statement and connection */ $stmt->close();
  24. MySql Workwench should solve your issue.
  25. In case that you didn't notice... the name of the function that was provided to you is a link to the manual ... here is the whole link http://www.php.net/mysql_num_rows
×
×
  • 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.