Jump to content

xxclear

Members
  • Posts

    34
  • Joined

  • Last visited

xxclear's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for your reply, that alone returns: var_dump($result); //this returns: col1, $value1, col2, $value2, col3, $value3 Notice "=" isn't inserted between each exploded result. What do i need to do to get that function to work between each result? FYI i get: PHP Parse error: syntax error, unexpected T_FUNCTION, expecting ')' In the original code.
  2. Can some help me make this code backward compatible? This code works with php 5.3 and above. I need it to work with 5.2.17. $columns = 'col1, col2, col3'; $values = '$value1, $value2, $value3'; $result = implode( ', ', array_map( function ($c, $v) { return $c . ' = ' . $v; }, explode(',', $columns), explode(',', $values) ) ); var_dump($result); //this returns: col1 = $value1, col2 = $value2, col3 = $value3 Cheers.
  3. Typical, i got it to work just as i was getting a print out for here. It seems that if i put in a date with a garbage keyword it gets the row with the date but if i don't put in a keyword it ignores the date... i thought the OR operator was supposed to overcome that? "The OR operator displays a record if either the first condition or the second condition is true." as taken from W3C
  4. Use onclick or onfocus functions in javascript http://www.webdeveloper.com/forum/showthread.php?191521-Show-Hide-div-based-on-Radio-button
  5. Thanks for replying. So this is what i did: $query = " SELECT id, auditor, auditee, datum, department, func, proc, audit_type, copy_to, comments FROM audit_data WHERE `auditor` LIKE '%$search_field%' OR `auditee` LIKE '%$search_field%' OR `department` LIKE '%$search_field%' OR `func` LIKE '%$search_field%' OR `proc` LIKE '%$search_field%' OR `audit_type` LIKE '%$search_field%' OR `id` = '$radio_id' OR `datum` = '$datum' " $result = mysqli_query($link, $query ) OR die(mysqli_error($link)); got a parse error on $result = mysqli_query($link, $query ) This is the real code i need it to work on btw, if it helps. What have a i done wrong?
  6. ok so i have set the query to a variable and used : print_r($result_debug); I get echoed back: "mysqli_result Object ( )" Where do i go from here, because your right: $result = mysqli_query($link, " SELECT id, col1, col2, datum, col4, col5, col6, col7, col8, col9FROM table WHERE `datum` = '$datum' " ) OR die(mysqli_error($link)); Doesn't work, and its killing me.
  7. Would echoing $result have the same affect?
  8. How do I search a column for a date which is stored as a var? Is this the best way? $result = mysqli_query($link, " SELECT id, col1, col2, datum, col4, col5, col6, col7, col8, col9 FROM table WHERE `datum` = '$datum' " ) OR die(mysqli_error($link)); Thanks in advance.
  9. Don't shy away chap & chapettes, any advice will be appreciated.
  10. I have tried it on my server and i'm getting the same error, the browser wasn't rendering it as expected, if you right click of the "Link" and inspect element you will see what i mean. Try setting a new variable above the echo and then try escaping the quotes with backslashes like this: $inf = $info['file']; echo "<a href=\"C:\php\website\files\'.$info['file'].'\">Link</a>"; If it still doesn't work it should at least give you a "Link". We can go from there.
  11. Breaking it down might help. echo "<a href=C:\php\website\files\'.$info['file'].'>"; echo "Link</a>"; What you are doing is letting the browser render its own quotes in the right place after the php has finished. (after the "=" and before the ">").
  12. It is possible but can i ask why? It would only work once as you can only have one database connected to website at any one time. are you sure you don't want to just create a new table? <?php $con=mysqli_connect("example.com","peter","abc123"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // Create database $sql="CREATE DATABASE my_db"; if (mysqli_query($con,$sql)) { echo "Database my_db created successfully"; } else { echo "Error creating database: " . mysqli_error(); } ?> as taken from W3C schools You would need to create an input form and use POST if you want it to be user controlled,
  13. You have single quotes inside single quotes there. Echo "<a href=C:\php\website\files\'.$info['file'].'>Link</a>"; Does that work ^^
×
×
  • 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.