Jump to content

jumbo

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jumbo's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I'm trying to call a script to run in the background. The script is in a file called script1.php, and I'm calling it from a test page through the following code: <? exec("/usr/bin/php /home/myaccount/public_html/test/script1.php >/dev/null &"); ?> I took this code from someone on the internet. They claimed this is the way to do it. However nothing happens. The script is supposed to write in the database. If I run script1.php directly, it works fine. Is the syntax I'm using correct? Thanks
  2. Hi I have like 50 tables I want to search through for a keyword. I am certainly not gonna do a query for each table separately, plus I need the results to be stored in 1 variable and ordered by date. The following query returns an error (using 2 tables for example): mysql_query("SELECT * FROM table1,table2 WHERE text LIKE \"%$keyword%\" OR title LIKE \"%$keyword%\" ORDER BY date") If I run this query using 1 table only, it returns a valid result. Is there something I missed here? PS: all the tables have the same structure, including columns named "text", "title" and "date" Thanks
  3. You're right!! doing it in 1 MySQL query makes it work! I thought about the PHP having to handle binary data, but i couldnt make sure it got distorted that way! Thanx a lot for your help! Admins can mark this thread as [solved] PS: the extra quote was a typo, im sorry
  4. Hi im trying to copy a row from table1 unto table2. The row contains 2 text fields and a blob object. The two tables have the same exact structure. My code goes like: $query1= mysql_query("SELECT * FROM table1 WHERE ID='$id' "); $num1 = mysql_num_rows($query1); if($num1 == 0) { $error.="Wrong ID"; die(); } $result1 = mysql_fetch_array($query1); $query2= "INSERT INTO table2 VALUES ("'{$result1[iD]}','{$result1[text]}','{$result1[pic]}')"; So the BLOB element is a picture and is the last value in the row. The code above returns a MySQL error: "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 '' at line 1" What is wrong in my code? do i need to treat the BLOB element differently than the other text fields? Thank you
  5. Hi all i'm working on a recursion function and i'd like to know how to track the depth of the recursion... thanx
  6. NOTE: in the code, just call the function pathx like: pathx($arr, 5, 5, 1, $parr, $x); //find all paths from 5 to 1, with 5 being supposedly the previous node for itself
  7. i see what u mean... but im trying to do this differently... like having a new array each time i find a new possible path...
  8. thanx dude ur code does return a valid result, which is great... actually i need all possible paths between 2 endpoints... so im trying to work around ur code and see i can make that possible... meanwhile any other input from anyone is most welcome! thanx again
  9. no one has any answer?
  10. the array actually looks like this [attachment deleted by admin]
  11. Hi guys i'm trying to find all the paths from a starting node to an ending node in a network (refer to the attached pic) what im doing is that i'm populating an array ($arr) with the connections that each node has with its neighbours. then in the function pathx, i'm trying to recursively find all paths that lead from a given starting node to a given ending node. now 3 essential assumptions should be made in the algorithm that guarantee a right output: 1- don't forward to an incoming node (that is, if the path is 1 - 0 - 2, i cannot go back to 0 from 2) 2- dont forward to a node already in the sequence (that is, 1 - 0 - 2, i cannot go from 2 back to 1 because it's already there) 3- if u get to a node where the only next possible node is already in the sequence, dismiss that path (example: 0 - 1 - 3 - 4 - 5 - 2 ==> then from 2 u can only go to 0 or 1, which are already in the sequence... then the mistake was 5- 2, then from 5 u gotta find another path) the code i've written so far returns promissing results, but i couldnt figure out how to implement the previous 3 essential points... my main problem is how to store and process the sequence during recursion (dynamically append new nodes or dismiss the entire sequence, or compare the new node to previous nodes in the sequence) to see the results, comment the echo"arr[".$start."][".$i."]"; line (which shows how the recursion proceeds) and uncomment the other echos... any help would be highly appreciated... thanx <? $arr = array(0 => array(0=>1,1=>2)); $arr[1] = array(0=>0,1=>2,2=>3,3=>7); $arr[2] = array(0=>0,1=>1,2=>5); $arr[3] = array(0=>1,1=>4); $arr[4] = array(0=>3,1=>5); $arr[5] = array(0=>2,1=>6); $arr[6] = array(0=>5,1=>7); $arr[7] = array(0=>1,1=>6); function pathx($arr, $prev, $start, $end) { foreach ($arr[$start] as $i => $value) { echo"arr[".$start."][".$i."]"; // echo $start.' - '; if ($arr[$start][$i] == $end) { echo $end; // echo"<br>"; } else if ($arr[$start][$i] == $prev){echo" | ";} else { pathx($arr, $start, $arr[$start][$i], $end); // echo $arr[$start][$i].' - '; } } } ?> [attachment deleted by admin]
  12. Great! It worked, thanx! Yeah, that turned out to be a misconception... So mysql_query() returns false if the query doesnt succeed because of the table missing, or the filed missing for example right?
  13. hi there i know that mysql_query() returns TRUE when it succeeds and FALSE if not... but it doesnt work well for me... i have a table where i got emails... and im trying to design a simple code that allows me to check whether an email is there or not... the code looks like this: [code]<? mysql_connect('localhost', 'me_user', 'password'); mysql_select_db('me_database'); if (isset($_POST['submit'])) { $em1=$_POST['em']; if( mysql_query("SELECT `email` FROM `emails` where ('email' = '$em1')"))        //table is called emails, and column is called email {echo "The email is already in the DB";} else {echo "This email address is not in the DB";} ?> <html> <body> <form method="post">           <input type="text" name="em" size="20"> <input type="submit" name="submit" value="submit"> </body> </html> [/code] when i enter any email, whether it is there or not, it always return The email is already in the DB!!! What is wrong with this code? or is it the mysql_query()?? Thanx
×
×
  • 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.