Jump to content

AliG

New Members
  • Posts

    9
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

AliG's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Yes sure <?php include_once '../included/datenbank.php'; $mysql=dbk_connect("locahost", "Username", "12345", "database"); dbk_close($mysql); dbk_close($mysql) dbk_query($mysql,$sql : string) // run sql querry dbk_fetch_row($result) : cells as array dbk_fetch_assoc($result) : cells as associative Array dbk_errno($mysql) : ErrorNr ?> and these are the complete functions <?php function dbk_connect($dbserver,$dbuser,$dbpasswort,$dbname) { $mysqli = mysqli_connect($dbserver,$dbuser,$dbpasswort,$dbname); return $mysqli; }; function dbk_close($mysqli) { mysqli_close($mysqli); return $mysqli; }; function dbk_query($mysqli,$sql) { if (strpos(strtolower($sql),"select") != FALSE) { $result = ""; } else { $result = mysqli_query($mysqli,$sql); }; return $result; }; function dbk_fetch_row($result) { $row = mysqli_fetch_row($result); return $row; }; function dbk_fetch_assoc($result) { $row = mysqli_fetch_assoc($result); return $row; }; function dbk_errno($mysqli) { return $mysqli->connect_errno; }; ?>
  2. Hi thanks , it is resolved, I used $mysqli , which is already defined in the function given above, I assigned $mysql and worked.
  3. I am still getting an error Parse error: syntax error, unexpected '$mysqli' (T_VARIABLE) in $mysqli = dbk_connect("locahost", "Username", "12345", "databse"); Is there really not a way to assign a connectionID ? Thanks alot for the answer.
  4. HIi, I have a the following function function dbk_connect($dbserver,$dbuser,$dbpasswort,$dbname) { $mysqli = mysqli_connect($dbserver,$dbuser,$dbpasswort,$dbname); return $mysqli; }; function dbk_close($mysqli) { mysqli_close($mysqli); return $mysqli; }; now I wish to use it to connect to my database and for some reasons I must use this function and I cannot use mysqi_connect directly. So this is what I have to conenct to the database <?php include_once '../included/database.php'; dbk_connect("locahost", "Username", "12345", "databse"), "connectionID"; dbk_close("connectionID"); ?> I am getting errors because of the connectionID , I do not know how to assign the session a connection ID with the syntax above and I must use the function above. I would appreciate your help. Thanks
  5. You are right ,i would personally prefer that to Uwe fopen. However a self peoclaimed coding Genius is pushing us to use File in a PHP Bootcamp at my end. Thats that , nonethless appreciate your asisstance, have great sunday.
  6. Thanks, you are absolutely right , my CSV had something probably corrupt or something, I recreated the Medikamente.csv test data and the code works like a charm. Just out or curosity wanted to ask , since i but my head alot to get this right , can it not work this way , integrating this function with file and then probbaly with explode ? Thanks a million again for the asisstance. function imp_open($pfad) { // Daten auslesen und in der Tabelle speichern $content = file($pfad); return $content; }; $array=imp_open('C:/xampp1/htdocs/S1/Medikamente.csv'); $data=explode(",", $array);
  7. Thanks, getting this error Fatal error: Uncaught ValueError: array_combine(): Argument #1 ($keys) and argument #2 ($values) must have the same number of elements in C:\xampp1\htdocs\S1\try.php:7 Stack trace: #0 C:\xampp1\htdocs\S1\try.php(7): array_combine(Array, Array) #1 {main} thrown in C:\xampp1\htdocs\S1\try.php on line 7
  8. Thanks , I did , this just displays the array with keys and index , I want the data to be presented in a rather formatted way as shown above or here like this Data Row 1 Number 9000000 Name Zebra Type Noropor List number 159 Data Row 2 Number 9000000 Name Zebra Type Noropor List number 159 Data Row 3 Number 9000000 Name Zebra Type Noropor List number 159
  9. HI I I have the following code , I wish to output my array in a nicely formatted way but I cannot get to do this. The array should look like this Data Row 1 Number 9000000 Name Zebra Type Noropor List number 159 Data Row 2 Number 9000000 Name Zebra Type Noropor List number 159 Data Row 3 Number 9000000 Name Zebra Type Noropor List number 159 This is my code <body> <center> <h1>DISPLAY DATA PRESENT IN CSV</h1> <?php function imp_open($pfad) { // Daten auslesen und in der Tabelle speichern $content = file($pfad); return $content; }; $array=imp_open('C:/xampp1/htdocs/S1/Medikamente.csv'); foreach($array as $key => $value) { if (!is_array($value)) { echo $key ." => ". $value ."\r\n" ; } else { echo $key ." => array( \r\n"; foreach ($value as $key2 => $value2) { echo "\t". $key2 ." => ". $value2 ."\r\n"; } echo ")"; } } /*echo "<table>"; foreach ($array as $key => $value) { echo $key, $value,"<br>"; } /*echo "</table>"; $y=explode(",", $value);*/ ?> </center> </body> </html> my code would bring the following output This is my data 9999900001,"zebra","Noropr","159" 9999900002,"coco1","Noropr","999998" 9999900003,"coco12","Noropr","78" 99999000099999,"coco1123","Noropr","33" 9999900005,"coco198","Noropr","79" 9999900006,"coco111","Noropr","66" 9999900007,"coco1456","NoroprNoropr","2999996" 9999900008,"coco1sss","Salbe","55" 9999900009,"coco90","Salbe","90" 9999900010,"coco111111","Tabletten","102" 9999900011,"coco178989","Noropr","999998" 9999900012,"coco18283838383","Noropr","59" 9999900013,"coco17874738774","Tabletten","899999" 99999000199999,"Tannosynt","Salbe","71" 9999900015,"Vomex A","Noropr","699999" 9999900016,"Vomex A","Noropr","35" Thanks for the asisstance.
×
×
  • 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.