wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
Also you have a logic issue here while ($db_field = mysql_fetch_assoc($result)) { $row['full_story'] = str_replace ($db_field['title'],"<a href=\"?newsid=" . $db_field['id'] . "\">" . $db_field['title'] . "</a>" ,$row['full_story']); $row['short_story'] = str_replace ($db_field['title'],"<a href=\"?newsid=" . $db_field['id'] . "\">" . $db_field['title'] . "</a>" ,$row['short_story']); } $mydata =$row['short_story'] . $row['full_story']; The variable $mydata will only hold the value to the last row (83,000th row). The previous 82,999 rows will not be outputted at all. You also don't seem to be doing anything with the $mydata variable either.
-
That wont work. mysql_connect doesn't have a fourth argument for selecting the database. You need to use mysql_select_db to connect to a database with the standard mysql function library.
-
session_start will either resume an existing valid session yes. It will not overwrite your existing $_SESSION vars. It will however clear your session variables when your browser is closed or when the session times out.
-
This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=339480.0
-
This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=339477.0
-
You are going to http://localhost to run your html/php file. You cannot load the php file directly into your web browser. It needs to be requested from localhost.
-
Need Help Creating 3 Columns From a Simple Query Array
wildteen88 replied to TecTao's topic in PHP Coding Help
Have a look at this thread for ideas http://www.phpfreaks.com/forums/index.php?topic=95426.0 -
You need install a server environment (known as the AMP stack) in order to run PHP code. There are couple of packages you can install called wamp or XAMPP. Read their document for where to place your php files. You then go to http://localhost/ to run them. EDIT: corrected the link to XAMPP.
-
You're right its calling index.php twice. I have just tested this myself using file_put_contents('data.txt', time() . "\n", FILE_APPEND); In an index.php file. It records two timestamps when calling index.php When web browsers request for files they also request for a file called favicon.ico at the same time. This is what is happening when you call index.php. The browser will first request for the webpage (index.php) and then immediately after it is calling for favicon.ico which what is adding the secondary timestamp to your database. The reason why the favicon.ico file is calling index.php is because your rewriterule is writing everything to the index.php file. Change your rewriteCond block to RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !favicon.ico #ignore the request for favicon.ico RewriteCond %{REQUEST_FILENAME} !-d When you start using images/css/javascript files within your pages you'll also need to ignore the requests for these too. You can change RewriteCond %{REQUEST_FILENAME} !favicon.ico to RewriteCond %{REQUEST_FILENAME} !.(ico,css,js,jpg,gif,png)$ # ignore requests to icons, css, javascript, and images
-
Could you post your code here (within or tags).
-
I'm always helping in the PHP help board. I hardly post in here.
-
End your table definitions with a semi-colon. In some of your table definitions you're using data types such 'smalldatetime' and 'uniqueidentifier' which do not exist in MySQL. Perhaps smalldatetime should be datetime. I guess uniqueidentifier should be int if its to be used as a foreign key?
-
mysqli_connect() is returning an empty mysqli object. This line echo '<pre>' . print_r($dbc, true) . '</pre>'; Should output something similar to mysqli Object ( [affected_rows] => 0 [client_info] => 5.1.49 [client_version] => 50149 [connect_errno] => 0 [connect_error] => [errno] => 0 [error] => [field_count] => 0 [host_info] => Localhost via UNIX socket [info] => [insert_id] => 0 [server_info] => 5.1.49-1ubuntu8.1 [server_version] => 50149 [sqlstate] => 00000 [protocol_version] => 10 [thread_id] => 138 [warning_count] => 0 ) As the connection is returning an empty mysqli object ($dbc) this could be why mysqli_real_escape_string is failing.
-
Yes, you can use explode combined with list to place each line into variables. Example code <?php //the data $data = 'John Doe John Doe Home Services 4748 National Rd E, Richmond, IN 47374 (765) 962-3908 johndoe@email.com www.johndoe.com'; // standardise newlines to \n character $data = str_replace(array("\r\n", "\r"), "\n", $data); // put each line into variables list($name, $companyName, $companyAddress, $telNumber, $email, $website) = explode("\n", $data); ?> <!-- display the data --> <b>Name</b>: <?php echo $name; ?><br /> <b>Company Name</b>: <?php echo $companyName; ?><br /> <b>Address</b>: <?php echo $companyAddress; ?><br /> <b>Tel. No.</b>: <?php echo $telNumber; ?><br /> <b>Email</b>: <?php echo $email; ?><br /> <b>Url</b>: <?php echo $website; ?>
-
Change $dbc = mysqli_connect($dbhost,$dbuser, $dbpass, $db) or die('Error connection'); To $dbc = mysqli_connect($dbhost,$dbuser, $dbpass, $db); if (mysqli_connect_errno()) { die('Connect failed: '. mysqli_connect_error()); } else { echo 'Successful Connection!<br />'; echo 'We are connected to: ' . mysqli_get_host_info($dbc); echo '<pre>' . print_r($dbc, true) . '</pre>'; } @Muddy_Funster: You cannot use mysqli_real_escape_string without be connected to mysql first! So your reply is not very helpful and making the matter even more confusing.
-
What are you wanting to do? Are you wanting to convert John Doe John Doe Home Services 4748 National Rd E, Richmond, IN 47374 (765) 962-3908 johndoe@email.com www.johndoe.com in to this format Name: John Doe Company Name: John Doe Home Services Address: 4748 National Rd E, Richmond, IN 47374 Tel. No.: (765) 962-3908 Email: johndoe@email.com Url: www.johndoe.com . Where is this data coming from? And have you made any attempt at doing this yourself? Post your code here within or tags.
-
SO when you uncomment these lines //$username = mysqli_real_escape_string($dbc, ($_POST['username'])); //$password = mysqli_real_escape_string($dbc, ($_POST['password'])); It comes up with an error? Does this error show on both your development and production boxes? The way you have coded those line is exactly how you use mysqli_real_escape_string.
-
Warning: mysql_fetch_array() ... null given: Bad class method?
wildteen88 replied to MasterACE14's topic in PHP Coding Help
Without those changes the $result variable will be set to null as your static function is not returning anything. $result = self::confirm_query($result); Which is overriding the value returned by mysql_query() earlier on. mysql_fetch_assoc expects a results resource to be given to it. That is what should be returned when you call $db->query(). -
You cannot use the mysql*() and mysqli*() functions together. If you're using mysql() based functions on your dev box but use mysqli based functions on your live box, then update your dev box to work with mysqli. You should configure your dev box so its configuration is similar to your live box.
-
Warning: mysql_fetch_array() ... null given: Bad class method?
wildteen88 replied to MasterACE14's topic in PHP Coding Help
Your need to return $result in your confirm_query() function private function confirm_query($result) { if(!$result) { trigger_error('Database query confirm failed: ' . mysql_error(), E_USER_ERROR); return false; } return $result; } -
Using PHP and mysqli to connect to a mysql database using socket
wildteen88 replied to CallumA's topic in PHP Coding Help
You don't need to use a socket to connect to MySQL. Just set the host field (first argument) to 'localhost'. Enter your mysql username into the second argument. Place the password for the user in the third argument. Last enter the mysql database you want to work with in the forth argument. Example PHP code to connect to mysql using MySQLi $mysqli = new mysqli('localhost', 'username', 'password', 'database'); if (mysqli_connect_error()) { die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); } echo 'Success... ' . $mysqli->host_info . "\n"; $mysqli->close(); Documentation on mysqli connect -
This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=339431.0
-
This what you mean <p><?php echo $row_test['platos']; ?> + <?php echo $row_test['mhkos']; ?> = <?php echo $row_test['platos'] + $row_test['mhkos']; ?></p>